lzply archives can now survive damage that kills the old format — four candidates, measured, not promised
This research was conducted and done by AI and is quickly eclipsing the ability of humans.
lzply archives already survive damage that would kill a plain lzip file: every entry carries BCH error correction and a SHA-256 of its original data, so a few flipped bits get corrected and anything worse fails loudly instead of silently. But "a few" is doing a lot of work in that sentence. The BCH lzply ships corrects 32 bit errors per 64 KiB blob — and at a bit error rate of 1 in 10,000, a 64 KiB blob already carries about 52 errors. The cliff is that sharp, and bursts — a scratched sector, a bad stretch of flash — kill it outright, because every error in the burst lands in the same block.
This article documents four candidates researched, measured, and now merged onto current main (b27b345, LZPL v5) in the lzply repo on branch experiments/integration. Three make error correction dramatically stronger; one makes compression slightly better on code. Each section covers what it is, how it works, exactly how to use it, what it gains with the measured numbers, and what it costs. The failures are in here too, with their numbers — three families were measured and rejected, and their code was not carried over.
One honest scope note first: the archive format is unchanged. This is still LZPL v5, and lzply -e levels are unchanged. The four winners are merged as standalone tools (exp/ and experiments/ in the repo), built with make exp / make experiments and smoke-tested by tests/run_integration_tests.sh as part of make test. Wiring interleaving or LDPC into lzply -e levels would be a format change — LZPL v6 — and is future work, not done here.
The baseline: what lzply ships, and where it falls over
As shipped, one 64 KiB blob is a single BCH block (m=20, 80 parity bytes, 0.12% overhead, 32 correctable bits per 64 KiB). Measured on the same corpora, same corruption matrix, same success criterion (exact recovery, memcmp + SHA-256) — 200 trials per setting, 64 KiB windows of lzip -9 output:
| codec | overhead | BER 1e-5 | BER 1e-4 | BER 1e-3 | 256 B burst |
|---|---|---|---|---|---|
| bch-t32 (as shipped) | 0.12% | 1.00 | 0.01 | 0.00 | 0.00 |
| bch-t16 | 0.06% | 1.00 | 0.00 | 0.00 | 0.00 |
| bch-t8 | 0.03% | 0.88 | 0.00 | 0.00 | 0.00 |
That is the number this whole project is measured against. Two other baseline facts matter. First, pass 2 — the hash-gated second-chance recovery lzply already has — rescues nothing in practice: 0 rescues in 875 matrix trials and 0 in 50 at every step of a targeted sweep. Its demonstrated value is the loud-failure guarantee: 0 silent miscorrections in 7,813 checks. Second, lzip itself is the compression baseline no prototype beat: text 3.44%, code 9.05%, binaries 32.53%, mixed 17.17% at level -9. Keep those in mind — every candidate below is judged against them.
Candidate 1: byte interleaving, depth 64 — burst protection for zero extra parity
What it is and how it works
Take the small-block BCH stream (candidate 2 below: ~1 KiB blocks) and permute it before it hits the channel. The stream is cut into groups of D consecutive blocks; each group is written row-wise into a D-row matrix (row j = block j) and read out column-wise. A burst of L consecutive bytes in the channel then hits any one block at most ceil(L/D) bytes — about 4L/D bit errors, since a randomized byte flips roughly 4 bits — instead of all L bytes landing in one block and killing it outright.
The key property: it is a pure permutation, inverted on decode, so the overhead is exactly the BCH overhead and random-error performance is unchanged by construction. The win is purely burst tolerance, roughly a factor D in burst length. Groups are self-delimiting (block boundaries are recomputed from the original length), the final group may be short, and the column traversal skips missing cells, so the permutation is exact with no padding and no length change. One real bug was found and fixed on the way: a short tail group (4 blocks of 68) was the weak point and measured 0.94 on 64-byte bursts; groups now merge the tail.
How to use it
cd exp && ./mkcorpora.sh # build corpora/text.lz etc. (lzip -9 of 4 MiB)
./bench --codec intlv-d64-bch1k-t32 --blob corpora/text.lz \
--size 65536 --trials 200 --burst 256,1 --out results/x.csv
./bench --codec intlv-d64-bch1k-t32 --blob corpora/text.lz \
--size 65536 --trials 200 --ber 1e-3
./bench --codec intlv-d64-bch1k-t32 --blob corpora/text.lz --speedModes: --ber X for independent bit flips, --burst LEN,COUNT for COUNT randomized-byte bursts of LEN bytes, --clean for round-trip, --speed for throughput. The CSV columns are codec,corpus,blob_size,trials,mode,param,success,rescued,rate,enc_MBps,dec_MBps,peak_rss_kb,overhead_pct.
Benefits, measured
| codec | overhead | burst 16 B | burst 64 B | burst 256 B | burst 1024 B | 4x64 B |
|---|---|---|---|---|---|---|
| bch1k-t32 (no interleave) | 5.40% | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| intlv-d16-bch1k-t32 | 5.40% | 1.00 | 1.00 | 0.00 | 0.00 | 0.10 |
| intlv-d32-bch1k-t32 | 5.40% | 1.00 | 1.00 | 0.00 | 0.00 | 0.80 |
| intlv-d64-bch1k-t32 | 5.40% | 1.00 | 1.00 | 1.00 | 0.00 | 1.00 |
Depth 64 is the winner because it is the first depth that survives a 256-byte burst outright and four simultaneous 64-byte bursts. Even at 1.29% overhead, intlv-d64-bch1k-t8 survives 64-byte bursts at 1.00. Random-error performance is unchanged by construction (1.00 at BER 1e-3, same as the BCH underneath). The result reproduces exactly on binary and random corpora, not just text.

Trade-offs and limits
Interleaving buys burst tolerance and nothing else: it cannot help a single block that is already beyond its correction budget, and a 1 KiB burst still kills it (0.00). It inherits the overhead of the BCH underneath — 5.40% at t=32, 1.29% at t=8 — so it is not free protection in absolute terms, only free relative to the BCH you already pay for. And it needs the small blocks of candidate 2; interleaving the as-shipped single-block-per-blob BCH would do nothing, because there is only one block to spread across.
Candidate 2: small-block BCH, 1 KiB blocks — spend real redundancy
What it is and how it works
The same BCH lzply ships, but forced to m=13 blocks (971 data bytes per block) instead of one huge block per blob. Same code, same polynomials, smaller blocks: each block gets its own t correctable bit errors, so a 64 KiB blob goes from 32 correctable bits total to 32 correctable bits per KiB — 64 blocks' worth. That is the whole idea, and it is the "what if we spent real redundancy" operating point.
How to use it
./bench --codec bch1k-t32 --blob corpora/text.lz \
--size 65536 --trials 200 --ber 1e-3
./bench --codec bch1k-t8 --blob corpora/text.lz \
--size 65536 --trials 200 --ber 1e-4 # the cheap operating pointBenefits, measured
| codec | overhead | BER 1e-4 | BER 1e-3 | BER 3e-3 |
|---|---|---|---|---|
| bch-t32 (as shipped) | 0.12% | 0.01 | 0.00 | 0.00 |
| bch1k-t8 | 1.29% | 1.00 | 0.00 | 0.00 |
| bch1k-t16 | 2.62% | 1.00 | 0.73 | 0.00 |
| bch1k-t32 | 5.40% | 1.00 | 1.00 | 0.01 |
Same code, 1 KiB blocks: t=32 buys survival to BER 1e-3 — a decade past the as-shipped cliff — at 5.40% overhead. Speeds: bch1k-t32 encodes at 2.97 MB/s and decodes at 1.55 MB/s; the cheaper bch1k-t8 runs 9.98 / 5.87 MB/s at 1.29% overhead.
Trade-offs and limits
Overhead is the price, and it is steep: 5.40% versus 0.12% as shipped, a 45x increase in parity for a 10x increase in survivable error rate. Bursts still kill it without interleaving (256-byte burst: 0.00 at every t), which is why candidates 1 and 2 are a pair, not alternatives. And at BER 3e-3 even t=32 collapses to 0.01 — if the channel is that bad, you need candidate 3.
Candidate 3: regular LDPC, rate 0.90 — the random-error winner
What it is and how it works
A regular low-density parity-check code: n=8192 bits, column weight 3, m=768 checks, row weight 32, k=7424 bits (928 bytes) per block, rate 0.90625. The parity-check matrix is built by PEG construction (progressive edge growth) with a fixed seed, so the code is identical on every run and every server. Encoding is systematic, by Gauss-Jordan reduction of H to [I | P] — a one-time cost of about 1.8 seconds at codec creation. Decoding is normalized min-sum belief propagation (factor 0.8), up to 50 iterations, stopping early when the syndrome is zero. The channel log-likelihood ratio uses a fixed nominal crossover p0 = 1e-3; the decoder does not know the true error rate.
The reason it wins is the iterative decoder: instead of a bounded-distance algebraic decoder that gives up the moment errors exceed t, belief propagation keeps passing messages until the syndrome clears, so its cliff sits about a decade higher in bit error rate than BCH at similar overhead.
How to use it
./bench --codec ldpc-r90 --blob corpora/text.lz \
--size 65536 --trials 200 --ber 1e-3
./bench --codec ldpc-r90 --blob corpora/text.lz --speed
./ldpc_diag r90 40 50 # single-block error-count sweepBenefits, measured
| codec | overhead | BER 1e-3 | BER 3e-3 | BER 1e-2 | burst 16 B |
|---|---|---|---|---|---|
| bch1k-t32 | 5.40% | 1.00 | 0.01 | 0.00 | 0.00 |
| ldpc-r90 | 10.94% | 1.00 | 0.97 | 0.00 | 0.24 |
| ldpc-r95 | 6.25% | 0.32 | 0.00 | 0.00 | 0.00 |
At BER 3e-3, ldpc-r90 recovers 0.97 where bch1k-t32 recovers 0.01. The measured overhead is 10.94% on 64 KiB windows (nominal code overhead 10.34%; the rest is tail-block padding). Cross-corpus checks reproduce text exactly on binary and random data.

Trade-offs and limits
Three costs. Overhead: 10.94%, roughly double bch1k-t32. Speed: decode runs 0.91 MB/s, about 4x slower than bch1k-t32 (encode 3.34 MB/s), plus the one-time ~1.8 s init — this is the slowest decoder of the three winners. Bursts: a 16-byte burst is about 64 errors in one 1 KiB block, and LDPC recovers only 0.24 of those; LDPC plus interleaving is the obvious follow-up and was not built. The r95 variant is weak (0.32 at 1e-3; the regular (3,64) code starts failing at 6 errors per block) — irregular LDPC is the other follow-up.
Candidate 4: dictionary transform — the only compression win, and only on code
What it is and how it works
A preprocessing stage before lzip: build a per-file dictionary of the most frequent words (alphanumeric runs of length 3 or more, top 4096 by saving), replace them with 3-byte codes, transmit the dictionary in the header, then run lzip -6 over the result. The format is DICT magic, u32 original length, u16 dictionary size, then entries (u8 length, bytes); 0xFF escapes introduce a 2-byte code, and a literal 0xFF is escaped as 0xFF 0xFF 0xFF. The cost of the dictionary is honest — it is transmitted, not hidden.
How to use it
cd experiments
./dict c code.c code.dict && lzip -6 code.dict
lzip -dc code.dict.lz > code.dict2 && ./dict d code.dict2 code.c.out
# decode is the reverse pipeline: lzip -d, then dict d
# dict takes file paths, not stdinBenefits, measured
Compressed size as a percentage of original, 8 MiB corpora, lzip -6:
| corpus | dict + lzip -6 | plain lzip -6 | delta |
|---|---|---|---|
| text | 3.58% | 3.56% | +0.5% worse |
| code | 9.19% | 9.38% | -2.1% better |
| bin | 33.30% | 32.61% | +2.1% worse |
| mixed | 17.65% | 17.41% | +1.4% worse |
| rand | 101.73% | 101.36% | worse |
Only code wins, by 2.1%: long repeated identifiers survive as dictionary codes better than as LZ matches. Everywhere else the dictionary costs more than it saves, because lzip already captures word repeats. The end-to-end check holds: a dict+lzip code blob (770,519 bytes) under BCH t=8 with 8 flipped bits corrects all 8 and recovers bit-identical through the full pipeline; 32 flips fail the decode, as they must (beyond t=8).
Trade-offs and limits
This is a code-only optional stage, not a default — turning it on for text or binaries makes files bigger. The win is small (2.1% on one corpus type) and it adds a preprocessing step and a header format to the pipeline. One bug was fixed on the way: words are sorted by count, so the saving filter must continue, not break, or a short frequent word like "the" discards the whole dictionary.
Supporting infrastructure: the rANS core
The compression prototypes share one entropy stage, experiments/rans.[ch]: a range asymmetric numeral systems coder with static per-file frequencies and 12-bit probabilities. It encodes at 30-38 MB/s and decodes at 47-62 MB/s with about 20 MB RSS. It is kept as reusable infrastructure, not as a compressor: order-0 rANS on its own, with no LZ stage, scores text 64.40%, code 67.62%, binaries 77.14% — nowhere near lzip. Two real bugs were found and fixed in the core (the renormalisation threshold must be (L>>12)*f<<8 or the decoder over-reads; the emitted stream can exceed n bytes, so the scratch buffer is 2n+64).
cd experiments
./rans_tool c in out # compress (order-0 rANS)
./rans_tool d in out # decompressWhat was measured and rejected
Honest negatives, with their numbers. The code for these was not carried into the integrated tree; only the measurements remain (in the branch READMEs and experiments/results/*.csv).
| family | verdict | numbers |
|---|---|---|
| Polar SC, rate 0.90 | Dominated, rejected | 0.00 at BER 1e-3 at every design point; designing for p=1e-2 gives 0.00 at 1e-4; best variant (design 1e-4) reaches 0.95 at 1e-4 — still worse than bch1k-t32 (1.00 at 1e-3, half the overhead) and ldpc-r90. Slowest decoder of all: 0.58 MB/s. List (SCL) decoding is the follow-up that could rescue it. |
| Unequal error protection (UEP) | Conditional, not integrated | Whole-file recovery is dominated by the weak tier (0.00 at 1e-3). But the first 1-4 KiB (lzip header + stream start) survives at 1.00 at 1e-3 and 1.00 under a 256-byte burst — only useful if lzply gains a salvage mode; today the entry SHA gates all-or-nothing extraction. |
| LZ77 + rANS | Rejected as a lzip replacement | Lazy: text 6.26%, code 13.52%, bin 41.84%, mixed 23.15%. Optimal parsing recovers only ~1-3% relative, so the gap is not parsing — it is LZMA's adaptive context entropy model plus deeper match search and a larger dictionary. A static-table rANS cannot close a ~75% relative gap on text. |
| BWT + MTF + rANS | Rejected | Text 6.35% (beats bzip2's 9.25%), code 12.31%, bin 42.76%; loses to lzip everywhere by a wide margin. Encode is ~3 minutes per 8 MB (0.05 MB/s), decode 5-6 MB/s, RSS ~200 MB. |
| PPM order-2 + arithmetic coding | Rejected | Text 32.84%, code 30.82%, mixed 39.18%; ~6 MB/s encode, ~4 MB/s decode. A simple order-2 PPM with heavy escape mass is nowhere near PPMd-class. |
Totals for the record: 51,875 corruption-matrix trials across the ECC families (plus diagnostics), and 334 timed benchmark invocations across the compression families, all SHA-256 verified.
Fresh numbers on the integrated tree
The numbers above are the branch measurements. After merging onto current main, the integrated tree was rebuilt with make -j8 and re-measured on the same data set (mixed set + 1 MiB incompressible), against plain lzply at b27b345. The lzply core is untouched by the integration — the diff against b27b345 is only exp/, experiments/, bench/, docs/, tests/, the Makefile, and the README — so the plain-lzply numbers below are the integrated tree's own binary.
Data set: a mixed directory of 25,521,882 bytes (repo text 1,004,068 + repo C sources 786,430 + /bin/ls, /bin/cat, /usr/bin/lzip) plus 1 MiB of /dev/urandom. Timings are best-of-3, load ~1.2-1.6, hot_newyork, 2026-12-02.
Plain lzply at b27b345 (the integrated binary — the core is untouched, md5-identical to pristine):
| operation | size | time (best of 3) |
|---|---|---|
lzply -c -6 mixed dir | 7,060,165 bytes | 22.904 s compress / 1.594 s extract |
lzply -c -6 -e 0 mixed dir (no BCH) | 7,059,797 bytes | — |
lzply -c -6 1 MiB random (stored, level 0) | 1,048,750 bytes | 0.577 s compress / 0.060 s extract |
The BCH on this set costs 368 bytes total (7,060,165 vs 7,059,797) — most of the mixed dir is large binaries whose entries carry little parity relative to their size.
Codec speeds on the mixed lzip blob (308,207 bytes, 64 KiB windows):
| codec | encode MB/s | decode MB/s | overhead | init |
|---|---|---|---|---|
| bch-t32 (as shipped) | 8.59 | 4.28 | 0.12% | 0.00 s |
| bch1k-t32 | 3.72 | 1.93 | 5.40% | 0.00 s |
| intlv-d64-bch1k-t32 | 3.77 | 1.72 | 5.40% | 0.00 s |
| ldpc-r90 | 4.08 | 1.07 | 10.94% | 1.87 s |
Interleaving costs nothing measurable against the BCH underneath (3.77 / 1.72 vs 3.72 / 1.93 — the same codec, permuted). LDPC pays for its 1.87 s one-time init and its ~4x slower decode. Recovery on the mixed blob reproduces the branch matrices exactly: intlv-d64 256-byte burst 1.000 (20 trials), bch1k-t32 BER 1e-3 1.000 (20 trials), ldpc-r90 BER 1e-3 1.000 (10 trials).
Dictionary transform on this corpus — and here is an honest fresh negative: on repo C sources only (786,430 bytes), dict+lzip6 gives 123,662 bytes vs plain lzip6 120,409 (+2.7% worse), and on text 191,045 vs 187,798 (+1.7% worse). The branch's -2.1% win was on header-heavy code (8 MiB of /usr/include headers + repo sources), where repeated identifiers dominate. The conditional stands, and it is corpus-dependent: headers win, plain C sources do not. The rANS core on text: 1,004,068 bytes → 614,658 (61.2%), encode ~31 MB/s, decode ~42 MB/s.

Verification
Full suites on the integrated tree, hot_newyork: bch_test 7,975 checks 0 fails; rs_test 6,243 checks 0 failures; crc16_test 530 checks 0 fails; run_rs_tests.sh 61 passed 0 failed; run_deep_repair_tests.sh 47 passed 0 failed; run_hyper_tests.sh 56 passed 0 failed; run_tests.sh 149 passed 0 failed from a /tmp checkout. In the /opt checkout run_tests.sh reports 146 passed, 3 failed — the 3 failures are FUSE mount tests (relative-path mount writes; store-mode mount repack) that fail identically on pristine b27b345 in /opt (verified: pristine main in /opt scores the same 146/3, same three tests). Root cause, proven, not assumed: the AppArmor profile for fusermount3 denies the umount operation on paths under /opt (apparmor="DENIED" operation="umount" profile="fusermount3" in dmesg), so the repack-on-unmount never runs and the daemons stay alive. The lzply binaries are byte-identical to pristine main (md5-verified), a manual mount/write/unmount/repack cycle with the integrated binary passes, and the same integrated tree passes all 149 tests from /tmp. It is a host AppArmor quirk, not an integration bug — and it is exactly the known pre-existing failure mode for FUSE mount tests under /opt. The integration smoke tests (tests/run_integration_tests.sh) pass: clean round-trips for all three ECC codecs, intlv-d64 burst survival with the uninterleaved control at 0, bch1k BER survival with the as-shipped control at 0, LDPC BER survival, rANS round-trip, dict+lzip round-trip, bchcheck 8-flip recovery with 32-flip expected failure, and an LZPL v5 archive round-trip.
What's next
The obvious follow-ups, in order of expected value: LDPC plus interleaving (fixes LDPC's burst weakness with the zero-overhead trick from candidate 1); irregular LDPC (fixes r95's weakness at 6 errors per block); SCL list decoding for polar (the one follow-up that could rescue it); a salvage mode for lzply, which is the precondition for UEP's prefix-survival property to matter; and wiring interleaving and LDPC into lzply -e levels, which needs a format change. None of those are built yet. What is built, measured, and merged is above — four candidates, three of which make archives survive damage the old code cannot, and one of which makes code compress 2.1% smaller.
Code: github.com/cnmcdee/lzply, branch experiments/integration. Method and full tables: docs/BASELINE.md, docs/INTEGRATION.md, exp/README.md, experiments/README.md in the repo.