by ComputerGuru · 8y ago · 0 comments
For example, if you know you're dealing with text, you can use snappy, if you know you're dealing with images, webp, videos x264 (or x265 if you only care about decode speed and encoded size), etc and then fall back to zstd only when you don't have a specific compressor for the chosen file type.
On enwik8 (100MB of Wikipedia XML encoded articles, mostly just text), zstd gets you to ~36MB, Snappy gets you to ~58MB, while gzip will get you to 36MB. If you turn up the compression dials on zstd, you can get down to 27MB - though instead of 2 seconds to compress it takes 52 seconds on my laptop. Decompression takes ~0.3 seconds for the low or high compression rate.
In my experience, if compression time is not a factor, for text (non-random letters and numbers), lzip is the best. I recently had to redistribute internally the data from python nltk, and tried to compress/decompress with different tools, this was my result (picked lzip again):
gzip -9 10 m 503 MiB 31 s
zstd -19 29 m 360 MiB 29 s
7za a -si 26 m 348 MiB s
lzip -9 78 m 310 MiB 50 s
lrzip -z -L 9 (ZPAQ) 125 m 253 MiB 95 m* 7za -m0=PPMd produced the smallest file being faster than bzip2
* bzip2 turned out to be way faster than both lz (684%) and xz (644%) and produced a smaller file
* xz is marginally faster than lz, compressed sizes are about the same with the xz file being a tad smaller
* without any switches 7za produces an archive a bit bigger than xz and lzip in about the same amount of time
* gzip and zst produce about the same compressed size, only zstd is a lot faster (517%) than gzip
The 7z file was produced using the -m0=PPMd switch. For the other files no command line switches were supplied. Here are the file sizes:
23668150 file.sql
3899477 file.sql.7z
4149962 file.sql.bz2
5954982 file.sql.gz
4540628 file.sql.lz
4506720 file.sql.xz
5961291 file.sql.zstWas bzip2 slightly, or considerably slower than zst?
If I can remember correctly zstd = 0.2s, gzip = 0.8s, 7zip (PPMd) = 2.1s, bzip2 = 2.7s, lzip, xz, 7zip (lzma) = 15..16s. This is CPU time from memory, might not be fully accurate.
I'd say zstd and gzip is better suited for general use, while bzip2 and 7zip (PPMd) are better suited for high compression of text files.
An example of close number sequences is just simple graphs. Your CPU temperature is 78 degrees, most likely it'll be 78, 79 or 77 the next tick, so they're almost close, the delta's will be 0's and 1's usually.
The correct term from information theory is that it approximates a "universal" compressor with respect to observable markov or fsmx sources.