- rsi c/d/bench subcommands, pinned Round 3 nominal defaults, make test (54 checks) + make bench (3 rotations) - 44-file corpus: ratio 0.7124 overall / 0.7406 ex-covid (xz -6 0.5399, +31.9%); encode 13.0, decode 43.5 MB/s median (quiet 13.1/44.3); ratios exact across 6 rotations in 2 runs - peak memory (burpsuite-src.zip): decode 41.1 MiB, encode 53.7 MiB maxrss - root README: rsi-cli entry + repo link
rsi — a research-grade fast codec
rsi is the shippable tool out of the fftdict-rsi research loop
(https://github.com/cnmcdee/fftdict-rsi): a standalone command-line
codec that compresses with a bit-level compositional dictionary plus
rANS entropy coding. It is fast, not small: on the 44-file
research corpus it encodes at 13.0 MB/s and decodes at 43.5 MB/s
(median rotation; quiet rotation 13.1/44.3 — speeds are
load-sensitive, see the measured-numbers table), but its ratio is
0.7124 — about 32% behind xz -6 (0.5399).
It wins on speed against dictionary coders in its class, not on
ratio against LZMA. That is the honest trade, and it is the reason
this tool is versioned 1.0.0 as a research artifact, not a
general-purpose compressor.
What Rounds 8 and 9 actually contributed
Rounds 8 and 9 are not standalone tools — they are two of the improvements that make this codec worth shipping at all:
- Round 8 — size-gated decoder tables. The Round 5 decoder prefix tables made literal-heavy files decode up to 4× faster but slowed small files (a 512 KB table allocation dominating a small decode). Round 8 gates the tables on the literal fraction (on iff ≥ 0.4, measured by an exact pre-scan): small files decode at Round 4 speed again, burpsuite keeps its 3.3× decode speedup, ratios identical by construction (the gate changes no token).
- Round 9 — encoder prefix table (N4 split matcher). The
encoder was the bottleneck (6.9 MB/s, 77–86% of it in
longest_match). A static encoder prefix table plus a split matcher (the decoder keeps its own inlined copy) 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.
The rest of the lineage is in the file header and in ../ROUNDLOG.md:
R1 literal-run escapes, R3 staleness-gated reset, R11 L0 memset,
R13 in-process malloc regime (128 MB top pad), R15–R18 peak-memory
work (the decoder trie is now a packed 8-byte node; CLI-measured
burpsuite peaks: decode 41.1 MiB, encode 53.7 MiB maxrss).
Build
make # gcc -O2, no dependencies beyond libc/libm
make test # 44-file corpus round-trips + cross-compat + spot checks
make bench # full-corpus bench, 3 rotations, load-guarded
Usage
rsi c in out # compress with the pinned best config
rsi d in out # decompress (parameters are read from the header)
rsi bench file # encode+decode, print stats, verify round-trip
rsi --help | --version
The pinned default config is Round 3 nominal (r3s12), the promoted configuration:
-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, so
rsi c in out and the explicit research command produce
byte-identical output (verified in test-rsi.sh). The research
flags are --lit, --minrun, --learn, --learnlen, --litmax,
--stale, --stalewin, --stalemrun, --stalemingap,
--legacy|--huff|--ans, --no-comp, --no-var, --no-reset,
--tokdump. Environment: RSI_TOP_PAD (bytes; default 128 MB
malloc top pad), RSI_MMAP_THRESHOLD, RSI_MMAP_MAX,
RSI_TRIM_THRESHOLD.
Measured numbers (RSI CLI 1.0.0, hot_house, 44-file corpus)
Measured with make bench (3 rotations, final binary; per-file TSVs
in results-rsi/, aggregate in bench-rsi-2.log). Ratios reproduce
exactly in all six rotations across two runs; speeds are
load-sensitive. Headline speeds are the quiet-window rotation (r2);
the range across this run's rotations and the median are in the table.
An earlier 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 — see bench-rsi.log.
| rsi 1.0.0 | xz -6 | |
|---|---|---|
| ratio, overall (48,144,974 bytes in) | 0.7124 | 0.5399 |
| ratio, ex-covid | 0.7406 | — |
| gap vs xz | +31.9% | — |
| encode, size-weighted (quiet / range / median) | 13.1 / 12.8–13.1 / 13.0 MB/s | — |
| decode, size-weighted (quiet / range / median) | 44.3 / 42.9–44.3 / 43.5 MB/s | — |
Per-type, quiet rotation (r2) — ratios identical in all six rotations; speeds MB/s:
| type | n | rsi ratio | xz -6 | gap | enc | dec |
|---|---|---|---|---|---|---|
| csv | 14 | 0.4763 | 0.1713 | +178% | 11.1 | 44.5 |
| text | 8 | 0.5143 | 0.2880 | +79% | 11.4 | 41.7 |
| json | 1 | 0.3095 | 0.2179 | +42% | 14.3 | 47.1 |
| c-source | 2 | 0.7217 | 0.2387 | +202% | 6.1 | 15.2 |
| c-source-bundle | 1 | 0.4683 | 0.1638 | +186% | 9.0 | 26.5 |
| bmp-image | 1 | 0.8379 | 0.2943 | +185% | 12.0 | 33.9 |
| ppm-image | 1 | 0.8097 | 0.1721 | +370% | 11.8 | 31.3 |
| elf-binary | 1 | 0.8531 | 0.4080 | +109% | 5.7 | 14.7 |
| jpeg-photo | 1 | 0.8022 | 0.7649 | +5% | 15.6 | 45.8 |
| zip | 5 | 0.9476 | 0.9049 | +5% | 15.7 | 45.1 |
| xlsx | 6 | 1.0032 | 0.9055 | +11% | 18.9 | 57.3 |
| audio | 1 | 1.0049 | 0.9631 | +4% | 18.4 | 59.9 |
| gzip-control | 1 | 1.0039 | 1.0001 | +0% | 20.4 | 69.9 |
| random-control | 1 | 1.0036 | 1.0001 | +0% | 20.9 | 74.8 |
CSV and JSON are the codec's best cases and still trail xz by a wide margin; random, zip, xlsx, and already-compressed inputs compress to ~1.0 (the literal-run escape keeps them from expanding much past 1.0). Peak memory (CLI, file-to-file, burpsuite-src.zip, 13.7 MB in): decode 41.1 MiB maxrss, encode 53.7 MiB maxrss.
Format
One file, one stream. Header is 40 bytes, magic CL4A (rANS) or
CL4H (Huffman); the parameters (W, L, flags, literal-run and
reset settings) are stored in the header, so decompression needs no
flags. Older CMPD/CMPH/CMPA files (pre-literal-run) still
decode. The token stream and the compressed bytes are byte-identical
to the research binary rsi18 run with the explicit promoted flags.
Limitations (read before using)
- Ratio is ~32% behind xz. If size is what matters, use xz.
- Single-threaded. No parallel encode/decode.
- Whole file in memory. Input, compressed, and output buffers coexist; the ~54 MiB burpsuite encode peak is the price.
- 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.
- No streaming, no archive format, no integrity checksum beyond the round-trip itself. This is a codec, not a file format.
- Research-grade. The code is a single 2,300-line C file grown by eighteen research rounds; the comments document each round's reasoning, including the dead ends.
Verify it yourself
make test # 54 checks: 44 corpus round-trips (byte-exact),
# 3 byte-identical vs rsi18+r3s12, 4 cross-compat
# (old decodes new, new decodes old), hello/random/empty
make bench # reproduces the table above
Source
- Codec:
rsi.c(rsi18.c + CLI front end; the diff is defaults, usage text, subcommands, and theRSI_*env names — no codec change) - Research loop:
../ROUNDLOG.md,../rsi18.c,../results/ - Upstream ideas: the fftdict study (token-entropy ceiling 0.7180), compdict/rANS