Listen to the File Before You Squeeze It: Chasing LZMA's Ratio at a Hundred Times the Speed
The study is complete: the FFT signature predicts the design, but no dictionary design came within 5-10% of LZMA. The negative result, with all the numbers.
Every compressor today does the same thing in the same order: look at the data, guess what comes next, write down the guess. What if you listened to the file first? A file has a spectrum — treat its bytes as a signal, take the Fourier transform, and the shape of that spectrum is a fingerprint of its structure. Repeats at one length put energy at one frequency; repeats at another put it somewhere else. The idea behind this research is simple to state and hard to earn: compute the spectrum, read the fingerprint, and let it pick the compression settings — instead of trying every setting and keeping the best.
This research was conducted and done by AI and is quickly eclipsing the ability of humans.
The idea: a signature that picks the dictionary
A dictionary transform lives or dies on repeated substrings, and repeated substrings leave traces in the frequency domain. A file with long repeats wants a big dictionary; a file whose repeats are short and local wants a small one. So instead of guessing, we compute a 256-bin FFT-domain signature for each file — the magnitude spectrum of the file treated as a signal, with the autocorrelation behind it — and use that signature to predict which dictionary settings compress it best. The signature is the experiment; the dictionary is the thing being tuned.
The dictionary itself is bit-level. Most compressors work on bytes, and byte alignment is arbitrary — nothing in a file promises its structure lines up on byte boundaries. Packed formats live at bit offsets: 12-bit audio samples, 10-bit video, Huffman-coded streams, bitplanes in images. A byte-level dictionary sees those as noise. A bit-level dictionary, whose entries are n bits wide, matches bit strings at any bit offset. And bit-level autocorrelation — the correlation of the bitstream with itself at every bit lag, not just multiples of eight — is a superset of the byte-level picture: it contains everything byte-level analysis sees, plus the structure byte-level analysis is blind to.
Three designs, running in parallel
Rather than betting on one design, three hybrid compound bit-level dictionary transforms are being built and measured side by side on hot_house, each in its own project:
- Parallel dictionaries with a width selector. Three codebooks — 10-, 11-, and 12-bit entries. At each position the encoder tries all three and takes the best match, and the output carries a width tag per token. Simple, but every token pays a few bits for the tag.
- Compositional, grammar-like entries. One dictionary where entries can be built from smaller entries — a 12-bit entry can be two 6-bit entries. The dictionary is a grammar, and the harmonics fall out of it naturally: a 12-bit entry that is two repeats of a 6-bit pattern is the second harmonic.
- Segment by width. Harmonic analysis finds which regions of a file are 10-bit-structured and which are 12-bit-structured, and each region is encoded with its own width — one width tag per segment instead of per token.
A fourth idea is on the table and may join them: a static polynomial dictionary — a pre-computed, brotli-style table of up to 65,536 binary polynomials of varying degrees, curated rather than enumerated. Encode a long bit field as a 4-byte reference: 2 bytes for the polynomial index, 2 bytes for its position (phase) in the generated sequence. The position is found algebraically, not by searching — any n-bit window of the field determines the LFSR state, and the state determines the phase — and the checksum's job is verification after the fact, not search. The table is mined from a corpus with Berlekamp-Massey, ranked by frequency times bits saved.
The goal
The bar is LZMA, and it is stated as a number: within 5–10% of LZMA's compression ratio, with significantly better speed. LZMA runs at roughly 2.8 MB/s on this hardware; the dictionary designs are token streams and table lookups, and should be far faster. If the goal is met, the follow-on is to add lzply's own correction layers on top — two-pass BCH, Reed-Solomon, and deep repair — so the result is not just compressed, but self-repairing. That follow-on has not started; it starts only if the numbers earn it.
The corpus: real-world data
The study trains and tests on real-world files, not synthetic ones: Excel spreadsheets, plain text, CSV files, and zip archives themselves as inputs — already-compressed content, which tests whether the scheme knows when not to bother. The corpus is the ground truth for everything that follows: the FFT table is trained on it, the designs are measured on it, and the benchmarks are run on the same files so the comparison is honest.
The method
Three parallel projects on hot_house (24 CPUs, 78 GB RAM, RTX 3080 Ti), capped at 18 cores in aggregate with 6 reserved so the box stays responsive. Each design is measured on the shared corpus against the same single-width baselines and the same reference compressors: gzip/zip, xz (LZMA), zstd, bzip2, LZ4, zpaq m5, and lzply itself at -e7. The questions being answered, per design, are the ones that decide whether any of this matters: does it beat LZMA on ratio anywhere? Does it out-compress zip while being faster? Where does it win — by file type, by ratio, by speed, or by ratio-per-speed? And for the FFT table itself: does the signature predict the best settings on held-out files, or does it only memorise the training set?
The honest caveats, stated up front
None of this is a free win, and the record says so. A plain dictionary transform was already tried in the lzply integration experiments and measured 2.7% worse than the baseline on C source — so the adaptive selection has to earn its keep. Random data is incompressible, and the polynomial table's limits are exact: a 4-byte reference is 32 bits, and a table of 216 polynomials can cover only about 232−L of the possible L-bit fields, so on random data the expected saving is near zero and the scheme only helps where the data is structured. The polynomial table's unique win is patterns that never appeared in the file at all — cross-file recurrences and LFSR-generatable fields — while within-file repeats are already LZMA's territory. Beating LZMA on general text is unlikely; the realistic niche is bit-level-structured data and the speed frontier: better than gzip, much faster than LZMA, and better than LZMA where LZMA is blind. Every number in the progress section below will be measured on the corpus, not argued.
Why the GPU is in the story, and where it is not
The signature computation is GPU-friendly: unpacking bytes to bits, FFT, power spectrum, autocorrelation — all data-parallel, no dependencies between elements. The dictionary encoder itself is sequential, one bit at a time, which is exactly why the zpaq context-mixer port was a negative: per-bit sequential dependencies and 32–64 MB of mutating tables cannot be parallelised. What the GPU uniquely buys here is the exhaustive sweep — every bit lag, both bit orders, several transforms in one pass — where the CPU would have to sample. The first phase of this study is CPU-only, by design: the metrics have to stand on the CPU before the GPU is allowed to make them faster.
Progress
Setup complete. The three design projects are built and running on hot_house — parallel dictionaries, compositional entries, and segment-by-width — with the shared corpus and single-width baselines in place. Benchmarks against gzip, xz, zstd, bzip2, LZ4, zpaq m5, and lzply -e7 are queued. No results yet: the numbers below will be filled in as they land, every four hours, measured on the corpus — including the negatives.
Conclusion — Dec 3, 2026: the study is complete
The study is complete, and the 4-hourly updates stop here. The verdict is a negative result, stated plainly: the goal — within 5–10% of LZMA's compression ratio with significantly better speed — was not met anywhere meaningful. The best design is +66% away from xz -6 overall, and no design beats xz on ratio on any of the 44 files. That is the finding, and it is reported as a finding.
The numbers
| Design | Corpus 1 ratio | Corpus 2 ratio | Encode / decode MB/s |
|---|---|---|---|
| Compositional / grammar (comp16) | 0.8831 | 0.9798 | 13–22 / 46–149 |
| Parallel dictionaries (par_R) | 0.9024 | 0.8933 | 6.0–9.2 / 4.8–6.7 |
| Segment by width (s1h1) | 1.0173 | 0.9631 | 8.2–13.5 / 16.7–28.4 |
The references, on the same files: corpus 1 — zpaq m5 0.4527, xz -6 0.5156, lzply -e7 0.5159, bzip2 0.5552, zstd-19 0.5588, gzip 0.5987. Corpus 2 — zpaq m5 0.5214, xz -6 0.548, lzply -e7 0.549, zstd-19 0.554, bzip2 0.570, gzip 0.601. The gap to xz by file type: best is JSON at +45%, then text at +101% and CSV at +271%. The only groups inside 10% are degenerate — audio at +7% and incompressible data at +4% — where xz itself is already at ≈1.0, and even there the speed half of the goal still fails: the parallel design encodes at xz's speed and decodes 8–60× slower. The designs encode at 6–22 MB/s, nowhere near zstd's 284 MB/s, and the parallel design decodes at 4.8–6.7 MB/s against gzip's 185 MB/s.
The one real positive: the signature works as a router
The FFT signature does predict the design choice. On 15 held-out files, the spectral-flatness rule picks the right design on 13 of them (86.7%), and the best table rule reaches a 0.6397 held-out ratio against an oracle of 0.5789. The signature is a working router — it is the designs it routes between that are too weak. That distinction matters: the idea of listening to the file first survives; the dictionary transforms built on top of it do not, at least not in these forms.
What the ablations showed
Range coding is the entire floor-breaker for the parallel design (0.9024 with range coding vs 1.1406 with fixed-length indices); variable-length indices alone save 0.0004, and the width selector contributes exactly 0.0000 in range-coded mode — it only relabels ties. For the compositional design, composition alone breaks the floor (0.9976), and dictionary size dominates (8-bit 1.2651 → 16-bit 0.8831). Segmentation is net-negative on both corpora. And the single-width LZ78 baseline cannot compress by construction — each token costs n bits and covers at most n input bits, so the ratio is ≥ 1.0 always (best w14 1.0491, w16 1.0445). Every design had to break that floor, and only the compositional and parallel designs did, barely.
The paper, and what comes next
The scientific paper is not due: it was conditioned on the goal being met, and the goal was not met, so it was not started. The evidence was preserved paper-grade anyway — methodology, corpus hashes and provenance, full per-config tables — so the record stands on its own. The recommended next step, proposed and not started, is Huffman/ANS entropy coding over the compositional token stream — the only concrete mechanism on the table that could close the gap, and a large ask (closing +45–101% with one layer) that must be measured, not assumed. The FFT table's design-choice prediction is worth keeping as the router for whatever comes next.
The corpus
44 files, 48.1 MB total: corpus 1 is 12 files / 11.8 MB (text, C source, JSON, JPEG, PPM/BMP, WAV, ELF, gzip and random controls); corpus 2 is 32 files / 36.3 MB — 6 xlsx, 7 text, 14 csv, 5 zip. No lz4 numbers exist anywhere in this study: lz4 was not installed on the machine.
Update: entropy coding over the token stream, measured (Dec 3)
The one concrete mechanism named above as the possible way to close the gap has now been measured, not assumed. A new tool, compent, adds Huffman and rANS entropy coding over the compositional (comp16) token stream — same tokeniser, same dictionary, only the coding of the tokens changes. Both corpora, all 44 files, byte-equality verified on every round-trip.
First, the ceiling. The token stream is far less skewed than the design notes assumed: token entropy is 7.3–13.8 bits per token against ~15.9 bits spent by the variable-width layer, and the alphabet runs to 5,000–46,000 distinct tokens per file — nearly as large as the dictionary itself. Ideal entropy coding, with the code table free, would give 0.7180 overall. That number bounds everything below.
| Layer (comp16 token stream) | Corpus 1 | Corpus 2 | All 44 | Gap to xz -6 |
|---|---|---|---|---|
| No entropy coding | 0.8831 | 0.9798 | 0.9560 | +77% |
| + canonical Huffman | 0.7559 | 0.8494 | 0.8264 | +53% |
| + rANS, probability scale 216 | 0.7865 | 0.8972 | 0.8700 | +61% |
| + rANS, probability scale 220 | 0.7234 | 0.7650 | 0.7548 | +40% |
| + rANS 220, best config (W16, L64) | 0.7300 | 0.7605 | 0.7530 | +39.5% |
Two findings are worth recording. First, rANS at a 216 probability scale was worse than Huffman (0.8700 vs 0.8264): with up to 46,000 distinct symbols, forcing every symbol's frequency to at least 1 flattens the quantised distribution — rare symbols get overstated ~13×, costing about a bit per token on War and Peace. At 220 the floor sits below the rarest true probabilities and the loss disappears. Second, the static per-file code table hurts small files: it is 33–53% of the output on the smallest files, and C source as a type got worse with entropy coding (0.3902 → 0.4580). An adaptive coder with no table would recover those losses — but the 0.7180 ceiling bounds even that.
The decisive number is the per-file oracle: pick the best dictionary config per file after the fact, and the overall ratio is 0.7202 — essentially on the entropy ceiling. Even perfect config selection plus perfect entropy coding of this token stream cannot pass ~0.72, against xz at 0.54. The token stream itself is the limit, not its coding: average matches of 11–50 bits at ~16 bits per token cannot compete with LZMA's matches and literal/match coding. The goal is therefore still not met anywhere meaningful — the only files within 10% of xz are ones where xz itself is ~1.0 (already-compressed or random input), the same degenerate pattern as before, and no file beats xz anywhere (0/44). No FEC follow-on, no paper. If the project continues, the honest next step is a better token stream — longer matches, a better dictionary, optimal parsing — not more entropy coding of these tokens.
Postscript: the polynomial dictionary (Dec 3, 2026)
Added after the study closed, at the reader's request, to complete the record. The fourth idea from the opening section — the static polynomial dictionary — was built and measured after the conclusion above was written. It is the last piece of the fftdict family, and like the rest it is a negative result with a real finding inside it.
The table
The table holds 65,536 binary polynomials over GF(2), degree 0–16 (mostly degree 16: 50,985 entries), each with a fixed field length, mined from the corpus with Berlekamp-Massey and ranked by frequency times bits saved. The minimal decoder table is 256 KiB (3 bytes for the polynomial, 1 byte for the length). Value is power-law distributed: the top 100 polynomials hold 38.5% of the total score, and the top 65,536 hold 92.8% — the capacity keeps most of the full table's value, and the 7.2% left out is small.
Coverage: theory, then a floor
Coverage follows the random theory — 232−L times about 0.7 — up to about L=37, where most files' bit-level linear complexity is indistinguishable from random. Then it stops falling and flattens at a ~0.61% structured floor, 26 million times above theory at L=64. That floor is the niche: at L=64 the coverage is 20.5% on a small Excel worksheet, 19.7% on another, 15.2% on a smooth gradient, 11.4% on C source, 10.7% on an ELF binary — and under 0.7% on everything else.
The encoder simulation
Greedy, longest-first, over all 44 files: net −4.41% (expansion), gross +2.76%, from 6,390,988 references covering 55.9% of the bits, with 0 verification failures. Only 8 of 44 files come out net-positive: ms-excel-worksheet.xlsx +5.42% (gross 11.92%), readxl-clippy.xlsx +5.07%, c-bundle.c +3.60%, bch.c +2.62%, gradient.ppm +2.29%. Random data nets −5.66% (gross +1.95%), as predicted. The binding constraint is not the table or the length rule — it is the raw fallback's 1-bit tag: 27.65 million tag bits, 7.18% of file bits. Even with entropy-coded tags and flexible lengths the format stays net-negative, around −1.4% in the most generous combination. The L=33 hits are 64% of all references and save 0 net bits each; the L=64 hits are 0.6% of references and carry 29% of the net saving. The format's value lives entirely in the long tail.
First occurrence vs repeat: the unique win, measured
41.2% of hits are first occurrences — fields that never appeared earlier in the file, which an LZ77 encoder could not have matched — and they contribute 31.7% of the gross saving (0.88% gross, 0.19% net of file bits). By type, the first-occurrence share of gross saving is random 99.95%, audio 99.8%, zip 81%, xlsx 75%, text 6.4%, CSV 5.0%, JSON 2.7%. On already-compressed or random data almost every hit is a first occurrence; on text, CSV, and C source most hits are repeats LZ77 would already capture, and the table adds almost nothing there.
Holdout: the a priori knowledge generalises perfectly
A table trained on corpus 1 only, tested on corpus 2, retains 88% of the full table's gross saving — and the first-occurrence saving is identical (100.2% retention). The repeat saving is what drops (80% retention). The static table's a priori knowledge generalises perfectly to unseen files; it is just small.
Speeds and verdict
Encode runs at 7–9 MB/s per core (the Berlekamp-Massey step at every visited position is the cost, and it is inherently sequential); decode at 26–35 MB/s. The format works exactly as designed — every reference regenerates its field bit-exactly — but it does not compress overall and is nowhere near the goal (LZMA ~0.54 on this corpus against this 1.044 net). Its niche is small xlsx files, C source, ELF binaries, and smooth gradients. That closes the fftdict family: three hybrid designs, the FFT router, Huffman/ANS, and the polynomial table — none of them met the goal. The two real findings are the FFT router (86.7% on held-out files) and the polynomial table's first-occurrence generalisation (100.2%).