Benchmarks
The numbers, and how to repeat them
Every figure here names the date it was measured and the yardstick it was measured with. The line-breaking table below was produced on 2026-08-17 by a command anyone with the engine can run.
The metric
Line-breaking quality is judged with a measure the optimiser does not optimise. For each non-final line of a paragraph, the residual space is the fraction of the measure left empty:
RMS-raggedness = √( mean( ri2 ) ) — overall tightness
max-raggedness = max( ri ) — the single ugliest line The final line of a paragraph is excluded, since it is supposed to be short. Lower is better in both columns.
Line quality across paragraph lengths
Three strategies on the same corpus: greedy first-fit, the shipping dynamic program, and the same dynamic program with its long-paragraph cap removed. Measure 517 units, 16.0 pt, about eleven words per line.
| Paragraph | Words | Greedy RMS / max |
Shipping DP RMS / max |
Uncapped DP RMS / max |
Greedy µs | DP µs |
|---|---|---|---|---|---|---|
| short | 20 | 0.073 / 0.081 | 0.109 / 0.117 | 0.129 / 0.138 | 13.0 | 45.2 |
| medium | 60 | 0.074 / 0.129 | 0.083 / 0.118 | 0.100 / 0.131 | 35.7 | 139.0 |
| just under cap | 90 | 0.077 / 0.149 | 0.081 / 0.132 | 0.101 / 0.152 | 54.3 | 235.6 |
| long | 150 | 0.082 / 0.177 | 0.081 / 0.139 | 0.093 / 0.149 | 91.5 | 397.7 |
| very long | 320 | 0.082 / 0.209 | 0.074 / 0.145 | 0.092 / 0.151 | 193.6 | 836.2 |
Word preservation and overflow were checked on every run and passed in all cases. On the two long categories, removing the cap changes the ugliest line as follows:
- 150 words — worst line 17.7% → 14.9% residual space, a 15.7% reduction.
- 320 words — worst line 20.9% → 15.1% residual space, a 28.0% reduction.
The trade-off, stated plainly
On those same long paragraphs the RMS raggedness gets about 13% worse, not better. That is the algorithm behaving as designed. Optimal breaking spreads the slack, so more lines are slightly loose and no line is terrible. It buys the maximum at the expense of the average, because the maximum is what a reader's eye actually catches.
On short paragraphs the metric favours greedy outright — at 20 words greedy scores 0.081 against 0.138. With few non-final lines there is little to redistribute, and packing tight wins on this particular yardstick. The gain from optimal breaking is a long-paragraph effect, and the table shows where it starts.
The cost, and who pays it
The dynamic program is roughly four times slower than greedy: 836 µs against 194 µs for a 320-word paragraph. Both are well under a millisecond, and the comparison matters less than where the work happens. The optimisation runs once, when the book is typeset. The result is stored in the container. A reader opening a .fab spends nothing at all on line breaking, because the lines are already decided.
An EPUB reader pays the greedy cost on every device, on every reflow, forever — and still gets the greedy result.
Reproducing the table
From the engine root:
python tools/wrap_quality_bench.py
The harness builds paragraphs at each length, runs all three strategies through the same measurement function, and verifies that no words are lost and no line overflows. Absolute values depend on the machine, the font metrics and the corpus; the ordering between strategies is the finding.
Catalogue measurement
Across the Fabylon catalogue rather than a synthetic corpus, optimal breaking moves the worst non-final line from 16.9% to 10.0% residual space. That figure is the threshold the build gate wrap-quality defends: the build fails on purpose if any text is ever routed back to greedy.
Microtypography gates
| Instrument | Measured effect | Gate |
|---|---|---|
| Optical margins (protrusion) | Optical edge RMS error 2.41 pt → 0.00 pt | microtype-quality |
| Protrusion auto-calibration | Factors derived from each font's own ink geometry | microtype-autocalib |
| Font expansion (hz) | Inter-word stretch variance −19%, e ≤ 1.03 | microtype-expansion |
| Reading measure ~66 chars | Lines inside the 45–80 char comfort band 88–95% of the time, against 9–10% uncapped | — |
Both microtypographic instruments are content-preserving by construction. Protrusion is a horizontal shift; expansion scales existing glyphs. Neither adds or removes a character, so text fidelity is untouched. The mathematics page explains what each one does.
Container size
Across five real books, total EPUB size 521 KB against 292 KB as .fab — 44% fewer bytes, roughly 1.8× smaller. Per title the ratio varies between 0.40 and 0.64. Heavily illustrated books can be larger, because the images dominate and are already compressed.
A number we retired
An early fixture reported .fab at 6% of the equivalent EPUB — a ratio of 0.061. It is not representative and should not be quoted. The fixture was an artificially repetitive synthetic document, and repetition is exactly what a compressor is best at. The real-book figure of about 0.56 is the one to use.
Decode speed
On a deterministic fixture the container opens in 0.061 ms, renders its first page in 0.064 ms and decodes all 48 pages in 0.423 ms. The first-page path is fast because the opening page is duplicated inside the compressed manifest, so showing page one never requires decompressing the full page block. These are fixture timings on one machine, not a claim about any particular device.