Skip to content

v0.8.0 — the entropy coder was the wall, not the transform

Choose a tag to compare

@tannevaled tannevaled released this 26 Sep 20:50
· 27 commits to main since this release
cff3463

The bottleneck on a scanned page is the entropy coder, not the wavelet

§24 of the conformance baseline named ia-biodiversity as the population where a
typical page ties with poppler — median 1.004×, slower on 128 of 250. Profiling its
worst page put the wavelet nowhere near the top:

DecodeCodeBlock 1.03 s 37.1%
↳ significancePropagationPass 0.47 s 16.9%
↳ cleanupPass 0.36 s 13.0%

And the largest single line inside the significance pass is not the arithmetic
decoder — it is computing the context from eight neighbours (100 ms against the
decoder's 90 ms).

e.state is [][]uint8, so each e.state[y][x] costs two bounds checks and a
pointer load, and countSigNeighbors does eight per coefficient. The rows are now
bound once and indexed; the same reads happen in the same order.

Measured

Three rounds of min-of-4 per binary, all in one interleaved run:

document before after
jahresberichtder710meye.pdf 801.7 ms 773.5 ms −3.5%
bulletin43peab.pdf 663.9 ms 636.4 ms −4.1%
b31820797.pdf (wavelet-heavy) +0.5%, noise

That last row is the point: the change helps where the mechanism applies and
nowhere else.

Unchanged output

All 3 215 corpus documents render byte-identical to v0.7.0.