Also re-enable a number of std/flate tests and benchmarks.
It's not an optimization per se, but as a data point, here are some
benchmark numbers between 36a93fa and this commit. 36a93fa is "36a93fa
Add a TODO about impure functions", which is one commit before "f968950
Read bits up front in decode_huffman_fast", and f968950 was the commit
that made decode_huffman_fast read more than one byte at a time.
name old speed new speed delta
puffs_adler32_10k/clang 2.45GB/s ± 0% 2.45GB/s ± 0% ~ (p=0.684 n=10+10)
puffs_adler32_100k/clang 2.45GB/s ± 0% 2.46GB/s ± 0% +0.07% (p=0.019 n=10+10)
puffs_flate_decode_1k/clang 124MB/s ± 0% 132MB/s ± 0% +6.06% (p=0.000 n=10+10)
puffs_flate_decode_10k/clang 145MB/s ± 0% 174MB/s ± 0% +20.19% (p=0.000 n=9+10)
puffs_flate_decode_100k/clang 168MB/s ± 0% 208MB/s ± 0% +23.31% (p=0.000 n=10+10)
puffs_zlib_decode_10k/clang 136MB/s ± 0% 162MB/s ± 0% +18.94% (p=0.000 n=10+9)
puffs_zlib_decode_100k/clang 158MB/s ± 0% 192MB/s ± 0% +21.58% (p=0.000 n=10+9)
puffs_adler32_10k/gcc 3.26GB/s ± 0% 3.26GB/s ± 0% ~ (p=0.631 n=10+10)
puffs_adler32_100k/gcc 3.27GB/s ± 0% 3.27GB/s ± 0% ~ (p=0.237 n=10+8)
puffs_flate_decode_1k/gcc 95.3MB/s ± 0% 105.5MB/s ± 0% +10.67% (p=0.000 n=10+10)
puffs_flate_decode_10k/gcc 110MB/s ± 0% 140MB/s ± 0% +27.32% (p=0.000 n=9+9)
puffs_flate_decode_100k/gcc 121MB/s ± 0% 150MB/s ± 0% +24.02% (p=0.000 n=8+10)
puffs_zlib_decode_10k/gcc 112MB/s ± 0% 120MB/s ± 0% +6.96% (p=0.000 n=10+9)
puffs_zlib_decode_100k/gcc 123MB/s ± 0% 134MB/s ± 0% +8.93% (p=0.000 n=9+8)
This uncovered a bug in the decode_huffman_fast function. A follow up commit
will actually fix the bug.
For what it's worth, some benchmark numbers are below, but they're
possibly bogus, as we might be decoding incorrect (and truncated) output
for some inputs. Everything since "f968950 Read bits up front in
decode_huffman_fast" landed possibly has bogus numbers too.
name old speed new speed delta
puffs_flate_decode_100k/clang 194MB/s ± 0% 204MB/s ± 1% +5.02% (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc 180MB/s ± 3% 202MB/s ± 1% +12.09% (p=0.008 n=5+5)
A future commit could set each benchmark's iteration count (call it N)
dynamically, but for now, the iteration counts are hard-coded. The rough
guiding principle is those N iterations should take more or less one
second, on my modern desktop CPU.
Prior to this commit, the adler benchmarks ran for the same N as the
zlib benchmarks. Each zlib decode involves exactly one adler checksum
computation, so both having the same N makes it very easy to calculate a
rough estimate of what fraction of zlib decoding is spent in adler code.
But in having the same N, the adler benchmarks run for a tiny fraction
of a second (and would run for an even tinier fraction if we further
optimize the adler code, e.g. with SIMD).
This commit raises that N for the adler benchmarks (but not for the zlib
benchmarks), which should hopefully make the adler numbers a little more
reliable. It will make that very easy calculation slightly less easy,
but it'd still be trivial.
The benchmark numbers do change. I'm not entirely sure why, but keep in
mind that this commit only changes the benchmark harness code, not the
actual std/flate code running in that harness.
name old speed new speed delta
puffs_adler32_10k/clang 2.45GB/s ± 0% 2.40GB/s ± 1% -2.00% (p=0.008 n=5+5)
puffs_adler32_100k/clang 2.44GB/s ± 0% 2.40GB/s ± 1% -1.67% (p=0.008 n=5+5)
puffs_flate_decode_1k/clang 133MB/s ± 0% 131MB/s ± 1% -1.37% (p=0.008 n=5+5)
puffs_flate_decode_10k/clang 174MB/s ± 0% 171MB/s ± 1% -1.66% (p=0.008 n=5+5)
puffs_flate_decode_100k/clang 205MB/s ± 0% 202MB/s ± 0% -1.28% (p=0.016 n=5+4)
puffs_zlib_decode_10k/clang 162MB/s ± 0% 159MB/s ± 1% -1.94% (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang 188MB/s ± 0% 185MB/s ± 1% -1.60% (p=0.008 n=5+5)
puffs_adler32_10k/gcc 3.25GB/s ± 0% 3.26GB/s ± 0% +0.25% (p=0.016 n=4+5)
puffs_adler32_100k/gcc 3.25GB/s ± 0% 3.27GB/s ± 0% +0.39% (p=0.008 n=5+5)
puffs_flate_decode_1k/gcc 132MB/s ± 0% 132MB/s ± 0% ~ (p=0.151 n=5+5)
puffs_flate_decode_10k/gcc 170MB/s ± 0% 170MB/s ± 0% ~ (p=0.738 n=5+5)
puffs_flate_decode_100k/gcc 207MB/s ± 0% 207MB/s ± 0% ~ (p=0.841 n=5+5)
puffs_zlib_decode_10k/gcc 161MB/s ± 1% 162MB/s ± 0% ~ (p=0.841 n=5+5)
puffs_zlib_decode_100k/gcc 194MB/s ± 0% 194MB/s ± 0% ~ (p=0.841 n=5+5)
The generated code is ugly and the language design is not finalized, but
the flate_backref_crosses_blocks test (testing a correctness bug) now
passes. We can fix the ugliness in subsequent commits.