gzip+Homogenius < gzip < Homogenius < original JSON
gzip+Homogenius will typically be better than just gzip because Homogenius 'knows' about the structure of JSON. gzip will typically be better than Homogenius (without gzip) because it can compress the payload.
Here's the size (in bytes) of the sample files given with the project:
I get the same ordering with gzip, but it seems sensitive to compression algorithm. With bzip2 (default settings, v1.0.6), homogenius seems to actually worsen the compression ratio, at least on this one example:
BWT-based compressors like bzip2 do best when their inputs have highly repetitive structure. In a JSON file with many repeated keys, the information that `"k` is usually followed by `ey_1": "` is compressed very effectively. For similar reasons, bzip2 tends to outperform gzip on executables-- it can more effectively model the conditional probability of opcode sequences.
Semi-OT: i am amazed to see how many big sites do not have gzip/deflate compression enabled in their webservers. Especially on mobile connections this can actually make a difference.
I think this needs some sort of marker for the compressed form to make it clear it's not to be digested as is. Maybe `$HMGNS$` or something as the first key of the array?
I see two great things about this tool, and not exactly for what it was designed:
1) Fix bandwidth problems caused by API designer laziness.
2) Detect API designer laziness and programmer laziness.
The API designer laziness merits description. Essentially, if you as an API host server are sending back tons of redundant data, you are doing a disservice to your user by not passing references to this data in the first place. The results in your API should either include an entities section or links to retrieve more data. (Note the scale of repeated data I am talking about here are subtrees, not just key/value)
The programmer laziness is when an he just sends back JSON.stringify(someVeryLargeObject), instead of making sure only a minimal object is sent back.
So we can detect this laziness by running this tool and looking for 4x compression gains!
It's not always lazyness, several small connections can be considered worse than one bigger payload in some scenarii.
There's no universal truth about API design, every case is different.
Sending too much data is often better than having to do many RPC calls. It's the same problem than normalizing/denormalizing DB schemas, except that DB engines are smart (denormalizing can hurt perf) while RPC clients aren't.
You loose in human readability but you win in size.
An interesting project and i think about a lot of uses for it (save bandwith, avoid timeout etc ...)
thks to make it and i will use it (in go i think).
So it's a schema plus interned values? Do you think it might be better on real-world data to use just one mapping of value id to value instead of one per column/key?
For some apps, there are cases where you want to load the entire dataset and then operate over it (see pourover.js http://newsdev.github.io/pourover/ )
Edit: I did a quick test by myself, using the first example but repeated for 10,000 objects:
Interesting to see a ~4x between raw JSON and Homogenius JSON both when compressed and not compressed.