Commit Graph
231 Commits
Author SHA1 Message Date
Nigel Tao 65dcf6a5b9 Add a yield keyword 2017-12-01 15:24:48 +11:00
Nigel Tao 7601fb45ce Rename String(*token.Map) to Str(*token.Map) 2017-12-01 11:22:08 +11:00
Nigel Tao 024dc7f97a Rename PUFFS to WUFFS, part 11 of N 2017-11-30 18:18:40 +11:00
Nigel Tao 79a94558be Rename PUFFS to WUFFS, part 5 of N 2017-11-30 16:37:20 +11:00
Nigel Tao 0cea46531b Rename PUFFS to WUFFS, part 2 of N 2017-11-30 16:23:16 +11:00
Nigel Tao 1cee9c6ea2 Add note to consider a read_u8_fast method. 2017-11-10 09:56:27 +11:00
Nigel Tao 693af478d6 Rename some bcheckOptimizeXxx methods. 2017-11-09 15:15:30 +11:00
Nigel Tao d2a01dd938 Refactor lang/check/bounds.go. 2017-11-09 15:11:45 +11:00
Nigel Tao 9b4cc179c4 Use puffs_base__writer1__copy_from_history32__bco.
name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.45GB/s ± 0%  2.45GB/s ± 0%    ~     (p=0.063 n=5+5)
puffs_adler32_100k/clang       2.45GB/s ± 0%  2.45GB/s ± 0%    ~     (p=0.905 n=5+4)
puffs_flate_decode_1k/clang     144MB/s ± 1%   146MB/s ± 0%  +1.41%  (p=0.016 n=5+5)
puffs_flate_decode_10k/clang    186MB/s ± 0%   204MB/s ± 0%  +9.39%  (p=0.008 n=5+5)
puffs_flate_decode_100k/clang   228MB/s ± 0%   240MB/s ± 0%  +5.24%  (p=0.008 n=5+5)
puffs_zlib_decode_10k/clang     173MB/s ± 0%   188MB/s ± 0%  +8.69%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang    209MB/s ± 0%   219MB/s ± 0%  +4.81%  (p=0.008 n=5+5)

puffs_adler32_10k/gcc          3.26GB/s ± 0%  3.26GB/s ± 0%    ~     (p=0.286 n=5+4)
puffs_adler32_100k/gcc         3.26GB/s ± 0%  3.26GB/s ± 0%    ~     (p=0.190 n=5+4)
puffs_flate_decode_1k/gcc       148MB/s ± 0%   148MB/s ± 0%  +0.27%  (p=0.016 n=5+4)
puffs_flate_decode_10k/gcc      245MB/s ± 0%   254MB/s ± 0%  +3.73%  (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc     284MB/s ± 0%   298MB/s ± 0%  +4.90%  (p=0.008 n=5+5)
puffs_zlib_decode_10k/gcc       228MB/s ± 0%   236MB/s ± 0%  +3.33%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/gcc      261MB/s ± 0%   273MB/s ± 0%  +4.46%  (p=0.016 n=5+4)
2017-11-09 15:08:28 +11:00
Nigel Tao 67fb7bf1dc Prepare to optimize w.since_mark.
It's not obvious why the benchmark numbers don't improve, so the
intuitively-better codegen is disabled for now. I'm also having trouble
exactly reproducing the numbers from yesterdays' commits. While I'm
investigating, land this commit and move on.
2017-11-09 12:03:38 +11:00
Nigel Tao 3bdd515e47 Allow "assert foo", not just "assert foo < bar". 2017-11-09 10:53:37 +11:00
Nigel Tao e2ce9f1b1d Add a writer1.is_marked method. 2017-11-09 10:38:24 +11:00
Nigel Tao 0bc6f792fb Remove some suspensions from decode_huffman_fast.
name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.41GB/s ± 1%  2.39GB/s ± 2%  -0.88%  (p=0.022 n=9+10)
puffs_adler32_100k/clang       2.41GB/s ± 1%  2.39GB/s ± 2%    ~     (p=0.095 n=10+9)
puffs_flate_decode_1k/clang     136MB/s ± 2%   134MB/s ± 1%  -0.86%  (p=0.036 n=9+8)
puffs_flate_decode_10k/clang    172MB/s ± 0%   175MB/s ± 0%  +1.96%  (p=0.000 n=8+9)
puffs_flate_decode_100k/clang   206MB/s ± 0%   209MB/s ± 1%  +1.38%  (p=0.000 n=8+9)
puffs_zlib_decode_10k/clang     160MB/s ± 1%   163MB/s ± 2%  +1.73%  (p=0.001 n=9+9)
puffs_zlib_decode_100k/clang    189MB/s ± 1%   188MB/s ± 6%    ~     (p=0.143 n=10+10)

puffs_adler32_10k/gcc          3.27GB/s ± 0%  3.20GB/s ± 2%  -2.03%  (p=0.000 n=8+10)
puffs_adler32_100k/gcc         3.27GB/s ± 0%  3.21GB/s ± 1%  -1.89%  (p=0.000 n=8+10)
puffs_flate_decode_1k/gcc       141MB/s ± 1%   139MB/s ± 1%  -1.66%  (p=0.000 n=9+10)
puffs_flate_decode_10k/gcc      200MB/s ± 0%   209MB/s ± 1%  +4.73%  (p=0.000 n=10+10)
puffs_flate_decode_100k/gcc     242MB/s ± 0%   237MB/s ± 0%  -2.19%  (p=0.000 n=9+10)
puffs_zlib_decode_10k/gcc       188MB/s ± 0%   195MB/s ± 1%  +3.71%  (p=0.000 n=10+10)
puffs_zlib_decode_100k/gcc      225MB/s ± 0%   221MB/s ± 0%  -1.84%  (p=0.000 n=8+9)
2017-11-06 16:59:27 +11:00
Nigel Tao 058938006a Remove some suspensions from decode_huffman_fast.
name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.45GB/s ± 0%  2.41GB/s ± 1%  -1.82%  (p=0.000 n=9+9)
puffs_adler32_100k/clang       2.45GB/s ± 0%  2.41GB/s ± 1%  -1.74%  (p=0.000 n=9+10)
puffs_flate_decode_1k/clang     133MB/s ± 0%   136MB/s ± 2%  +1.93%  (p=0.003 n=9+9)
puffs_flate_decode_10k/clang    181MB/s ± 0%   172MB/s ± 0%  -5.18%  (p=0.000 n=9+8)
puffs_flate_decode_100k/clang   204MB/s ± 0%   206MB/s ± 0%  +0.63%  (p=0.000 n=10+8)
puffs_zlib_decode_10k/clang     168MB/s ± 0%   160MB/s ± 1%  -4.82%  (p=0.000 n=10+9)
puffs_zlib_decode_100k/clang    189MB/s ± 0%   189MB/s ± 1%    ~     (p=0.143 n=10+10)

puffs_adler32_10k/gcc          3.26GB/s ± 0%  3.27GB/s ± 0%  +0.12%  (p=0.000 n=10+8)
puffs_adler32_100k/gcc         3.27GB/s ± 0%  3.27GB/s ± 0%  +0.18%  (p=0.000 n=10+8)
puffs_flate_decode_1k/gcc       130MB/s ± 0%   141MB/s ± 1%  +8.71%  (p=0.000 n=10+9)
puffs_flate_decode_10k/gcc      203MB/s ± 0%   200MB/s ± 0%  -1.72%  (p=0.000 n=9+10)
puffs_flate_decode_100k/gcc     241MB/s ± 0%   242MB/s ± 0%  +0.54%  (p=0.000 n=8+9)
puffs_zlib_decode_10k/gcc       188MB/s ± 0%   188MB/s ± 0%  +0.26%  (p=0.000 n=9+10)
puffs_zlib_decode_100k/gcc      223MB/s ± 0%   225MB/s ± 0%  +0.93%  (p=0.000 n=9+8)
2017-11-06 15:25:19 +11:00
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 55e0bc513b Don't suspend for read_u8 if data is available.
It's not obvious why the benchmarks get worse when the code looks
better, but the long term goal is for all of decode_huffman_fast to not
suspend, and this is one step along that path.

name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.40GB/s ± 1%  2.40GB/s ± 1%     ~     (p=0.841 n=5+5)
puffs_adler32_100k/clang       2.40GB/s ± 1%  2.39GB/s ± 2%     ~     (p=0.421 n=5+5)
puffs_flate_decode_1k/clang     131MB/s ± 1%   128MB/s ± 0%   -2.51%  (p=0.008 n=5+5)
puffs_flate_decode_10k/clang    171MB/s ± 1%   167MB/s ± 2%   -2.86%  (p=0.008 n=5+5)
puffs_flate_decode_100k/clang   202MB/s ± 0%   193MB/s ± 2%   -4.64%  (p=0.016 n=4+5)
puffs_zlib_decode_10k/clang     159MB/s ± 1%   157MB/s ± 0%   -1.65%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang    185MB/s ± 1%   180MB/s ± 1%   -3.11%  (p=0.008 n=5+5)

puffs_adler32_10k/gcc          3.26GB/s ± 0%  3.26GB/s ± 0%     ~     (p=0.421 n=5+5)
puffs_adler32_100k/gcc         3.27GB/s ± 0%  3.26GB/s ± 0%     ~     (p=0.151 n=5+5)
puffs_flate_decode_1k/gcc       132MB/s ± 0%   129MB/s ± 0%   -2.29%  (p=0.008 n=5+5)
puffs_flate_decode_10k/gcc      170MB/s ± 0%   164MB/s ± 0%   -3.13%  (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc     207MB/s ± 0%   185MB/s ± 0%  -10.45%  (p=0.016 n=5+4)
puffs_zlib_decode_10k/gcc       162MB/s ± 0%   157MB/s ± 0%   -2.95%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/gcc      194MB/s ± 0%   175MB/s ± 0%   -9.78%  (p=0.016 n=5+4)
2017-11-05 08:03:21 +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 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 4810db3994 Rename decode_huffman to decode_huffman_slow. 2017-11-04 13:38:24 +11:00
Nigel Tao 4b572702f9 Remove the return error "foo" special case. 2017-10-27 14:39:48 +11:00
Nigel Tao 7cefcccc98 Make error "foo" an expression. 2017-10-27 13:00:13 +11:00
Nigel Tao 9a8508857f Fix the "limitt" typo. 2017-10-27 11:10:25 +11:00
Nigel Tao cbc8c39375 Delete old limit- and mark-related code. 2017-10-27 10:57:32 +11:00
Nigel Tao 8ff453c752 Re-do how limits work. 2017-10-26 16:59:03 +11:00
Nigel Tao a9ba7e85ac Add reader1.limitt and writer1.limitt methods.
The "limitt" typo will be renamed to "limit" once we remove the keyword
named "limit".
2017-10-26 15:06:59 +11:00
Nigel Tao b886e3a1ea Add reader1.mark and reader1.since_mark methods. 2017-10-26 14:39:38 +11:00
Nigel Tao 5052b16f2d Rename writer1.slice to writer1.since_mark. 2017-10-26 13:03:19 +11:00
Nigel Tao 474a0d2ed7 Make mark a method, not a keyword. 2017-10-26 12:31:27 +11:00
Nigel Tao 83c8faef4d Reorder some switch cases. 2017-10-22 14:01:26 +11:00
Nigel Tao ac793d33bc Generate placeholder code for "mark in.dst". 2017-10-22 13:57:37 +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 b024cb1d8c Add some support for iterate assertions. 2017-10-20 16:17:20 +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 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 4b07d3cde6 Tweak some code for style consistency. 2017-10-19 16:51:00 +11:00
Nigel Tao 6492c52156 Add a ~+ operator. 2017-10-19 16:50:05 +11:00
Nigel Tao c99fdaf63d Actually copy from the flate decoder's history. 2017-10-13 14:50:34 +11:00
Nigel Tao a33f744da5 Drop the "?" from "writer1.copy_from_slice?". 2017-10-13 11:44:53 +11:00
Nigel Tao 0384c5e4a8 Rename the copy_from_xxx methods for consistency. 2017-10-13 10:59:47 +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 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 2efdf5fab6 Add a lang/builtin package. 2017-10-07 11:37:10 +11:00
Nigel Tao 010c4db54f Allow explicit returns of built-in status codes. 2017-10-06 17:34:58 +11:00