mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
std/brotli: speed up the encoder at qualities 10 and 11, byte-exactly
- encode_float.wuffs: package-private fast paths for the f32/f64 add, sub, mul, compare and int conversion calls in the encoder's hot loops. Calling std/softfloat is a cross-package public call (a receiver check, never inlined). Each fast path returns exactly the softfloat result and falls back to it for the uncommon cases. script/manual-test-brotli-float.c cross-checks them against hardware float and double arithmetic. - Zopfli update_nodes: compute a length's cost only when its copy code changes, hoist the distance cache values and the continuation byte, and use a table for small int to f32 conversions. - FindBlocks: memoize (block_switch_bitcost + insert_cost) for capped costs and skip the subtraction for costs at or above a per-byte threshold (S(c) = c - min_cost is monotone, so such costs would be capped anyway). - BrotliPopulationCost: per-call memo of each count's term and depth, and skip the zero terms of the entropy sums. - std/softfloat: a 64-bit f32_add_mags. Output is unchanged (mimic tests on gcc and clang, parity sweeps). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UZ978BikvkegL2JUkqoB1e
This commit is contained in:
16 files changed
+2650
-400
No files matched your search
+11
-6
@@ -880,6 +880,10 @@ round trips through the decoder. Its large-window tests cover qualities 3 to
|
||||
9 with lgwin 18 to 30 (and the H35, H55 and H65 hashers) on small files and
|
||||
on a 46 MiB input with repeats at distances of about 20 and 40 MiB, decoded
|
||||
by both this package's decoder and libbrotlidec.
|
||||
`script/manual-test-brotli-float.c` checks the encoder's package-private
|
||||
float fast paths (`encode_float.wuffs`, which spare the hot loops the
|
||||
cross-package `std/softfloat` calls) against the C compiler's hardware float
|
||||
and double arithmetic, for operands biased towards their edge cases.
|
||||
`script/manual-test-brotli-encoder-parity.c` runs a larger grid over every
|
||||
file in `test/data/brotli`, some larger files in `test/data` (up to about
|
||||
400 KiB) and some synthetic inputs (up to 1 MiB). Its `-q=LO-HI` and
|
||||
@@ -1127,12 +1131,13 @@ metablock) for as long as it needs the results.
|
||||
- `workbuf_len` is a worst case (or, at qualities 10 and 11, a practical
|
||||
bound). A future option could take the input length (like the C code's
|
||||
size hint) to give a tighter bound.
|
||||
- Speed. Compressing the 3 MiB `test/data/harvesters.bmp` (with
|
||||
`example/brcat` on x86-64, lgwin 22), the Wuffs encoder takes about 1.2
|
||||
times libbrotlienc's time at quality 5, 1.7 times at quality 9 and 6 times
|
||||
at quality 11, mostly because of the soft float arithmetic in the Zopfli
|
||||
cost model, the block splitter and histogram clustering. Decoding takes
|
||||
about 1.2 times libbrotlidec's time.
|
||||
- Speed. Compressing the 3 MiB `test/data/harvesters.bmp` in one call (on
|
||||
x86-64, lgwin 22), the Wuffs encoder takes about 1.2 times libbrotlienc's
|
||||
time at quality 5, 1.7 times at quality 9, 4 times at quality 10 and 3.5
|
||||
times at quality 11 (on text, 2 to 3 times at qualities 10 and 11), mostly
|
||||
because of the soft float arithmetic in the Zopfli cost model, the block
|
||||
splitter and histogram clustering. Decoding takes about 1.2 times
|
||||
libbrotlidec's time.
|
||||
- Serialized (shared) dictionaries, which only an experimental
|
||||
(`BROTLI_EXPERIMENTAL`) libbrotlienc build supports.
|
||||
- Changing parameters mid-stream.
|
||||
|
||||
Reference in new issue
Block a user