Commit Graph
419 Commits
Author SHA1 Message Date
Nigel Tao b54b40a418 Use history_available in decode_huffman_fast
name                                             old speed     new speed     delta

wuffs_deflate_decode_1k_full_init/clang5         134MB/s ± 1%  137MB/s ± 0%  +1.74%  (p=0.000 n=10+10)
wuffs_deflate_decode_1k_part_init/clang5         162MB/s ± 1%  165MB/s ± 0%  +1.79%  (p=0.000 n=10+10)
wuffs_deflate_decode_10k_full_init/clang5        220MB/s ± 0%  226MB/s ± 0%  +2.76%  (p=0.000 n=10+9)
wuffs_deflate_decode_10k_part_init/clang5        225MB/s ± 0%  232MB/s ± 1%  +2.77%  (p=0.000 n=9+9)
wuffs_deflate_decode_100k_just_one_read/clang5   270MB/s ± 0%  265MB/s ± 0%  -1.93%  (p=0.000 n=10+10)
wuffs_deflate_decode_100k_many_big_reads/clang5  225MB/s ± 0%  223MB/s ± 0%  -1.04%  (p=0.000 n=10+9)

wuffs_deflate_decode_1k_full_init/gcc7           151MB/s ± 1%  151MB/s ± 0%    ~     (p=0.277 n=9+8)
wuffs_deflate_decode_1k_part_init/gcc7           186MB/s ± 1%  186MB/s ± 0%    ~     (p=0.696 n=10+8)
wuffs_deflate_decode_10k_full_init/gcc7          256MB/s ± 1%  253MB/s ± 1%  -0.98%  (p=0.001 n=10+9)
wuffs_deflate_decode_10k_part_init/gcc7          264MB/s ± 1%  261MB/s ± 0%  -1.11%  (p=0.000 n=10+9)
wuffs_deflate_decode_100k_just_one_read/gcc7     310MB/s ± 1%  312MB/s ± 0%  +0.43%  (p=0.013 n=10+9)
wuffs_deflate_decode_100k_many_big_reads/gcc7    247MB/s ± 0%  251MB/s ± 0%  +1.47%  (p=0.000 n=10+9)
2019-07-06 11:31:17 +10:00
Nigel Tao ef7aa0d980 Rename "!=" to "<>"; "!" now only shows impurity 2019-03-02 14:51:32 +11:00
Nigel Tao 045f180a6c Rename errors from "?msg" to "#msg" 2019-02-23 17:06:24 +11:00
Nigel Tao 8794a586ac Add wuffs_foo__bar__initialize methods 2019-02-09 12:54:02 +11:00
Nigel Tao f877fb2c59 Use the workbuf instead of lzw.decoder.suffixes
This commit will soon be followed by a rollback, but it is committed
anyway so that we can refer to these numbers in the git log.

name                                     old speed      new speed      delta

wuffs_lzw_decode_20k/clang5               255MB/s ± 0%   241MB/s ± 0%   -5.63%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/clang5              418MB/s ± 1%   401MB/s ± 1%   -4.02%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/gcc7                 255MB/s ± 1%   235MB/s ± 0%   -7.88%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/gcc7                444MB/s ± 1%   382MB/s ± 0%  -13.90%  (p=0.008 n=5+5)

wuffs_gif_decode_1k_bw/clang5             239MB/s ± 2%   235MB/s ± 1%   -1.89%  (p=0.016 n=5+5)
wuffs_gif_decode_1k_color/clang5          135MB/s ± 0%   132MB/s ± 0%   -1.86%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/clang5          692MB/s ± 1%   678MB/s ± 0%   -2.08%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_indexed/clang5       186MB/s ± 0%   181MB/s ± 0%   -2.58%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/clang5               237MB/s ± 1%   226MB/s ± 0%   -4.46%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/clang5   536MB/s ± 0%   506MB/s ± 0%   -5.53%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/clang5    219MB/s ± 0%   203MB/s ± 1%   -7.11%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k/clang5             222MB/s ± 0%   206MB/s ± 0%   -7.25%  (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/clang5   1.07GB/s ± 0%  1.04GB/s ± 1%   -3.11%  (p=0.008 n=5+5)

wuffs_gif_decode_1k_bw/gcc7               262MB/s ± 0%   255MB/s ± 1%   -2.63%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color/gcc7            142MB/s ± 1%   137MB/s ± 1%   -3.38%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/gcc7            596MB/s ± 1%   593MB/s ± 0%     ~     (p=0.151 n=5+5)
wuffs_gif_decode_10k_indexed/gcc7         185MB/s ± 0%   182MB/s ± 2%   -1.63%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/gcc7                 230MB/s ± 0%   226MB/s ± 0%   -1.78%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/gcc7     490MB/s ± 1%   488MB/s ± 0%     ~     (p=0.095 n=5+5)
wuffs_gif_decode_100k_realistic/gcc7      203MB/s ± 1%   203MB/s ± 0%     ~     (p=0.421 n=5+5)
wuffs_gif_decode_1000k/gcc7               207MB/s ± 0%   207MB/s ± 0%     ~     (p=1.000 n=5+5)
wuffs_gif_decode_anim_screencap/gcc7     1.04GB/s ± 0%  1.03GB/s ± 0%   -0.83%  (p=0.008 n=5+5)
2019-02-03 14:57:34 +11:00
Nigel Tao d1f1340d47 Add a nothing built-in literal 2019-02-03 14:01:19 +11:00
Nigel Tao be2d96bb27 Add public max_incl_workbuf_len constants 2019-02-02 15:51:04 +11:00
Nigel Tao 8bbdcc4ce1 Allow scalar constants in type expressions 2019-02-02 07:53:59 +11:00
Nigel Tao 705a84723a For "x shift y", check that y < (x's bit-size) 2019-01-26 16:51:49 +11:00
Nigel Tao f8a619f47d Update lang/check tests for coroutine_resumed 2019-01-19 12:36:27 +11:00
Nigel Tao 1af543866c Add an implicit coroutine_resumed variable 2019-01-13 11:41:58 +11:00
Nigel Tao ef5fc86f8a Allow "if true" and "if false" 2019-01-06 20:28:33 +11:00
Nigel Tao 1ea32b3745 Remove the !? effect, leaving only ! and !?? 2018-12-29 13:36:38 +11:00
Nigel Tao 3ba450ba55 Make gif's decoder.copy_to_image_buffer ! not !? 2018-12-28 17:32:48 +11:00
Nigel Tao 489fec4437 Remove parse's Options.AllowBuiltIns 2018-12-28 15:50:18 +11:00
Nigel Tao 5cddd4894f Fix lang/check tests for language changes 2018-12-27 21:06:50 +11:00
Nigel Tao c9e6ee6fb3 Fold Expr statements into Assign statements 2018-12-27 17:36:08 +11:00
Nigel Tao 6dc68950c0 Drop the "= RHS" out of "var x T = RHS" 2018-12-27 11:29:47 +11:00
Nigel Tao cbe19f50e0 Restrict var statements to the top of functions 2018-12-27 11:19:22 +11:00
Nigel Tao d552f88738 Make Iterate contain Assign's not Var's 2018-12-27 10:35:27 +11:00
Nigel Tao bac74a830d Place some vars at the top of functions 2018-12-26 18:34:52 +11:00
Nigel Tao 7405307173 Propagate tighter bounds checks after assignments 2018-12-26 16:52:55 +11:00
Nigel Tao 231389ee26 Have bounds checks use interval.IntRange methods 2018-12-26 15:13:56 +11:00
Nigel Tao 20e82ba97b Use interval.IntRange instead of ast.Bounds 2018-12-26 14:02:34 +11:00
Nigel Tao 6fe313a72c Allow an io_limit limit to be a refined base.u64 2018-12-15 10:45:36 +11:00
Nigel Tao 6d2bb77bb7 Add a data:etc argument to io_bind 2018-12-09 09:53:46 +11:00
Nigel Tao badbdfc487 Tweak io_bind syntax 2018-12-09 09:13:29 +11:00
Nigel Tao e992921dce Add an io_limit keyword 2018-12-09 09:03:21 +11:00
Nigel Tao 6c9dca47ee Add a base.pixel_swizzler type 2018-12-08 13:25:53 +11:00
Nigel Tao 5cae1f8c82 Remove the obsolete Effect.RootCause concept 2018-12-01 13:37:33 +11:00
Nigel Tao 9741eada02 Replace "= try foo" with "=? foo" 2018-12-01 13:11:47 +11:00
Nigel Tao c986536230 Rename some read_uxx methods as read_uxx_as_uyy 2018-11-25 12:15:05 +11:00
Nigel Tao 762b320b5e Make the return value mandatory; add ok 2018-11-24 15:09:28 +11:00
Nigel Tao 24ace1c144 Type and bounds check the "x" in "return x" 2018-11-24 14:46:52 +11:00
Nigel Tao c84732f3d3 Quote built-in statuses 2018-11-24 13:42:18 +11:00
Nigel Tao 9e5aec5d25 Change "$foo" to base."$foo" 2018-11-24 13:36:09 +11:00
Nigel Tao 875362ea07 Change status "?foo" to just "?foo" 2018-11-24 12:36:42 +11:00
Nigel Tao 5f9d007b1c Make a struct's implicit reset method impure 2018-11-24 11:05:39 +11:00
Nigel Tao 3338d6d1bc Write LZW output 8 bytes at a time, not 1
The benchmarks are mixed, but I think it's still a net win.

----
name                                    old speed     new speed     delta

wuffs_gif_decode_1k_bw/clang            258MB/s ± 0%  253MB/s ± 1%    -2.04%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color/clang         159MB/s ± 0%  116MB/s ± 0%   -26.76%  (p=0.008 n=5+5)
wuffs_gif_decode_10k/clang              167MB/s ± 0%  138MB/s ± 0%   -17.42%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/clang  205MB/s ± 0%  439MB/s ± 0%  +114.53%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/clang   151MB/s ± 0%  164MB/s ± 0%    +8.41%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k/clang            155MB/s ± 0%  165MB/s ± 0%    +6.50%  (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/clang   255MB/s ± 0%  921MB/s ± 0%  +261.50%  (p=0.008 n=5+5)

wuffs_gif_decode_1k_bw/gcc              316MB/s ± 2%  267MB/s ± 1%   -15.78%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color/gcc           184MB/s ± 1%  134MB/s ± 0%   -27.57%  (p=0.008 n=5+5)
wuffs_gif_decode_10k/gcc                196MB/s ± 0%  161MB/s ± 0%   -17.50%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/gcc    287MB/s ± 0%  449MB/s ± 1%   +56.22%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/gcc     182MB/s ± 0%  182MB/s ± 1%      ~     (p=0.690 n=5+5)
wuffs_gif_decode_1000k/gcc              187MB/s ± 1%  185MB/s ± 1%      ~     (p=0.056 n=5+5)
wuffs_gif_decode_anim_screencap/gcc     397MB/s ± 0%  973MB/s ± 0%  +145.42%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/clang              170MB/s ± 0%  191MB/s ± 1%   +12.52%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/clang             242MB/s ± 0%  312MB/s ± 2%   +29.00%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/gcc                220MB/s ± 0%  227MB/s ± 0%    +3.31%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/gcc               317MB/s ± 0%  369MB/s ± 1%   +16.53%  (p=0.008 n=5+5)
----

LZW is the compression method used by GIF images. Roughly speaking, LZW
is a sequence of codes, and each code emits either 1 byte (a literal
code) or multiple bytes (a copy code). The speed gain in this commit
comes from, when emitting an N-byte copy code, this now requires N/8
iterations instead of N iterations, as each iteration now writes 8 bytes
instead of 1. Literal codes, both before and after this commit, requires
a single iteration.

Decoding should therefore get faster or slower depending on whether it's
copy-code-heavy or literal-code-heavy respectively. For what it's worth,
copy-code-heavy GIF images also usually compress better.

Running script/extract-giflzw.go (or examining the cached output at
test/data/analysis/giflzw-emission-lengths.txt) on the anim_screencap
(which got faster) and 1k_color (which got slower) cases (also known as
gifplayer-muybridge.gif and hippopotamus.regular.gif) shows that the
proportion of literal codes agrees with that explanation.

----
gifplayer-muybridge.gif (all frames)
 Percent   Count  Emission_Length_Bucket
   12.78   34658           1 (Literal Code)
   14.05   38106           2
   13.25   35937           3
   10.59   28707           4
    7.85   21286           5
    6.08   16481           6
    4.85   13156           7
    3.60    9764           8
    9.34   25318    9 ..  16
    4.89   13257   17 ..  32
    4.78   12954   33 ..  64
    4.72   12806   65 .. 128
    3.02    8190  127 .. 256
    0.20     550  256+

hippopotamus.regular.gif (all frames)
 Percent   Count  Emission_Length_Bucket
   82.66     672           1 (Literal Code)
   13.04     106           2
    2.83      23           3
    0.86       7           4
    0.37       3           5
    0.25       2           6
    0.00       0           7
    0.00       0           8
    0.00       0    9 ..  16
    0.00       0   17 ..  32
    0.00       0   33 ..  64
    0.00       0   65 .. 128
    0.00       0  127 .. 256
    0.00       0  256+
----

The new algorithm also adds more CPU and RAM overhead, regardless of
whether the input GIF image's LZW data is copy-code-heavy or
literal-code-heavy. For example, the suffix table grows by 8x, from 4KiB
to 32 KiB.

The gifplayer-muybridge.gif image is also larger (472 x 298) and the
hippopotamus.regular.gif image is also smaller (36 x 28). Higher fixed
costs may have larger (negative) relative effects on decoding smaller
images.

To repeat, I think it's still a net win.

An upcoming commit will update the std/lzw/README.md file to provide
more detail on the algorithm.

Thanks to Tushar Khandelwal for the idea.
2018-10-21 14:48:40 +11:00
Nigel Tao ff92d22ea6 Read LZW input bits 4 bytes at a time, not 1
name                             old speed     new speed     delta

wuffs_gif_decode_1k_bw/clang     306MB/s ± 0%  295MB/s ± 0%   -3.62%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color/clang  156MB/s ± 0%  163MB/s ± 0%   +4.64%  (p=0.008 n=5+5)
wuffs_gif_decode_10k/clang       153MB/s ± 0%  179MB/s ± 0%  +17.34%  (p=0.008 n=5+5)
wuffs_gif_decode_100k/clang      147MB/s ± 0%  155MB/s ± 0%   +5.13%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k/clang     151MB/s ± 1%  159MB/s ± 0%   +5.34%  (p=0.008 n=5+5)

wuffs_gif_decode_1k_bw/gcc       319MB/s ± 0%  313MB/s ± 0%   -1.79%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color/gcc    165MB/s ± 0%  173MB/s ± 0%   +4.82%  (p=0.008 n=5+5)
wuffs_gif_decode_10k/gcc         171MB/s ± 1%  184MB/s ± 1%   +7.48%  (p=0.008 n=5+5)
wuffs_gif_decode_100k/gcc        161MB/s ± 1%  173MB/s ± 1%   +7.32%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k/gcc       166MB/s ± 0%  179MB/s ± 1%   +7.53%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/clang       167MB/s ± 0%  185MB/s ± 0%  +10.85%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/clang      239MB/s ± 0%  260MB/s ± 0%   +8.96%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/gcc         192MB/s ± 0%  211MB/s ± 0%   +9.47%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/gcc        295MB/s ± 0%  300MB/s ± 0%   +1.65%  (p=0.008 n=5+5)
2018-10-14 22:14:02 +11:00
Nigel Tao 9573b88a02 Remove unused appendFact code path 2018-10-14 13:11:58 +11:00
Nigel Tao 34049e52d8 Optimize deflate Huffman; tighten an if
name                             old speed     new speed     delta
wuffs_deflate_decode_1k/clang    148MB/s ± 0%  149MB/s ± 0%  +0.61%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k/clang   228MB/s ± 1%  235MB/s ± 0%  +3.45%  (p=0.016 n=5+4)
wuffs_deflate_decode_100k/clang  253MB/s ± 0%  262MB/s ± 0%  +3.42%  (p=0.008 n=5+5)
wuffs_deflate_decode_1k/gcc      158MB/s ± 1%  157MB/s ± 0%  -0.44%  (p=0.032 n=5+5)
wuffs_deflate_decode_10k/gcc     265MB/s ± 0%  274MB/s ± 0%  +3.31%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k/gcc    300MB/s ± 0%  317MB/s ± 0%  +5.45%  (p=0.008 n=5+5)
2018-10-07 18:13:25 +11:00
Nigel Tao 555a72d7a9 Add a decode_frame_options type 2018-09-02 15:08:00 +10:00
Nigel Tao c1af1e2c82 Rename $(etc) to [etc] 2018-08-18 10:11:43 +10:00
Nigel Tao 6236e7205f Remove packageid 2018-08-12 21:44:49 +10:00
Nigel Tao eec0fce647 Change error "?foo" to status "?foo" 2018-08-12 21:31:56 +10:00
Nigel Tao 203b45e869 Remove status values 2018-08-12 19:36:29 +10:00
Nigel Tao 98b2aa9837 Move some Go packages from lang/foo to lib/foo 2018-08-04 09:17:08 +10:00
Nigel Tao 7fc98dee00 Tweak how we parse "try foo?(etc)" 2018-08-04 08:51:15 +10:00
Nigel Tao df19bcdb03 Require if and while conditions to be effect-free 2018-07-29 14:20:15 +10:00