← .fab

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:

ri = (Wmax − Wi) / Wmax

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.

Measured 2026-08-17. RMS / maximum raggedness, then wrap time in microseconds.
Paragraph Words Greedy
RMS / max
Shipping DP
RMS / max
Uncapped DP
RMS / max
Greedy µs DP µs
short200.073 / 0.0810.109 / 0.1170.129 / 0.13813.045.2
medium600.074 / 0.1290.083 / 0.1180.100 / 0.13135.7139.0
just under cap900.077 / 0.1490.081 / 0.1320.101 / 0.15254.3235.6
long1500.082 / 0.1770.081 / 0.1390.093 / 0.14991.5397.7
very long3200.082 / 0.2090.074 / 0.1450.092 / 0.151193.6836.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

InstrumentMeasured effectGate
Optical margins (protrusion)Optical edge RMS error 2.41 pt → 0.00 ptmicrotype-quality
Protrusion auto-calibrationFactors derived from each font's own ink geometrymicrotype-autocalib
Font expansion (hz)Inter-word stretch variance −19%, e ≤ 1.03microtype-expansion
Reading measure ~66 charsLines 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.

Mathematics What is being optimised Badness, demerits and the window-bounded dynamic program behind these numbers. Specification Where the result is stored Container layout, manifest fields and page records.

Line-quality table measured 2026-08-17 with tools/wrap_quality_bench.py. Catalogue, microtypography and decode figures are the thresholds enforced by the named build gates in the Fabylon engine.