mirror of
https://github.com/google/brotli.git
synced 2026-09-22 14:45:51 +00:00
q9 significantly faster than q6 for specific input #206
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fasterthanlime on GitHub (Jan 9, 2018).
I've been in touch with Jyrki Alakuijala on twitter after I noticed compressing with q9 being faster than q6, and they mentioned q9 being faster "unusual".
The behavior was observed deep into a golang program using (non-official) cgo bindings, so I've been trying to reproduce it with vanilla brotli, and I was finally able to!
Exhibit
This is not a "benchmark done right", but I've been playing with various input files for dozens of runs for the last 48h and I've noticed this pattern quite a bit.
How I built brotli
I followed the instructions in
README.md- this was run on windows-amd64, compiled with cmake:CMake auto-detected and used
Visual Studio 14 2015to compile. Note that when I originally observed the performance difference, brotli's sources were built with gcc 7.2.0 (built by the MSYS2 project) via cgo.The version of brotli I used was
da254cffdb(HEAD of master at the time of this writing)The data
Here's a
none.br.zipfile, which is a 2.3MB zip archive (due to github issues limitations) containing a brotli-q9-compressed version of my sample input.📦 none.br.zip
The uncompressed input (
none) is a 2.2GB file. Its SHA-256 checksum is:352994da7a1b3f10e665e7eb4f477e9ebeaf5088742e4fddfacd7d4901d51df5It compresses particularly well (brotli performs splendidly in particular) because it's a patch file inspired by the original BSDiff paper.
In particular, the file:
It's supposed to compress well because bsdiff is basically:
00000029000000000000290000000000) - this is calleddiff dataextra dataOther differences from the original bsdiff:
diff dataextra datadiff dataandextra datadirectly after the relevant instruction - and limits an instruction's slice size. This lets us to streaming diff & apply with lower memory/disk requirements, with a slight compression penalty, I have a tweet thread about this for the curious.Hypotheses
Although I've played with compression formats a lot, I cannot claim to understand its inner workings, but I've noticed the following:
speed up RLE-ish data compressioncommit (and this input data might be RLE-ish? depending on the meaning of it), but afaict I was seeing the performance difference before that commit.Conclusion
At this point I'm tempted to use q=9 rather than q=6-8 (our diff process is much slower than brotli compression anyway, and we're running it on a machine with many cores, so it's not a bottleneck), but I figured it'd be interesting to brotli developers and I might learn a thing or two in the process :)