Abstract
DEFLATE level 13 is a deliberately impractical libdeflate compression level: the output remains standard DEFLATE, while the encoder spends far more time searching parse, Huffman, and block split choices. On Silesia it saves 86'990 bytes, 0.134%, over level 12 and runs 56.4x slower; this cost is acceptable only when data is compressed once and distributed many times.
Why DEFLATE
DEFLATE remains worth optimising because its decoders are already everywhere: HTTP content encoding, ZIP archives, PNG internals, software distribution, backup tools, and embedded formats still use the same LZ77 plus Huffman design. The decoder contract is fixed, but the encoder still chooses matches, block boundaries, and Huffman tables; better choices improve size without changing compatibility.
The baseline is libdeflate level 12, one of the strongest practical DEFLATE encoders. The level 13 implementation was contributed upstream as pull request.
Level 13 Mechanics
Level 13 keeps libdeflate’s near optimal parser, but makes its choices more expensive. It searches the full 32 KiB DEFLATE window, permits 15 optimisation passes, and applies static Huffman optimisation to blocks up to 50'000 input bytes. No format extension is involved.
For text like data, level 13 delays block size commitment. It samples up
to 64 KiB from the current block start; if the sample contains no NULL
byte and at most 97 distinct byte values, the soft block size rises from
300'000 to 1'000'000 bytes. The assumption is simple: a stable byte
distribution lets one Huffman table cover more data.
The parser broadens the minimum cost search. It can choose the cheapest offset for each match length, estimate initial Huffman costs from literal and match length statistics, estimate offset slot frequencies from cached matches, and compare measured dynamic Huffman cost against static Huffman and literal only encodings.
Block splitting is also delayed. The compressor stores up to nine split candidates with parser state, then scores the full block and a bounded shortest path over candidate intervals. A single split can win on cost; a multi split path must beat the full block by at least 512 bits. The selected parse is cached for final flushing.
The slowness is bounded. Search passes, split candidates, and block sizes are capped, so level 13 cannot enter an unbounded optimisation loop like turtledeflate or broader file optimizers such as ECT.
Regression Policy
Development used a zero compression regression policy against the Silesia corpus: many approaches were tried, but only changes that strictly decreased at least one compressed file, without increasing any other compressed file, survived into the final level 13 configuration.
The Silesia corpus is small enough for repeated development, but mixed enough to punish single file tuning: it contains text, binaries, databases, images, and structured data.
Silesia Results
| file | level 12 size / time | level 13 size / time | size diff | time diff |
|---|---|---|---|---|
| dickens | 3'688'552 / 1'289 ms | 3'684'671 / 83'512 ms | -3'881 (-0.105%) | +82'223 (+6378.8%) |
| mozilla | 18'267'490 / 4'959 ms | 18'235'120 / 110'754 ms | -32'370 (-0.177%) | +105'795 (+2133.4%) |
| mr | 3'448'571 / 1'627 ms | 3'443'723 / 16'260 ms | -4'848 (-0.141%) | +14'633 (+899.4%) |
| nci | 2'766'224 / 7'935 ms | 2'758'044 / 673'648 ms | -8'180 (-0.296%) | +665'713 (+8389.6%) |
| ooffice | 2'998'130 / 424 ms | 2'995'604 / 8'676 ms | -2'526 (-0.084%) | +8'252 (+1946.2%) |
| osdb | 3'642'347 / 798 ms | 3'641'341 / 4'942 ms | -1'006 (-0.028%) | +4'144 (+519.3%) |
| reymont | 1'702'796 / 1'005 ms | 1'699'494 / 81'839 ms | -3'302 (-0.194%) | +80'834 (+8043.2%) |
| samba | 5'135'662 / 2'889 ms | 5'122'812 / 141'227 ms | -12'850 (-0.250%) | +138'338 (+4788.4%) |
| sao | 5'255'575 / 333 ms | 5'255'358 / 1'687 ms | -217 (-0.004%) | +1'354 (+406.6%) |
| webster | 11'565'754 / 6'452 ms | 11'555'293 / 475'196 ms | -10'461 (-0.090%) | +468'744 (+7265.1%) |
| x-ray | 5'754'248 / 305 ms | 5'748'141 / 3'276 ms | -6'107 (-0.106%) | +2'971 (+974.1%) |
| xml | 633'760 / 1'104 ms | 632'518 / 69'504 ms | -1'242 (-0.196%) | +68'400 (+6195.7%) |
| total | 64'859'109 / 29'120 ms | 64'772'119 / 1'670'521 ms | -86'990 (-0.134%) | +1'641'401 (+5636.7%) |
Level 13 saves 86'990 bytes across the corpus, a 0.134% reduction, and
adds 1'641'401 ms of runtime. The strongest relative result is nci at
0.296%; sao changes by only 0.004%.