rsi 1.0: Eighteen Rounds, 44 MB/s Decode — and Still 32% Behind xz

rsi 1.0 is the standalone codec out of eighteen rounds of RSI research: 44 MB/s decode, 13 MB/s encode, ratio 0.7124 — still 32% behind xz -6. Rounds 8 and 9 are what made it shippable.

rsi 1.0: Eighteen Rounds, 44 MB/s Decode — and Still 32% Behind xz

rsi 1.0 is a standalone codec that decodes at 44 MB/s and encodes at 13 MB/s — and still loses to xz -6 by 32% on ratio. That sentence is the whole article, really: this is a tool about speed, not size. It comes out of eighteen rounds of adversarial research on a token-stream codec, and the two rounds that made it shippable are the subject here — a decoder table gate that fixed a small-file regression, and an encoder prefix table that nearly doubled encode speed, both without changing a single compressed byte.

It lives in its own repo, it is one C file, and it links only libc and libm. It has nothing to do with lzply's FEC core.

cnmcdee/lzply
lzply — error-correcting compression: LZMA + BCH/Reed-Solomon parity, GPU-accelerated deep repair, and the lzcsv CSV compressor.
cnmcdee/fftdict-rsi
rsi 1.0 — standalone fast codec (bit-level compositional dictionary + rANS). 44 MB/s decode, 13 MB/s encode, ratio 0.7124 on the 44-file corpus. One C file, make, rsi c/d/bench.

What Rounds 8 and 9 actually did

The codec — RSI, for recursive self-improving — is a bit-level compositional dictionary over a token stream, entropy-coded with rANS. The token stream was already the binding constraint (its entropy ceiling is 0.7180; the best ratio the loop ever found is 0.7124), so after Round 3 the loop turned to speed. Round 5 put 16-bit prefix tables in the decoder and nearly doubled decode (21.1 → ~40 MB/s) — but broke small files, which decoded at 0.66–0.67× their old speed. Round 7 proved the cause was the 512 KB table allocation, not table traffic. Round 8 is the fix.

Round 8 — the size gate. The decoder now measures the literal fraction of the token stream (an exact pre-scan) and allocates the tables only when it is ≥ 0.4. Below that, the file decodes the old way. The gate changes no token, so ratios are identical by construction. Small files are back to Round 4 speed, burpsuite keeps its 3.3× decode speedup (13.6 → 44.6 MB/s), and the full-corpus headline is unchanged at 0.7124.

Round 9 — the encoder prefix table. Encode was the bottleneck at 6.9 MB/s, 77–86% of it inside longest_match. A static encoder prefix table with a split matcher — the decoder keeps its own inlined copy, because a shared function refused to inline and cost the decoder 12% — lifts encode 1.83× weighted (2.56× on burpsuite) with ratios bit-identical and decode at gated-Round-5 levels on 5 of 6 spot files. Burpsuite keeps a consistent ~5% decode cost against a 2.56× encode win: the residue of the shared-matcher codegen, measured and bounded rather than wished away.

Neither round is a standalone tool. Together with the rounds around them — R1 literal-run escapes, R3 staleness-gated reset, R11 L0 memset, R13 in-process malloc regime, R15–R18 peak-memory work — they are what turn a research binary into something worth a make target. That is the honest answer to "what tools come out of R8 and R9": the codec itself, shipped as rsi.

How it works

Input bytes are tokenised bit by bit into a compositional dictionary: each token is a bitstring, and new entries are concatenations of earlier ones, so the dictionary learns the file's own repeated structure. Literal-run escapes (Round 1) handle incompressible regions — a random byte costs one LIT token plus raw payload bytes instead of eight 1-bit tokens. A staleness-gated reset (Round 3) discards the dictionary when its recent matches go stale, which is where most of the ratio comes from. The token stream is then coded with rANS (20-bit precision) or Huffman; the default is rANS.

The decode path is where the speed lives: 16-bit prefix tables over the token stream (Round 5), allocated only when the literal fraction says they pay (Round 8), over a decoder trie that is now one packed 8-byte node (Round 18), with the winning malloc regime applied in-process — a 128 MB top pad (Round 13) — so the binary does not depend on environment variables. The whole file is held in memory (input + compressed + output), which is why the peak is what it is: burpsuite-src.zip (13.7 MB in) decodes at 41.1 MiB maxrss and encodes at 53.7 MiB.

The container is a 40-byte header — magic CL4A (rANS) or CL4H (Huffman), the width, length cap, flags, and the literal-run and reset settings — followed by the token stream and the literal payload. Decompression reads its parameters from the header, so rsi d takes no flags. Older CMPD/CMPH/CMPA files still decode.

The numbers: 44 files, 48,144,974 bytes

Measured on hot_house with make bench (3 rotations; all three per-file TSVs are in results-rsi/). Ratios are load-independent and reproduce exactly across rotations; speeds are the quiet-window rotation.

typenrsi ratioxz −6gapenc MB/sdec MB/s
audio11.00490.9631+4%18.459.9
bmp-image10.83790.2943+185%12.033.9
c-source20.72170.2387+202%6.115.2
c-source-bundle10.46830.1638+186%9.026.5
csv140.47630.1713+178%11.144.5
elf-binary10.85310.4080+109%5.714.7
gzip-control11.00391.0001+0%20.469.9
jpeg-photo10.80220.7649+5%15.645.8
json10.30950.2179+42%14.347.1
ppm-image10.80970.1721+370%11.831.3
random-control11.00361.0001+0%20.974.8
text80.51430.2880+79%11.441.7
xlsx61.00320.9055+11%18.957.3
zip50.94760.9049+5%15.745.1
overall440.71240.5399+31.9%13.144.3
ex-covid430.7406——13.644.3

Aggregate: ratio 0.7124 against xz −6's 0.5399 (+31.9%), ex-covid 0.7406, encode 13.1 MB/s, decode 44.3 MB/s (size-weighted, quiet rotation; the three rotations of this run measured 12.8–13.1 / 42.9–44.3, median 13.0 / 43.5). CSV is the codec's best case at 0.4763 and still trails xz by 178%. An earlier 3-rotation run on the same codec, while the Qwen4 server was generating (load ~12), measured 7.4 / 24.4 MB/s on its slowest rotation (median 10.7 / 29.5) with identical ratios — speeds move with load, ratios do not, and both runs are reported here rather than only the flattering one.

The losses, stated honestly

First, the ratio: 32% behind xz is not a rounding error, and no round in the loop has closed it. The token stream's entropy ceiling is 0.7180 — the codec is within 1% of the best its own token stream can do, and that best is still a third worse than LZMA. If size is what matters, use xz. This tool is for the case where decode speed matters more than the extra bytes, and the corpus where that trade is real is narrow.

Second, the wins are concentrated. CSV (0.4763) and JSON (0.3095) compress well; xlsx, zip, gzip, and random files compress to ~1.0 — the literal-run escape keeps them from expanding, but there is nothing to win there. Images are the worst gap (ppm +370% vs xz): the dictionary learns structure xz's match finder already finds, and pays for it in model cost.

Third, small-file decode varies ±30% run to run — the encoder-layout lottery documented in Rounds 8–12. Single-file timings on small inputs are not trustworthy; the corpus aggregates are. Fourth, the whole file sits in memory, so this is not a streaming compressor and will never be one in this form. Fifth, there is no integrity checksum beyond the round-trip itself.

Speed and correctness

make test runs 54 checks: 44 corpus round-trips, byte-exact; 3 byte-identical outputs against the research binary rsi18 run with the explicit promoted flags (the pinned defaults are not a new configuration, they are the old one with the flags filled in); 4 cross-compatibility checks (the new binary decodes old files, the old binary decodes new files — the format did not change); and hello/random/empty spot checks. All 54 pass.

Peak memory (CLI, file-to-file): burpsuite-src.zip decodes at 41.1 MiB maxrss and encodes at 53.7 MiB. In the research harness, Round 18's packed trie cut the decoder live peak from 57.2 MB to 53.0 MB; a 64 MB top pad is free, 32 MB now costs ~2% of decode (was ~4%).

Get it

rsi 1.0 is in the fftdict-rsi repo. One C file, one Makefile, no dependencies beyond libc and libm.

git clone https://git.lightgui.com/thinkmelt/fftdict-rsi.git
cd fftdict-rsi/rsi-cli
make
./rsi c in out     # compress (pinned best config)
./rsi d in out     # decompress
./rsi bench file   # encode+decode, print stats, verify round-trip
make test          # 54 checks
make bench         # full-corpus bench, 3 rotations

The pinned default config is Round 3 nominal: -w 16 -L 128 --comp --var --reset --ans --lit 20 --minrun 48 --learn 1 --learnlen 15 --stale 12 --stalewin 256. Every research flag still works and overrides the defaults. The research loop itself continues in the same repo — ROUNDLOG.md records every round, including the dead ends, and Round 19 (recovering the decode cost of the packed trie) is open. Source: git.lightgui.com/thinkmelt/fftdict-rsi.

Linux Rocks Every Day
Source code: git.lightgui.com/thinkmelt/lzply