Compressing JSON: Gzip vs. Zstd
lemire.me
lemire.me
Most of the gzip competitors beat it in time (LZ4) or space (LZMA or Bzip) but zstd's aim was always to replace gzip by not extending the time-space tradeoff curve but rather moving the whole curve.
I actually did a simple SquashFS benchmark myself a while back[1][2] (including Zstd vs plain zlib, which SquashFS calls "gzip") and came to the same conclusion as the article: Zstd turned out to compress somewhat faster, decompress more than twice as fast and achieved a higher data density. It would be interesting how much the better optimized zlib mentioned in the article could gain on Zstd at least in terms of speed.
Interestingly, in addition to zlib, in my benchmark Zstd also clearly beats LZO in terms of speed and size.
[1] https://github.com/AgentD/squashfs-tools-ng/blob/master/doc/...
[2] https://github.com/AgentD/squashfs-tools-ng/blob/master/doc/...
gzip in comparison delivered very-nice but only half as good ratios of around 15x. For the "bulk transfer" case gzip went fairly slowly, it couldn't nearly reach gigabit rates - it still transferred less data, but it took significantly longer than uncompressed and still longer than compressed.
gzip slows down a lot on incompressible data (not as bad as LZMA though), so it's not a good choice as an "always-on" compression. zstd on the other hand handles incompressible data very well. Unless the I/O is quite a bit faster than 100 MB/s, using zstd will very likely only improve things.
tldr: zstd seems to be somewhat more flexible, generally provides slightly better performance across almost all metrics, and decompresses much more quickly than Brotli.