Commit Graph
111 Commits
Author SHA1 Message Date
Nigel Tao 13731f989f Add a reader1.unread_u8 method.
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)
2017-11-05 15:59:02 +11:00
Nigel Tao 325c36314a Prepare decode_huffman_fast to rewind in.src. 2017-11-05 14:13:27 +11:00
Nigel Tao b6a079fd3e Tweak the decode_huffman_fast loop condition more. 2017-11-05 13:47:28 +11:00
Nigel Tao f6e072fe77 Add some more "inconsistent n_bits" checks.
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)
2017-11-05 09:23:49 +11:00
Nigel Tao db57d8b707 Bump decode_huffman_fast's src available hurdle.
We will need this later, to prove that the other read_u8 calls in
decode_huffman_fast will not suspend.

It's not obvious why the clang benchmarks don't change but the gcc ones
(including the adler numbers, which are superficially unrelated) look
worse. If the change from 6 to 12 bytes is a genuine performance
regression, then a future commit can tighten the bound back to 6,
although it would probably make the decode_huffman_fast assertions and
proof requirements considerably more complicated.

name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.40GB/s ± 1%  2.41GB/s ± 0%    ~     (p=0.690 n=5+5)
puffs_adler32_100k/clang       2.39GB/s ± 2%  2.40GB/s ± 1%    ~     (p=1.000 n=5+5)
puffs_flate_decode_1k/clang     128MB/s ± 0%   128MB/s ± 0%    ~     (p=1.000 n=5+5)
puffs_flate_decode_10k/clang    167MB/s ± 2%   168MB/s ± 0%    ~     (p=0.548 n=5+5)
puffs_flate_decode_100k/clang   193MB/s ± 2%   194MB/s ± 0%    ~     (p=0.310 n=5+5)
puffs_zlib_decode_10k/clang     157MB/s ± 0%   155MB/s ± 4%    ~     (p=0.421 n=5+5)
puffs_zlib_decode_100k/clang    180MB/s ± 1%   177MB/s ± 3%    ~     (p=0.222 n=5+5)

puffs_adler32_10k/gcc          3.26GB/s ± 0%  3.20GB/s ± 1%  -1.81%  (p=0.008 n=5+5)
puffs_adler32_100k/gcc         3.26GB/s ± 0%  3.21GB/s ± 0%  -1.63%  (p=0.008 n=5+5)
puffs_flate_decode_1k/gcc       129MB/s ± 0%   126MB/s ± 1%  -2.30%  (p=0.008 n=5+5)
puffs_flate_decode_10k/gcc      164MB/s ± 0%   161MB/s ± 0%  -1.86%  (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc     185MB/s ± 0%   180MB/s ± 3%  -2.81%  (p=0.016 n=4+5)
puffs_zlib_decode_10k/gcc       157MB/s ± 0%   151MB/s ± 2%  -3.49%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/gcc      175MB/s ± 0%   170MB/s ± 2%  -2.97%  (p=0.016 n=4+5)
2017-11-05 08:56:55 +11:00
Nigel Tao fe5e9c68b3 Remove a superfluous while loop.
It's not obvious why the adler benchmark numbers also change (for the
better), but it seems superficially repeatable for fresh before/after
measurements. I'll take it for now, but perhaps the adler benchmarks
need to run for longer.

name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.38GB/s ± 2%  2.45GB/s ± 0%  +2.87%  (p=0.008 n=5+5)
puffs_adler32_100k/clang       2.39GB/s ± 1%  2.44GB/s ± 0%  +2.42%  (p=0.008 n=5+5)
puffs_flate_decode_1k/clang     129MB/s ± 2%   133MB/s ± 0%  +3.41%  (p=0.008 n=5+5)
puffs_flate_decode_10k/clang    161MB/s ± 1%   174MB/s ± 0%  +8.46%  (p=0.008 n=5+5)
puffs_flate_decode_100k/clang   187MB/s ± 3%   205MB/s ± 0%  +9.51%  (p=0.008 n=5+5)
puffs_zlib_decode_10k/clang     150MB/s ± 1%   162MB/s ± 0%  +8.09%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang    174MB/s ± 1%   188MB/s ± 0%  +8.13%  (p=0.008 n=5+5)

puffs_adler32_10k/gcc          3.12GB/s ± 3%  3.25GB/s ± 0%  +4.30%  (p=0.016 n=5+4)
puffs_adler32_100k/gcc         3.12GB/s ± 3%  3.25GB/s ± 0%  +4.15%  (p=0.008 n=5+5)
puffs_flate_decode_1k/gcc       128MB/s ± 3%   132MB/s ± 0%  +3.11%  (p=0.008 n=5+5)
puffs_flate_decode_10k/gcc      172MB/s ± 4%   170MB/s ± 0%    ~     (p=0.151 n=5+5)
puffs_flate_decode_100k/gcc     196MB/s ± 2%   207MB/s ± 0%  +5.46%  (p=0.008 n=5+5)
puffs_zlib_decode_10k/gcc       164MB/s ± 1%   161MB/s ± 1%  -1.34%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/gcc      186MB/s ± 0%   194MB/s ± 0%  +4.12%  (p=0.016 n=4+5)
2017-11-05 06:57:10 +11:00
Nigel Tao f968950345 Read bits up front in decode_huffman_fast.
name                           old speed      new speed       delta

puffs_adler32_10k/clang        2.36GB/s ± 4%   2.38GB/s ± 2%     ~     (p=1.000 n=5+5)
puffs_adler32_100k/clang       2.39GB/s ± 4%   2.39GB/s ± 1%     ~     (p=0.841 n=5+5)
puffs_flate_decode_1k/clang     121MB/s ± 1%    129MB/s ± 2%   +5.95%  (p=0.008 n=5+5)
puffs_flate_decode_10k/clang    138MB/s ± 3%    161MB/s ± 1%  +16.52%  (p=0.008 n=5+5)
puffs_flate_decode_100k/clang   163MB/s ± 4%    187MB/s ± 3%  +14.50%  (p=0.008 n=5+5)
puffs_zlib_decode_10k/clang     132MB/s ± 2%    150MB/s ± 1%  +13.92%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang    152MB/s ± 6%    174MB/s ± 1%  +14.60%  (p=0.008 n=5+5)

puffs_adler32_10k/gcc          3.25GB/s ± 0%   3.12GB/s ± 3%   -4.06%  (p=0.008 n=5+5)
puffs_adler32_100k/gcc         3.25GB/s ± 0%   3.12GB/s ± 3%   -3.99%  (p=0.008 n=5+5)
puffs_flate_decode_1k/gcc      95.1MB/s ± 0%  127.7MB/s ± 3%  +34.25%  (p=0.008 n=5+5)
puffs_flate_decode_10k/gcc      110MB/s ± 0%    172MB/s ± 4%  +55.66%  (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc     121MB/s ± 0%    196MB/s ± 2%  +61.45%  (p=0.008 n=5+5)
puffs_zlib_decode_10k/gcc       112MB/s ± 0%    164MB/s ± 1%  +46.14%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/gcc      123MB/s ± 0%    186MB/s ± 0%  +51.22%  (p=0.016 n=5+4)
2017-11-04 17:37:54 +11:00
Nigel Tao 36a93fa6b7 Add a TODO about impure functions. 2017-11-04 16:04:28 +11:00
Nigel Tao 1c7a6792de Tweak the decode_huffman_fast loop condition. 2017-11-04 15:19:40 +11:00
Nigel Tao 8fafcbcb31 Tweak the flate end_of_block check. 2017-11-04 14:54:56 +11:00
Nigel Tao aa1f0078db Add decode_huffman_fast.
It's not fast yet, and the immediate impact is indeed a significant
performance loss, but follow-up commits should make it faster.

name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.41GB/s ± 0%  2.40GB/s ± 1%     ~     (p=0.222 n=5+5)
puffs_adler32_100k/clang       2.41GB/s ± 1%  2.39GB/s ± 1%   -0.97%  (p=0.016 n=5+5)
puffs_flate_decode_1k/clang     116MB/s ± 5%   115MB/s ± 0%     ~     (p=0.310 n=5+5)
puffs_flate_decode_10k/clang    145MB/s ± 0%   139MB/s ± 0%   -4.18%  (p=0.016 n=4+5)
puffs_flate_decode_100k/clang   164MB/s ± 5%   158MB/s ± 1%     ~     (p=0.151 n=5+5)
puffs_zlib_decode_10k/clang     135MB/s ± 2%   131MB/s ± 0%   -2.84%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang    154MB/s ± 1%   148MB/s ± 2%   -4.09%  (p=0.016 n=4+5)

puffs_adler32_10k/gcc          3.13GB/s ± 4%  3.19GB/s ± 0%   +1.94%  (p=0.032 n=5+5)
puffs_adler32_100k/gcc         3.14GB/s ± 3%  3.20GB/s ± 3%     ~     (p=0.056 n=5+5)
puffs_flate_decode_1k/gcc       122MB/s ± 1%    94MB/s ± 1%  -22.84%  (p=0.008 n=5+5)
puffs_flate_decode_10k/gcc      143MB/s ± 0%   110MB/s ± 0%  -23.24%  (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc     158MB/s ± 0%   118MB/s ± 0%  -24.98%  (p=0.008 n=5+5)
puffs_zlib_decode_10k/gcc       136MB/s ± 0%   119MB/s ± 1%  -12.63%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/gcc      150MB/s ± 1%   124MB/s ± 2%  -17.17%  (p=0.008 n=5+5)
2017-11-04 14:45:11 +11:00
Nigel Tao c550ad9bda Add redundant but clearer continue/break labels. 2017-11-04 14:14:07 +11:00
Nigel Tao ded044da41 Add a flate end_of_block field. 2017-11-04 14:12:38 +11:00
Nigel Tao 4810db3994 Rename decode_huffman to decode_huffman_slow. 2017-11-04 13:38:24 +11:00
Nigel Tao c3420dd138 Refactor std/flate/*.puffs code. 2017-11-04 13:31:39 +11:00
Nigel Tao c0c023e1cf Remove the writer1.length method. 2017-10-26 13:15:24 +11:00
Nigel Tao 5052b16f2d Rename writer1.slice to writer1.since_mark. 2017-10-26 13:03:19 +11:00
Nigel Tao 0d32b6cb47 Add a mark call to zlib_decoder.decode. 2017-10-26 12:34:01 +11:00
Nigel Tao 474a0d2ed7 Make mark a method, not a keyword. 2017-10-26 12:31:27 +11:00
Nigel Tao 36f5ae9bf4 Move the "mark in.dst" into the flate decode loop. 2017-10-26 11:20:42 +11:00
Nigel Tao 21bbbd422f Generate code for "mark in.dst".
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.
2017-10-22 14:44:53 +11:00
Nigel Tao ac793d33bc Generate placeholder code for "mark in.dst". 2017-10-22 13:57:37 +11:00
Nigel Tao 76f7621221 Re-order some decode_huffman checks.
name                           old speed     new speed     delta
puffs_flate_decode_1k/clang    112MB/s ± 1%  123MB/s ± 0%  +10.03%  (p=0.008 n=5+5)
puffs_flate_decode_10k/clang   135MB/s ± 0%  146MB/s ± 0%   +7.81%  (p=0.008 n=5+5)
puffs_flate_decode_100k/clang  154MB/s ± 0%  166MB/s ± 0%   +7.61%  (p=0.016 n=5+4)
puffs_zlib_decode_10k/clang    128MB/s ± 0%  138MB/s ± 0%   +7.79%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang   145MB/s ± 0%  156MB/s ± 0%   +7.33%  (p=0.016 n=5+4)
puffs_flate_decode_1k/gcc      119MB/s ± 0%  128MB/s ± 0%   +7.49%  (p=0.029 n=4+4)
puffs_flate_decode_10k/gcc     138MB/s ± 1%  146MB/s ± 0%   +6.18%  (p=0.016 n=5+4)
puffs_flate_decode_100k/gcc    153MB/s ± 0%  164MB/s ± 0%   +6.92%  (p=0.029 n=4+4)
puffs_zlib_decode_10k/gcc      132MB/s ± 0%  140MB/s ± 0%   +6.13%  (p=0.016 n=5+4)
puffs_zlib_decode_100k/gcc     147MB/s ± 0%  156MB/s ± 0%   +6.48%  (p=0.016 n=5+4)
2017-10-21 17:19:43 +11:00
Nigel Tao 2ec0cc1db9 Add TODO to think about a std/zlib directory. 2017-10-21 16:27:18 +11:00
Nigel Tao 8ee56a7911 Tweak puffsfmt'ing "iterate.8 (etc)". 2017-10-21 14:33:29 +11:00
Nigel Tao 1f9e391e7d Add a TODO to add a checksum opt out API. 2017-10-21 13:20:14 +11:00
Nigel Tao 2639f8f46a Rename std/flate's decoder to flate_decoder. 2017-10-21 13:05:19 +11:00
Nigel Tao 1c75edb32e Calculate the zlib checksum. 2017-10-21 12:38:23 +11:00
Nigel Tao 62935c41d7 Prepare for calculating the zlib checksum. 2017-10-21 11:55:58 +11:00
Nigel Tao 245e3ec7b9 Unroll iterate loops.
name                      old speed      new speed      delta
puffs_adler32_10k/clang   2.12GB/s ± 1%  2.42GB/s ± 1%  +14.24%  (p=0.008 n=5+5)
puffs_adler32_100k/clang  2.12GB/s ± 3%  2.43GB/s ± 0%  +14.29%  (p=0.008 n=5+5)
mimic_adler32_10k/clang   2.93GB/s ± 2%  2.96GB/s ± 0%     ~     (p=0.310 n=5+5)
mimic_adler32_100k/clang  2.89GB/s ± 2%  2.91GB/s ± 0%     ~     (p=1.000 n=5+5)
puffs_adler32_10k/gcc     2.17GB/s ± 1%  3.23GB/s ± 0%  +48.59%  (p=0.008 n=5+5)
puffs_adler32_100k/gcc    2.18GB/s ± 1%  3.23GB/s ± 0%  +48.34%  (p=0.008 n=5+5)
mimic_adler32_10k/gcc     2.97GB/s ± 0%  2.96GB/s ± 1%     ~     (p=1.000 n=5+5)
mimic_adler32_100k/gcc    2.91GB/s ± 1%  2.91GB/s ± 1%     ~     (p=0.548 n=5+5)
2017-10-20 17:28:21 +11:00
Nigel Tao 2cd6ebed8e Add a "deref" unary operator. 2017-10-20 15:44:30 +11:00
Nigel Tao 51bd52239b Add an "iterate" keyword. 2017-10-20 15:33:31 +11:00
Nigel Tao 74f3b76b09 Rename the adler struct to adler32. 2017-10-19 20:49:20 +11:00
Nigel Tao f9cea5c17c Fix the adler.update implementation. 2017-10-19 20:45:43 +11:00
Nigel Tao d770bf7534 Add some adler.update implementation. 2017-10-19 19:32:10 +11:00
Nigel Tao 50369c782c Add a skeleton of an adler.update method. 2017-10-19 18:58:17 +11:00
Nigel Tao 5b0d6f6f3e Add a skeleton of an Adler checksummer. 2017-10-19 18:09:14 +11:00
Nigel Tao 6492c52156 Add a ~+ operator. 2017-10-19 16:50:05 +11:00
Nigel Tao e7d01e7b2a Fix flate decoding across multiple I/O calls. 2017-10-14 16:27:53 +11:00
Nigel Tao c1789e0065 Rename some variables for clarity. 2017-10-14 11:24:40 +11:00
Nigel Tao b402429eee Remove some redundant inequalities. 2017-10-13 14:55:15 +11:00
Nigel Tao c99fdaf63d Actually copy from the flate decoder's history. 2017-10-13 14:50:34 +11:00
Nigel Tao 0384c5e4a8 Rename the copy_from_xxx methods for consistency. 2017-10-13 10:59:47 +11:00
Nigel Tao 66f712039b Prepare for introducing copy_from_slice. 2017-10-13 10:30:22 +11:00
Nigel Tao 36ba4b866c Calculate the length-distance for a history copy. 2017-10-12 16:06:28 +11:00
Nigel Tao d4372cb5b8 Change license to Apache 2.
Also remove explicit PATENTS file. The new LICENSE file already
discusses patents.

Note that the Puffs project has not yet been publicly released.
2017-10-12 11:17:41 +11:00
Nigel Tao c3ae0534df Add a writer1.available method. 2017-10-07 16:15:17 +11:00
Nigel Tao d275b379a3 Remove the idea of limited reads and writes. 2017-10-07 15:32:00 +11:00
Nigel Tao 585ea2024d Drop the "?" from "copy_from32?".
Also add a PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND macro.

Also add a loop to decoder.decode, as the code generator was previously
(incorrectly) not generating a coro_susp_point at the end of the
function.
2017-10-07 14:34:31 +11:00
Nigel Tao 0e09aa8c10 Call copy_from32 in a trival 1-iteration loop.
Follow-up commits will re-try copy_from32's across I/O boundaries.
2017-10-07 11:50:50 +11:00