130 KiB
RSI round log
One entry per round: the idea tried, the numbers (ratio + speed vs references, per file type where relevant), the verdict, and what changed in the research process itself for the next round. Then the next round starts.
Baselines (all-44, size-weighted): xz -6 0.5399, lzply -e7 ~0.540, zstd-19 ~0.556, comp16 legacy 0.9560, comp16 + rANS P=20 (W16-L64) 0.7530, token-entropy ceiling 0.7180.
Round 1 — literal-run escape tokens in the compdict token stream (CLOSED, WIN, small)
- Idea. The token stream is the limit, and its worst failure is incompressible regions: a random byte costs eight 1-bit tokens at up to 16 bits each (comp16 1.37 on random.bin; rANS only recovers to 1.09). When the longest match at the current position is shorter than a threshold, emit one LIT token + one length token and copy the raw bytes to a side payload (8 bits each + ~2 tokens amortised over the run).
- Implementation.
rsi1.c, fork of compent.c. Token value 2 reserved as LIT; length token follows (1..255 bytes); payload appended after the coded token stream; new magics CLTH/CLTA with 34-byte header.--lit N(threshold bits, 0 = off = exact compent control). No dictionary learning inside a run; prev cleared after a run. - Bugs found and fixed before any sweep. (1) Code as delivered did not
compile: the preserved compdict header comment was missing its opening
/*(line 35). (2) Duplicatesize_t posindecompress_huff_mem(leftover from the lit-header branch). (3) Cold-start swallow: with a cold dictionary every match is 1 bit, so the first literal run swallowed whole files — first sweep scored 1.0010 on all 6 configs. Fixed with a warm-up gate: no literal run until the dictionary has learned >= 1024 entries. (4) 1–2 byte runs: the trigger fired on a single position's match length, but the next byte boundary usually matched long, so runs averaged ~2 bytes, cost 2 tokens each, and broke the composition chain (second sweep 0.9282–0.9688, worse than control everywhere). Fixed with--minrun N: the forward probe must reach N bytes or the encoder falls through to the ordinary token path and keeps learning. - Control.
--ans -w 16 -L 64 --comp --var --lit 0reproduces the comp16 rANS baseline exactly: 0.7530 (44/44 files, 48,144,974 bytes, enc 13.4 MB/s, dec 59.5 MB/s). L128 control also run to isolate the L effect:--lit 0 -L 128= 0.7548 (L128 alone does NOT help). - Numbers (best config).
--ans -w 16 -L 128 --comp --var --lit 18 --minrun 48→ 0.7274 overall, enc 8.6 MB/s, dec 125.1 MB/s, gap to xz +34.7% (control +39.5%). That is −0.0256 absolute (−3.4% relative) vs the 0.7530 control. 20,832,389 of 48,144,974 bytes literal (43.3%), 156,898 runs. - Sweep neighbourhood (flat basin, ±0.002): lit16-mr48-L128 0.7363, lit20-mr48-L128 0.7306, lit22-mr48-L128 0.7361, lit14-mr48-L128 0.7522, lit18-mr32-L128 0.7299, lit18-mr64-L128 0.7289, lit18-mr96-L128 0.7318, lit18-mr48-L64 0.7323, lit16-mr16-L64 0.7449, lit8-mr16-L64 0.7530 (= control: at thresh 8 with min-run 16 the escape almost never fires).
- Per-type, best vs control: random 1.0925→1.0027, gzip-control 1.0878→1.0027, xlsx 1.1475→1.0031, audio 1.0695→1.0023, zip 1.0094→0.9736, jpeg 0.9839→0.8221, bmp 0.9298→0.8377, ppm 0.8541→0.8026, csv 0.5136→0.5086, json 0.3567→0.3094 (L128 effect, 0% lit), c-source-bundle 0.4507→0.4401, elf 0.8613→0.8530. Regressions: c-source 0.6570→0.7242 (13.3% of bytes literal — the escape fires inside C source and breaks the chain), text 0.5026→0.5073.
- Round-trip.
make test21/21 OK; winning config verified by hand on random.bin, warandpeace.txt, burpsuite-src.zip, gen-sales.xlsx, bch.c (compress → decompress → cmp identical). - Verdict. WIN, small. First RSI advance: 0.7530 → 0.7274. The escape does exactly what the measurements predicted on incompressible types, and the decode-speed side effect is real (59.5 → 125.1 MB/s: literal bytes bypass token decode). But 0.7274 is now within 0.0094 of the comp16 token-entropy ceiling (0.7180) — this mechanism is nearly exhausted. Cost: encode slowed 13.4 → 8.6 MB/s (forward probe at every candidate position). The remaining gap to xz is the token stream itself, as the program concluded. Not merged anywhere; draft only.
- Process change. (1) Build +
make test+ control reproduction BEFORE any sweep — the delivered code did not compile, and the first two sweeps were both broken in ways only visible in the numbers. (2) A trigger that fires on one position's match length is not a region test: any future escape/switch rule must be validated by a forward probe with a minimum-run (or minimum-win) criterion. (3) Verify the winning config by hand round-trip on real corpus files, not just--bench(bench PASSes, but a hand check is the backstop). (4) Sweep one dimension at a time around the winner and isolate confounds with a control at the same L (L128 control caught here).
Round 2 — learn dictionary entries inside literal runs (CLOSED, NEGATIVE as a robust advance)
- Idea. Round 1 froze the dictionary inside literal runs, so structure repeating inside a run (XML tags in stored zip/xlsx regions, filenames) was never learned, and the token path after a run started from a stale prev. If encoder AND decoder both learn entries from the payload bytes as they pass through, runs self-terminate when a region turns compressible and the token path after a run starts warm. Same mechanism was expected to shrink the c-source regression (0.6570→0.7242).
- Implementation.
rsi2.c, fork ofrsi1.c. Virtual-token walk over each run's bytes: longest-match steps advancing by the match length (min 8 bits/step), one comp add per step (concat(vprev, cur)with --comp,concat(cur, next bit)with --no-comp), gated by--learnlen(only virtual tokens >= learn_len bits add an entry). Post-runprev= last virtual token (warm chain). Decoder mirrors the walk over the payload and maintains a trie on every add (real + virtual) so its longest-match agrees with the encoder's. Header flags bit 3 = learn, bits 4-7 = learn_len (0..15), lit path only.--learn 0reproduces Round 1 exactly (verified: 0.7274, per-file ratios/tokens/lit identical). New knobs:--learn 0/1,--learnlen 0..15,--litmax 1..255(run-length cap). - NOT implemented: early run termination. Proved impossible
single-pass: the decoder cannot evaluate a "match >= thresh at boundary
B" probe without the post-run bytes, and any walk step whose match is
truncated by the run end computes a different longest match on the two
sides (encoder cap = probed end, decoder cap = final end). Needs a
two-pass design with a rollback journal; deferred.
--litmaxwas the cheap proxy tested instead (failed: shorter runs = more LIT pairs + more token-path bytes, 0.7410 at lm64 vs 0.7382). - Control.
--lit 0reproduces 0.7530 exactly;rsi2 --learn 0reproduces the Round 1 best 0.7274 exactly (44/44, byte-identical output totals). - Numbers (headline,
--ans -w 16 -L 128 --comp --var). Learning at the Round 1 best (--lit 18 --minrun 48) HURTS, monotonic in the gate: learnlen 0 → 0.7462, 4 → 0.7455, 8 → 0.7434, 12 → 0.7382, 15 → 0.7262 (enc 6.8, dec 22.0 MB/s). The learned dictionary matches just well enough inside incompressible regions to pull bytes out of the cheap literal path into the expensive token path: runs 156,898 → 219,906, lit bytes 20.8M → 19.2M (learnlen 12); random 1.0027→1.0419, audio 1.0023→1.0454, xlsx 1.0031→1.0240. But it DOES fix the c-source regression as predicted (0.7242→0.6890 at learnlen 12, 0.6961 at 15). Best config found:--reset --lit 20 --minrun 48 --learn 1 --learnlen 15→ 0.7220 overall, enc 6.0 MB/s, dec 17.3 MB/s, gap to xz +33.7% (Round 1: 0.7274, enc 8.6, dec 125.1, +34.7%). Neighbourhood is SHARP, not a basin: lit19 0.7249, lit21 0.7331, lit16 0.7363, lit22 0.7415, mr40 0.7306, mr56 0.7372, learnlen 13+reset 0.7273, 14+reset 0.7320, L64 0.7539, lit20 without reset 0.7265. - Why 0.7220 is not a win. The entire net improvement comes from ONE file: covid-countries.csv 0.5674→0.3650 (5.5 MB, ≈ −1.1 MB) while the overall net is only ≈ −260 KB. Ex-covid overall: Round 1 0.7481 → winner 0.7682 (+0.020 WORSE). Per-type, winner vs Round 1: csv −0.055 (all covid; other CSVs flat), zip −0.012, jpeg −0.020, but text +0.048 (warandpeace 0.4198→0.4756), c-source-bundle +0.049 (0.4401→0.4893), json +0.040 (0.3094→0.3490). Decode speed collapses 125.1 → 17.3 MB/s (decoder trie maintenance on every add).
- Mechanism findings (real, reproducible). (1) Learning rescues
reset:
--resetwith NO learning scores 0.7848 (post-reset the dict is cold, the warm-up gate blocks runs, incompressible bytes pay the token-path price); reset+learn is 0.7236–0.7272 — the walk re-teaches the dictionary from run bytes, so runs resume quickly after a reset. (2) The covid win needs BOTH: reset alone 0.8576 (worse), learn alone 0.5674 (flat), together 0.3650 — reset lets the dict re-adapt to a repetitive file's later regions, learning rebuilds it fast. (3) Reset hurts varied text/code even with learning (warandpeace/c-bundle/json all worse than Round 1 under every reset config) — the old dictionary still matches well there, and the cold post-reset period costs more than re-adaptation saves. - Round-trip.
make testgreen (rsi1 21 checks + rsi2 learn round-trips huff/ans, learnlen 0/4/8/12, random 100 KB). Winning config verified by hand on random.bin, warandpeace.txt, burpsuite-src.zip, gen-sales.xlsx, bch.c, covid-countries.csv, easylist.txt (ans) + gen-sales.xlsx (huff) — all byte-identical. - Verdict. NEGATIVE as a robust advance. Headline 0.7274 → 0.7220, but single-file-driven, sharp-optimum, and 7x slower to decode. The config is NOT promoted as the new best; Round 1's 0.7274 (no reset, no learn) stands. The durable results are the three mechanism findings above, which point directly at Round 3: the reset decision must be adaptive, not unconditional-on-fill.
- Process change. (1) Always report the ex-largest-file overall alongside the headline: a win carried by one file is not a win. (2) Sweep the reset interaction explicitly whenever a mechanism touches dictionary state — reset alone, mechanism alone, both — the three-way split is what attributed the covid effect. (3) A sharp optimum (neighbours worse on both sides, some much worse) is a corpus-overfitting smell: record the neighbourhood table, do not trust the peak. (4) When a mechanism changes decoder cost structurally (trie maintenance), report decode speed next to the ratio in the headline, not as an afterthought.
Round 3 — adaptive (staleness-gated) dictionary reset (CLOSED, WIN, small, qualified)
- Idea. Round 2 showed reset is a win on repetitive, drifting content
(covid 0.5674→0.3650 with reset+learn) and a loss on varied content
(warandpeace 0.4198→0.4756, c-bundle 0.4401→0.4893, json 0.3094→0.3490)
— reset helps only when the dictionary has gone STALE. Gate the reset
on staleness instead of firing it unconditionally when the dictionary
fills: reset only if the trailing-mean match length (bits, over the
last
--stalewintoken-path matches + virtual-walk steps) is below--stale. Learning (Round 2) stays on as the post-reset re-teacher. Secondary target: decoder speed (125→17 MB/s from trie maintenance). - Implementation.
rsi3.c, fork ofrsi2.c. Trailing-mean tracker inDict(ring buffer, integer comparisonsum < thresh * n, no float). Both sides update at mirrored points with identical values (token path: encoderbest_len/ decoderL = ent[idx].len, incl. the no-comp lag case whereL = lp+1equals the encoder'sbest_len; walk:vlfromlongest_matchon the same bytes; LIT tokens and probes never update), so the gate can never desync the dictionaries. Three reset paths: (a) fill/fire-point gate (dict_reset_gated: fire if stale, else skip and setstale_armed); (b) continuous re-check at each token-loop top and each walk step while armed, firing the deferred reset the moment the mean drops below the threshold; (c) the no-comp armed fire is gated at fire time, matching the decoder's lagged fill point (same token prefix). New magics CLSH/CLSA, 37-byte header (stale params after D). The legacy CMPD fill points route through the same gated helper; with stale off it is exactly the old unconditional reset, so legacy behaviour is unchanged (--stalerejected with--legacy/--lit 0). Bench printsstale_thresh/stale_win/stale_fills/stale_skips. Bug found and fixed during the round: a mid-walk re-check reset setvprev = -1, but the step'svprev = vioverwrote it, leaving a stale pre-reset index as prev for the next step's add. Fixed by routing the re-check through the samerstflag the fill-reset uses. Verified no-op: the s12 TSV after the fix is byte-identical to before except the speed columns (unreachable at learnlen 15 — a cold dict cannot produce a ≥15-bit match — but the hazard was real for any future learnlen sweep). - Control.
--lit 0reproduces 0.7530 exactly;--learn 0 --lit 18 --minrun 48 -L 128reproduces the Round 1 best 0.7274 exactly;--reset --lit 20 --learn 1 --learnlen 15reproduces the Round 2 winner 0.7220 exactly (all 44/44, byte-identical round-trips). All three re-run after the walk fix: unchanged. - Numbers (best config).
--ans -w 16 -L 128 --comp --var --reset --lit 20 --minrun 48 --learn 1 --learnlen 15 --stale 13 --stalewin 256→ 0.7054 overall, ex-covid 0.7393, enc 6.9 MB/s, dec 21.7 MB/s, gap to xz +30.6% (Round 1: 0.7274, enc 8.6, dec 125.1, +34.7%). Nominal config--stale 12→ 0.7124, ex-covid 0.7405; the 12↔13 difference is covid timing noise, not a tunable optimum (see below). - Threshold sweep (win 256, lit20/learn15/reset base). s4 0.7265, s8 0.7226, s10 0.7213, s11 0.7465, s12 0.7124, s13 0.7054, s14 0.7231, s16 0.7339, s24 0.7087, s32 0.7494. Threshold ±1 swings the headline by up to ±0.03 — the reset timing is a chaotic dynamical system (each reset re-anchors the dictionary, changing all subsequent match lengths and the next reset time). There is no flat basin: do NOT trust the 0.7054 peak as a tunable optimum.
- Ex-covid is the robust signal. Ex-covid overall by threshold: s4 0.7464, s8 0.7420, s10 0.7405, s11 0.7406, s12 0.7405, s13 0.7393, s14 0.7396, s16 0.7382, s24 0.7511, s32 0.7606 — vs Round 1 best 0.7481 and Round 2 winner 0.7682. The gate improves the 43-file corpus by ~0.008–0.010 at every threshold in 4–16, and the headline chaos is entirely covid (0.5725 at s4/s8/s10, 0.7913 at s11, 0.4948 at s12, 0.4427 at s13, 0.5952 at s14, 0.7001 at s16, 0.3806 at s24, 0.6620 at s32; baselines 0.5674 no-reset, 0.3650 unconditional-reset). Attribution of the s13 headline gain vs Round 1 best (−1.06 MB): covid −687 KB (65%, lottery), gen-mixed-l0.zip −235 KB (22%, robust, see below), everything else −138 KB. Ex-covid-ex-gen-mixed-l0: 0.7496→0.7464 (s13), 0.7496→0.7476 (s12) — the bulk of the corpus is roughly a wash vs no-reset, with small wins and losses cancelling.
- Per-file, s13 vs Round 1 best (≥0.01): gen-mixed-l0.zip 0.6592→0.3444, covid 0.5674→0.4427, photo.jpg 0.8221→0.8021, burpsuite-src.zip 0.9859→0.9713; losses: easylist 0.6239→0.6343, default-passwords.csv 0.7705→0.7815, frankenstein 0.5543→0.5733, c-bundle.c 0.4401→0.4652. Per-type s13 vs Round 1 best: csv 0.5086→0.4525, zip 0.9736→0.9476, text 0.5073→0.5097, json 0.3094→0.3095, c-source 0.7242→0.7216, c-source-bundle 0.4401→0.4652.
- Mechanism findings (real, reproducible). (1) The fill-gate almost never fires at the fill: fills≈skips on every file (e.g. covid s13: 8 fills, 8 skips, 8 resets — all 8 resets came from deferred re-checks). At a fill the trailing mean is usually still high; the reset happens later, when the mean drops — the continuous re-check, not the fill gate, does the work. (2) The gate robustly finds the ONE good reset on gen-mixed-l0.zip: 0.6592→0.3444 at every threshold ≥8 and every window (64/256/ 1024), while unconditional reset (1 reset, wrong time) scores 0.6688 and no-reset 0.6592 — one well-timed reset + fast re-learn beats no reset by −0.31 on a mixed stored zip. At s4 (thresh too low to ever fire) it stays 0.6590. (3) The gate robustly suppresses harmful resets on text: warandpeace 14 resets→0 at s12/s13 (ratio 0.4756→0.4174, beating no-reset's 0.4198 — learning helps once resets stop interfering), moby-dick 5→1 (0.5953→0.5046) at thresh 4–16; both degrade as the threshold rises (s32: warandpeace 12 resets→0.4705, moby-dick 5→0.6074). (4) Easylist is the one file the gate consistently hurts vs no-reset (0.6239→0.63–0.66 at most thresholds; only s24/s32 match unconditional reset) — many literal runs there, possibly mid-run re-check resets at bad times. (5) Decoder speed NOT fixed: 21.7 MB/s (Round 1: 125.1, Round 2 winner: 17.3). The trie is confirmed as the cost: gate-alone without learn decodes at 128.3 MB/s (no trie maintenance), with learn at ~20 MB/s.
- Three-way split (reset interaction). Reset alone, no learn
(Round 2): 0.7848. Gate alone, no learn (
--reset --lit 20 --learn 0 --stale 12): 0.7396, ex-covid 0.7516, dec 128.3. Both (gate+learn, s12): 0.7124, ex-covid 0.7405, dec 20.9. As in Round 2, the mechanism needs learning to help; the gate's job is to make reset+learn viable by removing most of reset's harm (0.7220→0.7124 headline, 0.7682→0.7405 ex-covid vs unconditional reset+learn). - Window / base legs. At stale 12: win 64 → 0.7099 (ex-covid 0.7471, covid 0.4225), win 256 → 0.7124 (0.7405), win 1024 → 0.7168 (0.7400) — window is not the sensitive knob. Lit18 base + gate → 0.7202 (ex-covid 0.7430); lit20 stays the better base, as in Round 2.
- Round-trip.
make testgreen (rsi1 21 + rsi2 + rsi3 checks, incl. stale 0/8/16 ans, no-comp stale 12, huff stale 12 win64). Winning config verified by hand in file mode (CLSA magic) on random.bin, warandpeace.txt, burpsuite-src.zip, gen-sales.xlsx, bch.c, covid-countries.csv, easylist.txt, gen-mixed-l0.zip — all byte-identical. s13 and s24 re-run with the fixed binary: identical ratios (0.7054 / 0.7087). - Verdict. WIN, small, qualified. The gate is a real advance
over unconditional reset (broad-based vs the Round 2 winner) and
a small robust advance over the Round 1 best ex-covid
(0.7481→0.739–0.741 across thresh 8–16, gen-mixed-l0 −0.31 at
every threshold ≥8, text resets suppressed). It is PROMOTED as
the new best config — nominal
--stale 12 --stalewin 256(0.7124), best measured--stale 13(0.7054) — with the qualification recorded in full: the headline peak is not tunable (chaotic threshold response via covid), 55–65% of the headline gain is the covid lottery, the bulk of the corpus is roughly a wash vs no-reset, easylist/c-bundle regress, and decode is still ~21 MB/s. The next round should attack the covid timing chaos directly (Round 4), not re-sweep the threshold. - Process change. (1) When a mechanism's headline moves on a
threshold sweep, report the ex-largest-file AND ex-second-file
overalls: Round 3's headline was two-file-driven (covid +
gen-mixed-l0), and only the second exclusion showed the bulk of
the corpus is a wash. (2) A chaotic threshold response (±1
swinging the headline ±0.03) is itself a finding: record the
full sweep table, promote the middle of the robust ex-file band
rather than the peak, and never re-sweep a chaotic knob hoping
for a better peak. (3) Count WHERE resets come from, not just
how many: fill-gate fires vs deferred re-check fires
(
stale_fills/stale_skipsvsresets) distinguished the mechanism here (re-checks do the work; the fill gate almost never fires). (4) Fix latent-correctness hazards when found even if unreachable in the current sweep — and verify with a before/after TSV diff that the fix changed nothing but speed.
Round 4 — sustained-staleness (hysteresis) reset timing (CLOSED, NEGATIVE)
- Idea. Round 3's gate fires a deferred reset the moment the
trailing mean dips below the threshold — one dip, one reset — and on
repetitive files the reset time is chaotic (covid 0.38–0.79 across
±1 of threshold). Require SUSTAINED staleness instead: reset only
after the trailing mean has stayed below the threshold for M
consecutive observations (
--stalemrun), and/or enforce a minimum token gap between resets (--stalemingap). A single dip caused by one literal run or one odd region should not re-anchor the dictionary; a genuinely stale dictionary stays stale. Target: covid stable near its best (~0.38–0.44) instead of lottery, with the ex-covid band (0.738–0.741) held. Secondary target (still open): decoder speed — the trie costs 128→20 MB/s. - Implementation.
rsi4.c, fork ofrsi3.c(mechanical transform/tmp/make_rsi4.py, assertion-counted replacements + diff review).Dictgainsstale_run(consecutivestale_updatecalls with the trailing mean below threshold),stale_since_reset(updates since the last reset fired),stale_mrun,stale_mingap,stale_hyst_skips(fill-gate blocks). Both counters are pure functions of the mirroredstale_updatesequence + resets, so encoder/decoder lockstep holds exactly as in Round 3;dict_resetclears the counters but NOT the trailing-mean history (Round 3 semantics preserved).stale_hyst_okgates bothdict_reset_gatedandstale_recheck. New magics CL4H/CL4A, 40-byte header (mrun at byte 37, mingap LE16 at 38–39).--stalemrun 0 --stalemingap 0reproduces Round 3 exactly (verified in controls). Makefile gainsrsi4target + round-trip tests (ans/huff, no-comp, mrun 0/1/4/16/64, mingap 256/1024, random 100 KB). - Control. All five reproduce exactly on rsi4:
--lit 0→ 0.7530; Round 1 best (--learn 0 --lit 18 --minrun 48) → 0.7274 (ex-covid 0.7481, dec 117.5); Round 2 winner → 0.7220 (ex-covid 0.7682, dec 17.1); Round 3 nominal (--stale 12 --stalewin 256, mrun/gap 0) → 0.7124 (ex-covid 0.7406, covid 0.4948, 6 resets, dec 21.3); Round 3--stale 13→ 0.7054 (ex-covid 0.7393, covid 0.4427, 8 resets, dec 21.0). (Ex-covid 0.7406 vs the Round 3 log's 0.7405 is 4th-decimal TSV rounding.) - Numbers (base: Round 3 nominal,
--ans -w 16 -L 128 --comp --var --reset --lit 20 --minrun 48 --learn 1 --learnlen 15 --stale 12 --stalewin 256→ 0.7124, ex-covid 0.7406, covid 0.4948, 6 resets, enc 6.9, dec 21.3).- mrun sweep (mingap 0): mr2 0.7148 (ex-covid 0.7408, covid 0.5138, 5 resets), mr4 0.7153 (0.7406, 0.5198, 4), mr8 0.7170 (0.7406, 0.5341, 3), mr16 0.7158 (0.7399, 0.5294, 3), mr32 0.7176 (0.7406, 0.5399, 3), mr64 0.7191 (0.7399, 0.5587, 3). Dec 21.1–21.6 throughout.
- mingap sweep (mrun 0): 256 / 1024 / 4096 / 16384 / 65535 all
0.7124 byte-identical to base (covid 0.4948, 6 resets,
hyst_skips 0). 65536 / 131072 never ran: the CLI rejects mingap
65535 (header field is uint16) — all 44 files FAIL at usage(), a harness limit, not a codec result.
- stale 13 + mrun: mr4 0.7109 (ex-covid 0.7407, covid 0.4807, 5 resets) vs s13 base 0.7054 (covid 0.4427, 8 resets); mr16 0.7407 (ex-covid 0.7406, covid 0.7410, 4 resets) — the entire +0.035 headline regression is covid alone.
- Gate-alone + mrun 8 (learn 0): 0.7278 (ex-covid 0.7516, covid 0.5444, 2 resets, dec 119.3) vs Round 3 gate-alone 0.7396 (ex-covid 0.7516, dec 128.3) — headline gain is covid only; ex-covid identical; vs Round 1 best 0.7274 it is a wash.
- Per-file: gen-mixed-l0.zip 0.3444 at every mrun (0.3422 at mr32/64); warandpeace 0.4174 / 0 resets at every config; moby-dick 0.5046 everywhere; easylist 0.6461–0.6633 (base 0.6593). No-learn easylist 0.7914 / frankenstein 0.6182 — learning matters there.
- Mechanism findings (real). (1) Hysteresis delays resets and
covid gets WORSE at every setting on both thresholds — the delay
does not stabilise timing, it moves the reset off the lucky
anchor. (2) Ex-covid is flat across the whole sweep
(0.7399–0.7408 at s12, 0.7406–0.7407 at s13): the other 43 files
do not care about reset timing at this scale at all. (3)
stale_hyst_skips= 0 in EVERY run, including mr64: with window 256 the mean moves slowly, so whenever it is stale at a fill the run is already long — the fill gate is never the binding gate. The delay bites only in the uncounted recheck path (resets 6→3 as mrun grows, all from rechecks). (4) mingap as designed can never bind: resets average ~270k observations apart on covid (1,629,126 tokens, 6 resets) and the fill interval itself is ~65k adds — both dwarf the uint16-capped mingap (max 65535). The knob is vacuous at every representable value. (5) Decode speed untouched, as expected: 19.9–21.6 MB/s with learn on, 119.3 gate-alone — hysteresis adds no decode cost and fixes none; the trie is still the cost. - Round-trip.
make testgreen (rsi1–rsi4). Winning config N/A (no winner); hand file-mode (CL4A magic) round-trips pass for--stalemrun 8 --stalemingap 256(ans) on random.bin, warandpeace.txt, burpsuite-src.zip, gen-sales.xlsx, bch.c, covid-countries.csv, easylist.txt, gen-mixed-l0.zip, plus covid in huff with mrun 16 / gap 1024 — all byte-identical. Every bench tag is 44/44 with roundtrip PASS (aggregate only counts PASS logs). - Verdict. NEGATIVE. Sustained-staleness does not stabilise
covid-countries.csv; it perturbs reset timing and covid gets
worse monotonically-ish with the delay (s12: 0.4948→0.5587 at
mr64; s13: 0.4427→0.7410 at mr16), while ex-covid never moves.
The covid reset effect is timing chaos, not a tunable: threshold
±1 (Round 3), delay +4–16 observations (Round 4), all swing
covid by up to ±0.3 while the other 43 files sit still. The
promoted best stays Round 3 nominal
--stale 12 --stalewin 256(0.7124, ex-covid 0.7406). The hysteresis knobs stay in the tool (mrun 0 = Round 3) but are not promoted. Decoder speed remains open and becomes Round 5. - Process change. (1) When a knob's effect is confined to one file, test it at TWO base configs before concluding — s13mr16 (ex-covid flat, covid 0.44→0.74) was the decisive datum, not the s12 sweep. (2) Check a new knob's natural scale against the system's own intervals BEFORE sweeping: mingap in observation units is dominated by the fill interval (~65k adds) and the reset spacing (~270k on covid) — sweep values must straddle those scales or the sweep is vacuous, and the uint16 header field caps mingap below both, so the knob as designed can never bind; record the scale analysis first. (3) Count blocks at EVERY gate, not just the fill gate: hyst_skips = 0 everywhere looked like "hysteresis never fires" until the reset counts showed the delay bites in the uncounted recheck path — instrument the path that actually fires the resets. (4) A CLI validation cap is a sweep hazard: mg65536/131072 failed all 44 files at usage() — check the cap before launching a sweep leg, and treat all-FAIL tags as harness failures, never as results.
Round 5 — decoder speed, profile-first (CLOSED — WIN)
- Idea (from Rounds 3–4: the open secondary target). With
learning on, decode runs at ~20 MB/s; gate-alone (no learn) at
~128 MB/s, and Round 1 (no learn, no reset) at 125 MB/s. The
trie is the suspected cost, but two rounds have asserted that
without measuring WHERE the decode time goes. Profile first:
break decode time down (rANS/Huffman token decode vs
token-path trie inserts vs walk
longest_matchvs walk trie inserts) on covid-countries.csv + warandpeace.txt, then implement the cheapest fix the profile points at. Constraint: the decoder trie must contain exactly the entries the encoder's trie contains (it is a search index, not optional state — a missing entry changeslongest_matchand desyncs the walk), so a valid fix preserves the trie ENTRY SET and the match results; only the representation / redundant work may change. Success criterion is crisp: ratios must be IDENTICAL to the Round 3 nominal (0.7124 / ex-covid 0.7406) — any ratio change is a desync bug, not a speedup — with decode materially faster. Queued alternative if profiling shows the trie is not the bottleneck: clear the stale history on reset (Round 3/4 deliberately preserved it; untested variant) and/or a two-threshold Schmitt gate on the mean itself. - Implementation sketch. Instrument a scratch copy (or
perf) for the phase breakdown; candidate fixes depend on the profile (e.g. faster trie representation, skipping the duplicate-walk for entries already present, cheaperlongest_matchin the walk). Keep the token stream identical. - Profile (gprof; no
perfon hot_house). covid+warandpeace decode: token loop 38% / token-path trie inserts 34% / rANS 22% / walklongest_match0.7%.longest_matchis 66.85% of TOTAL time but almost all from the encoder. burpsuite+audio+ghidra (literal-heavy): walklongest_match= 81.5% of all time, 12.43s of 15.08s decode (82% of decode). Corpus-wide decode-time share: burpsuite-src.zip 43.6% of all decode time (1.10s of 2.53s); the walk is ~55-65% of all decode time. Per-step cost ~80ns (trie dense to depth ~16, ~16 bit-steps perlongest_matchcall, one call per literal byte; burpsuite 12.5M virt_steps, 287K virt_adds, 12.8M lit bytes). dup_adds tiny (covid 958, warandpeace 11) -- (prev,idx) pairs essentially never repeat, killing the pair-hash idea. - Fix: decoder-only 16-bit prefix table (
best16,rsi5.c). One 65536-entry int32 table (-1 = none); first entry with a bitstring wins, matching the trie's first-wins rule; maintained intrie_insert_dec(the single funnel for all decoder inserts).longest_match_declooks up pfx16 -> trie node index at depth 16, then continues the bit-walk from there; table path only when >=24 bits remain, else plainlongest_match. Encoder untouched, so ratios cannot change; a table bug can only desync the walk and fail the round-trip memcmp. FORMAT UNCHANGED from rsi4: same magics CL4H/CL4A, same 40-byte header, so rsi4 and rsi5 files decode interchangeably. - Numbers. Controls on rsi4 (tags
r5-ctl-*): lit0 0.7530, r1best 0.7274, r2win 0.7220, s12 0.7124, s13 0.7054 -- all exact. Controls on rsi5 (tagsr5s-ctl-*): same five, exact; 0 FAIL/MISMATCH across all tags. Quiet paired A/B (tagsr5q-*, sequential, load ~0.5): s12 dec 21.3 -> 40.4 MB/s (1.90x), s13 21.1 -> 39.8 (1.89x); an earlier quiet run measured 41.3/1.95x -- headline ~1.9x. 0 ratio mismatches and 0 token-count mismatches across all 44 files, both configs. Encode unchanged (6.9 -> 6.8 MB/s). Per-file: literal-heavy files 3-4.2x (wpgz 4.18x, random 3.96x, ghidra 3.90x, audio 3.73x, burpsuite 3.25x); low-lit files ~1.0x.make testgreen (45 round-trip OKs incl. rsi5 checks + rsi4<->rsi5 cross-compat). Hand file-mode check 8/8 PASS (CL4A): random.bin, warandpeace.txt, burpsuite-src.zip, gen-sales.xlsx, bch.c, covid-countries.csv, easylist.txt, gen-mixed-l0.zip. - Small-file regression (real, open). gen-log 0.67x, gapminder 0.66x, stocks ~0.8x -- consistent 6/6 across three spot-checks on a quiet machine. A per-length prefix-table revision (bestL, one table per entry length, O(1) insert) was tried and REVERTED: it gave only 1.18x overall (burpsuite 1.31x vs best16 3.25x) because the scan does (17-vl) reads where best16 does one, and it did NOT fix the three files. A nop bisection binary (tables allocated but never used) is just as slow on them, so the regression is NOT the table maintenance or the table walk path. first16 is cheap (fast path 2 loads, gprof ~6ns/call); bestL/best16 alloc+memset is ~65us per decode call (too small); rebuilt rsi4 from clean gives the same numbers (not a stale binary). Remaining suspect is code layout / inlining (rsi5 decompress_tokens has 3 trie_insert_dec + 4 first16 call sites vs rsi4's 2 + 0; trie_insert_dec grew 0xd6 -> 0x141 bytes). Aggregate cost ~6ms per full-corpus decode vs ~1100ms saved.
- Verdict. WIN. Promoted best stays Round 3 nominal (0.7124 / ex-covid 0.7406) with decode 21.1 -> ~40 MB/s (~1.9x). rsi5 is the new decoder; rsi4 kept as the control binary.
- Process change. Profile-first worked (the walk, not the inserts, was the cost on literal-heavy files). The nop-bisection discipline caught a misdiagnosis: the best16 fan-out was real (measured 212K iterations / 165K writes on gen-log) but NOT the cause of the small-file regressions -- keep a scratch bisection binary in the loop before rewriting a design on a measured cost. Quiet-machine A/B is the honest number (parallel bench_all dec speeds are load-confounded: s12 24.7 there vs 40.4 quiet).
Round 6 — small-file regression + token-path inserts (CLOSED, NEGATIVE on the fix)
- Idea. Round 5 closed with decode ~1.9x faster but three
small files 20-35% slower (gen-log 0.67x, gapminder 0.66x,
stocks ~0.8x). First find the cause (bisection variants A/B/C/E/F
- exact counters + a decode-only driver loop), then fix it. Second target if the regression resolves: token-path trie inserts (34% of decode on compressible files). Third: encoder-side prefix table -- encode 6.9 MB/s is now the bottleneck vs decode ~40 MB/s. Still queued and untested from Round 5: clear stale history on reset / two-threshold Schmitt gate.
- Success criterion. Ratios identical to Round 3 nominal (0.7124 / ex-covid 0.7406); decode not slower than rsi5 on any file class.
- Status. Closed Dec 4 ~22:30 EST. No promotion; rsi5 stands.
- Numbers. Quiet A/B, rotated orders, medians of 3 (NOM =
--ans -w 16 -L 128 --comp --var --reset --lit 20 --minrun 48 --learn 1 --learnlen 15 --stale 12 --stalewin 256 --stalemrun 0 --stalemingap 0):- Variant E / best16len (check3, load 0.61 flat): gen-log rsi4
63.9 / rsi6e 41.3 / rsi5 48.5; gapminder 15.2 / 9.0 / 10.1;
stocks 11.3 / 9.2 / 8.9 MB/s. Ratios identical 15/15.
best16len is WORSE than rsi5 on gen-log (-15%) and gapminder
(-11%). The
ent[cur].lencompare load was not the cause. - Variant C / reads-off (r6c-check, load 1.19): gen-log 59.4 / 45.0 / 41.9; gapminder 13.8 / 9.9 / 10.0; stocks 11.5 / 8.7 / 8.3; burpsuite rsi6c 13.3 (walk speedup gone, as designed). The walk-path table READS are innocent.
- Variant F / span-capped fan-out, len>=12 + bl<12 plain-walk fallback (r6f-check, load 0.55-0.59): gen-log 65.0 / 52.9 / 51.1; gapminder 15.3 / 9.2 / 9.3; stocks 11.8 / 9.5 / 9.0; burpsuite rsi6f 14.0 vs rsi5 43.9 -- the walk speedup is LOST. The cap did not restore the small files and killed burpsuite.
- Variant B / tables never allocated (r6b-check.log, prior agent, quiet): gen-log rsi6b 59-63 vs rsi4 65-68; gapminder 14.4-15.3; stocks 10.5-11.8; burpsuite 13.5. The tables' PRESENCE is the cause; layout is innocent (B has rsi5's identical code).
- Counters (rsi6h/rsi6hf, exact, per decode): gen-log inserts 17,858; fan-out iters 212,313 / writes 165,495 (reproduces Round 5's 212K/165K); node16 writes 4,579; walk calls 197 table + 11 plain. F cuts fan-out iters 98.8% (2,617) yet stays slow -- the fan-out WRITES are exonerated. F's bl<12 fallback fires on 166/197 gen-log walks (84%) and 10,728,248/12,375,113 burpsuite walks (87%): the table-path win comes overwhelmingly from SHORT matches, which is why the cap killed burpsuite. Resets: 0 on all three small files (dict never fills) -- the 512KB memset runs once per decode (~65us, ~1%), so the memset is exonerated too. Token streams rsi4 vs rsi5 byte-identical (tokens/dict_entries/lit_runs/ virt_steps all match); encoder untouched.
- Decode-only driver (2000 iters, -pg builds, quiet load 1.00): drv4 12.000 / drv5 11.758 / drvb 11.591 ms/iter -- NO gap in a hot loop (rsi4 ~= rsi5 ~= B). The bench gap does not come from steady-state decode work; it is a COLD-state effect (the bench interleaves a full encode before each decode, evicting caches). drvf 14.990 is load-suspect (load rose to 2.85 during its run), not a finding. gprof decode-only (load-contaminated, shares only): insert path ~31-32% of decode in ALL rsi5-family drivers incl. B vs 21% in rsi4, total insert+new_node ~46-51% everywhere -- no single function is the smoking gun; trie grows to ~517K nodes per gen-log decode (cap is only for entries).
- Direct-cost accounting vs measured gap, gen-log: the table machinery's direct cost is ~0.1ms/decode (one memset, ~7K stores, ~600 loads, first16) but the gap is ~1.6ms (rsi4 5.7ms vs rsi5 7.6ms). The missing ~1.5ms is a second-order (cache/TLB/cold) effect, not counted work.
- Variant E / best16len (check3, load 0.61 flat): gen-log rsi4
63.9 / rsi6e 41.3 / rsi5 48.5; gapminder 15.2 / 9.0 / 10.1;
stocks 11.3 / 9.2 / 8.9 MB/s. Ratios identical 15/15.
best16len is WORSE than rsi5 on gen-log (-15%) and gapminder
(-11%). The
- Verdict. NEGATIVE on the fix: neither best16len nor the span cap restores the small files, and the cap destroys the burpsuite speedup, so nothing is promoted and rsi5 stands as the decoder. Diagnosis advanced substantially: the cause is the tables' presence (variant B), with reads, fan-out writes, first16, and the per-reset memset all exonerated, and the gap shown to vanish in a hot decode loop -- the problem is now framed as a cold-start effect, not a steady-state cost. That reframes Round 7: quantify the cold start first (per-iteration timing driver), then test cold-start fixes before touching the insert path.
- Process change. Counter-first beat theory-first this round: the fan-out-write hypothesis died on exact counts (F cut 99% of the writes, stayed slow), and the hot/cold split only showed up in a purpose-built decode-only loop. Never trust a cost estimate (e.g. "memset ~65us") without the reset count beside it (0 here). Variant A stays uninterpretable: its wrong tables make the walk take many more 1-bit steps, so it cannot rule first16 in or out (B does rule first16 out -- B pays it and is fast). Keep every scratch variant + its check log in /tmp with the transform script mirrored in ~/workspace; the waiter + lean rotated check is now the standard quiet A/B.
Round 7 — cold-start cost of the tables + token-path inserts (CLOSED)
- Idea. Round 6 closed NEGATIVE on the fix but reframed the problem: the small-file regression is a COLD-state effect (no gap in a hot decode loop), not steady-state work. First quantify the cold start (per-iteration timing driver: iteration 1 vs steady state, rsi4/rsi5/B; then an encode-interleaved driver mimicking the bench). Then test cold-start fixes (candidates: lazy/generational table reset, smaller/leaner cold footprint, keeping the tables out of the first-touch path). Second target: token-path trie inserts (34% of decode on compressible files; gprof decode-only: insert+new_node ~46-51% of decode). Third: encoder-side prefix table -- encode 6.9 MB/s is now the bottleneck vs decode ~40 MB/s. Still queued and untested: clear stale history on reset / two-threshold Schmitt gate.
- Success criterion. Ratios identical to Round 3 nominal (0.7124 / ex-covid 0.7406); decode not slower than rsi5 on any file class; small files back to rsi4 speed.
- Status. CLOSED Dec 4 ~23:35 EST. No fix promoted; rsi5 stands.
- Numbers. All decode MB/s medians, nominal args
(
--ans -w 16 -L 128 --comp --var --reset --lit 20 --minrun 48 --learn 1 --learnlen 15 --stale 12), quiet rotated checks. Ratios identical for every variant (gen-log 0.2178, gapminder 0.6642, stocks 0.7281, covid 0.4948, burpsuite 0.9713);make testgreen (45 round-trip OKs, no failures).- drv7 (-pg, gen-log, load 1.25-1.67): mode 0 (hot loop, 2000 iters) drv74 11.459 / drv75 12.658 / drv7b 11.049 ms; mode 1 (re-compress, 200 iters) 11.179 / 11.379 / 12.112 ms. First5 ~13.5ms vs medians ~11.5ms: a ~2ms warmup ramp, bigger than the effect -- the run was too noisy to confirm/refute eviction.
- drv8 (non-pg, warmup discard, 5 rotated rounds, gen-log): first run (load 5.7->2.0, Qwen4 active) mode-1 rsi5 excess +1.75/+1.42/+0.83/+1.18/+2.20 (mean +1.48, 5/5 rounds); second run (load 1.2-1.8) mode-1 medians 4: 8.63 / 5: 8.80 / b: 8.82 / g: 9.03 ms (gap collapsed to +0.17). The driver gap appears under Qwen4 contention and vanishes when quiet -- the loop driver does NOT faithfully model the bench.
- G (lazy tables, dirty bitmaps, no 512KB sweep; r7g-check, load 1.2-1.8): gen-log 4: 69.4 / 5: 53.0 / b: 64.9 / g: 51.4; gapminder 4: 16.3 / 5: 9.7 / b: 14.5 / g: 9.3; stocks 4: 11.9 / 5: 9.4 / b: 11.3 / g: 8.7; burpsuite 4: 13.6 / 5: 43.9 / b: 13.5 / g: 41.7. G = rsi5 on small files (NOT fixed) but keeps the burpsuite speedup (-5%, bitmap RMW cost).
- K (alloc-only tables, never touched; r7k-check, load ~1.0): gen-log 4: 66.2 / 5: 51.4 / b: 63.8 / g: 50.1 / k: 55.2; gapminder 4: 15.0 / 5: 9.3 / b: 15.4 / g: 10.1 / k: 11.0; stocks 4: 12.3 / 5: 9.4 / b: 10.9 / g: 9.0 / k: 9.5; burpsuite 4: 13.7 / 5: 44.3 / b: 13.4 / g: 41.6 / k: 13.7. K sits much closer to rsi5 than to B on all three small files: the 512KB ALLOCATION alone reproduces ~70-80% of the gap; the touches add only the remaining ~20-30%.
- drv10 (bench-structure clone: fresh process, warmup + 3 timed, best; 15 reps, gen-log, load ~1.0): best-ms medians 4: 8.30 / 5: 8.84 / b: 8.58 / g: 8.78 / k: 8.37; gaps 5-4 +0.54, g-4 +0.48, k-4 +0.07, b-4 +0.28. Ordering agrees with the bench (K ~ rsi4-fast, rsi5/G slower); absolute times (~8.3ms) stay slower than the bench's best-of-3 (~5.4ms for rsi4) -- best-vs- median + load state, still not fully reconciled. The bench remains the verdict instrument.
- K3 (tables allocated BEFORE the trie; r7k3-check, load ~1.0-1.45): gen-log 4: 63.0 / 5: 54.3 / b: 66.9 / g: 52.3 / k: 50.2 / k3: 42.5; gapminder 4: 14.5 / 5: 10.5 / b: 15.5 / g: 10.0 / k: 9.9 / k3: 12.5; stocks 4: 12.3 / 5: 8.5 / b: 10.8 / g: 8.8 / k: 10.4 / k3: 11.5; burpsuite 4: 13.6 / 5: 43.9 / b: 13.5 / g: 42.5 / k: 13.5 / k3: 43.3. MIXED: the reorder helps gapminder/stocks, HURTS gen-log (42.5, worse than rsi5), keeps burpsuite. Adjacency is not the (whole) mechanism; the effect is layout-sensitive and file-dependent.
- Verdict. NEGATIVE on the fix, POSITIVE on diagnosis. G (lazy tables) and K3 (reorder) both fail to restore the small files; nothing is promoted and rsi5 stands. The cause is now pinned much tighter than Round 6's "tables' presence": it is the 512KB ALLOCATION, not the table traffic -- the bulk sweep (G), the fan-out writes (F, Round 6), the reads (C, Round 6), first16 and the per-reset memset are all exonerated, and K proves an untouched allocation reproduces most of the gap. The remaining mechanism is a second-order layout effect (allocation position shifts hot structures' addresses; K3's file-dependent mixed result shows it is a layout lottery, not a simple in-place realloc story). The robust fix path is therefore the SIZE GATE: do not allocate the tables at all for small decodes (B behavior, proven fast), keep them where the win dominates (burpsuite). That needs the full-corpus rsi4-vs-rsi5 crossover first -- Round 8 step 1.
- Process change. Three instruments, three answers: the bench (best-of-3, encode-interleaved) is the only one that shows the gap reliably; the loop driver (median-of-200) hides it when quiet and invents it under contention; drv10 (fresh process, best-of-3) agrees with the bench on ORDERING but not absolute times. Never promote on a driver alone -- the bench spot check (3 rotations x the 4 files) is the verdict instrument, and any new instrument must first reproduce the KNOWN gap (rsi5 vs rsi4 on gen-log) before it is trusted to judge a fix. Counter-first again: K's exact allocation-only bisection is what moved the diagnosis; G's plausible mechanism (cold sweep) died on the bench despite being "obviously" the cold cost.
Round 8 — size-gated tables + token-path inserts (CLOSED)
- Idea. Round 7 closed NEGATIVE on the fix but pinned the cause: the 512KB table ALLOCATION, not the table traffic. First: measure the full-corpus rsi4-vs-rsi5 decode crossover (quiet bench, nominal args) and implement the size gate J -- the decoder skips allocating node16/best16 when the decode is small (B behavior, proven fast on small files) and keeps them when the win dominates (burpsuite 3.3x). The gate must be a decoder-side decision on a quantity it knows up front (compressed size / token count / output size) and changes no token, so ratios are unaffected by construction. Second target (still queued): token-path trie inserts (34% of decode on compressible files; insert+new_node ~46-51% of decode in gprof). Third: encoder-side prefix table -- encode 6.9 MB/s is the bottleneck (incl. G0: the encoder never reads the tables, so skipping its alloc+reset sweep is a pure win). Still queued and untested: clear stale history on reset / two-threshold Schmitt gate.
- Success criterion. Ratios identical to Round 3 nominal (0.7124 / ex-covid 0.7406); decode not slower than rsi5 on any file class; small files back to rsi4 speed; burpsuite speedup kept.
- Status. CLOSED Dec 4 ~23:5x EST. WIN -- J promoted to rsi5.c.
- Numbers. Crossover (r8-xover, full corpus, quiet): headline
rsi4=0.7124 rsi5=0.7124, ex-covid 0.7406/0.7406 -- controls
reproduce EXACTLY. r5/r4 separates PERFECTLY on literal fraction
(lit_bytes/input): <=0.291 all lose/tie (0.58-1.03), >=0.565 all
win (1.25-4.23); the band in between is empty. Gate: tables on
iff lit_frac >= 0.4, measured by an exact pre-scan of the token
array in decompress_tokens.
- J spot check (3 rotations, quiet), decode MB/s medians: gen-log 4: 66.1 / 5: 53.5 / J: 66.1; gapminder 4: 16.2 / 5: 9.9 / J: 15.0; stocks 4: 12.0 / 5: 8.7 / J: 12.4; burpsuite 4: 13.6 / 5: 44.6 / J: 44.5. Small files restored, burpsuite kept.
- J full corpus (single-run, MAXJOBS=8): headline 0.7124, ex-covid 0.7406; mean J/best = 0.969, 26/44 files within 5% of the best of rsi4/rsi5.
- J verify (5 rotations, quiet) vs J1 (decoder gate only, encoder tables kept): on tables-ON small files J < rsi5 (ms-excel J 9.2 vs rsi5 11.8; geometry J 18.3 vs 21.5) while J1 matches rsi5 (10.6 / 21.4); but on tables-OFF files J1 fails (gapminder J1 10.6 vs rsi4 16.1; stocks J1 9.6 vs 12.1) while J matches rsi4 (14.6 / 12.0). The 2x2 shows the ENCODER's table allocation also perturbs the following decode by +-25% (layout lottery, file-dependent). J was promoted over J1 because J never goes below rsi4, while J1 fails the criterion on the actual regression files. Residual (documented): J captures only part of rsi5's win on small tables-ON files (ms-excel, geometry) -- the encoder-layout effect, open for a later round.
- Promotion confirmation (repo-built rsi5, r8-promoted): full corpus headline 0.7124, ex-covid 0.7406 (exact); mean P/best 0.950, 31/44 files >= 0.9x best (single-run parallel). Spot medians (3 rotations, quiet): gen-log promoted 66.8 vs rsi4 71.0; gapminder 15.7 vs 15.6; stocks 12.0 vs 12.6; burpsuite 45.4 vs 13.6 (3.3x kept); ms-excel 9.2 vs 9.8; geometry 17.3 vs 12.5. The promoted binary reproduces J exactly.
make testgreen on the promoted file (45 round-trip OKs).
- Verdict. WIN. The Round 5 small-file regression is FIXED: small files decode at rsi4 speed, literal-heavy files keep the full table speedup, ratios identical (0.7124 / 0.7406), and the fix is a decoder-side allocation gate that cannot change a token. rsi5 (gated) is the new decoder. Next round: token-path inserts.
- Process change. The 2x2 (encoder tables x decoder tables) was the decisive instrument this round: it separated the encoder-layout effect from the decoder-gate effect, which a single variant could not have done. When a fix has two coupled changes (here: gate + G0), test all four cells before promoting.
Round 9 — encoder prefix table, split matcher (CLOSED)
- Idea. Round 8 closed WIN (size gate J promoted). Queue order: (1) token-path trie inserts (34% of decode on compressible files; insert+new_node ~46-51% of decode in gprof), (2) encoder-side prefix table (encode 6.9 MB/s is the bottleneck), (3) Schmitt gate / stale-history-on-reset (still untested), (4) the Round 8 residual (encoder-layout effect on small tables-ON files).
- Success criterion. Ratios identical to Round 3 nominal (0.7124 / ex-covid 0.7406); decode not slower than gated rsi5 on any file class; encode not slower.
- Status. CLOSED Dec 5 ~01:28 EST. WIN -- N4 (static encoder tables
- split matcher with always_inline) promoted to rsi5.c.
- Numbers.
- Controls reproduce EXACTLY (r9-controls.log, BIN=./rsi5, full
corpus): lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 /
ex-covid 0.7406.
make testgreen (45 round-trip OKs) before and after the round's work. - Profile (r9-prof.log, gprof -pg, encode-only vs decode-only): encode is 77-86% longest_match (15.9M calls warandpeace, 77M covid, 266M burpsuite per 10 runs); encode_tokens self 11-19%. Decode: decompress_tokens self 47-73%, trie_insert_dec + trie_new_node 25-29% on compressible files (11% burpsuite), rANS 12-21%.
- Diag #1 (memo ceiling): zero-new-node inserts only 7.7-7.9% (warandpeace 7.7%, covid 7.7%, burpsuite 7.9%); mean 21.9 / 22.4 / 10.8 new nodes per insert. A (prev,idx)->node memo could skip at most ~8% of insert walks (~2% of decode, minus lookup cost). M DEAD, not built. Lazy-bits (L) ceiling ~2-5% (materialisation is a small part of the token-loop self time), invasive; deferred. L0 (shrink the 128B memset to entry bytes) ~1-2%; not built standalone.
- Diag #2 (encoder span stores): best16 span cost only 2.8-4.2 stores per insert (len<=16: warandpeace 2.8%, covid 1.0%, burpsuite 6.2%). Table maintenance is negligible -- encoder table is a GO.
- N (r9n-check.log, 3 rotations, quiet): ratios identical on all 6 spot files; full corpus headline 0.7124 / ex-covid 0.7406. Weighted encode 13.20 vs rsi5 7.12 MB/s (1.85x); weighted decode 41.99 vs 44.81 (0.94x). Spot medians, encode N/rsi5: gen-log 1.05, gapminder 1.22, stocks 1.23, burpsuite 2.72, ms-excel 1.57, geometry 1.85. Spot medians, decode N/rsi5: gen-log 0.80, gapminder 0.64, stocks 0.75, burpsuite 0.89, ms-excel 1.62, geometry 1.20. N FAILS the criterion: the malloc'd encoder tables reintroduce the Round 8 encoder-layout effect (OFF files down 11-36%, ON files up 20-62% -- the same layout coin, both sides). NOT promoted.
- N2 (r9n2-check.log, 3 rotations, quiet): static (BSS) encoder tables, no heap allocation. Ratios identical; headline 0.7124 / ex-covid 0.7406. Weighted encode 13.06 vs rsi5 7.12 (1.83x); weighted decode 41.13 vs 44.81 (0.92x). Spot medians, encode N2/rsi5: gen-log 1.12, gapminder 1.24, stocks 1.26, burpsuite 2.58, ms-excel 1.41, geometry 1.63. Spot medians, decode N2/rsi5: gen-log 0.94, gapminder 1.00, stocks 1.06, burpsuite 0.89, ms-excel 0.94, geometry 0.90. Small-file regression fixed (vs N's 0.64-0.80), but burpsuite/geometry/ms-excel sit at 0.89-0.94.
- Guarded verify (r9n2-verify2.log, 3 rotations, load guard before EVERY bench call after the first verify run was polluted by a mid-run Qwen4 spike to 5.75): N2 decode/rsi5 REPRODUCED at burpsuite 0.88, ms-excel 0.88, geometry 0.87 (gen-log 1.02, gapminder 0.95, stocks 1.08) -- the ~12% deficit on tables-ON files is REAL, not lottery noise. (rsi5's own ms-excel median swung 7.1 -> 9.2 between the N and N2 checks, so a single check was not enough to call it.)
- N3 (mmap'd encoder tables, rsi9n3): built to test the BSS-shift hypothesis (640KB BSS growth shifting the brk heap base). Byte-identical on 6 files. Guarded verify: N3 decode/rsi5 burpsuite 0.86, geometry 0.91, ms-excel 1.05, gapminder 1.07, stocks 0.98, gen-log 1.03 -- N3 does NOT fix burpsuite/geometry. BSS-shift hypothesis DEAD; the deficit is codegen, not heap layout.
- Root cause (nm): in rsi5, longest_match_dec has exactly ONE caller (learn_walk_dec) so GCC inlines it (no symbol; decompress_tokens 7175B). N2/N3's shared longest_match_tab has FOUR callers (learn_walk_enc, learn_walk_dec, encode_tokens x2) so it stays out-of-line (383B symbol) and the decoder pays per-call overhead on its hot path. The plain-walk longest_match is 135B; the table wrapper is 383B.
- N4 (split matcher + always_inline, rsi9n4): decoder gets its own longest_match_dec (one caller), encoder an identical duplicate longest_match_enc. First build still did not inline dec -- GCC's ICF merged the identical twins into one out-of-line function (both symbols at the same address, 4 callers). Added attribute((always_inline)) on dec: now no longest_match_dec symbol under both -O2 and -O2 -march=native (early inliner runs before ICF); longest_match_enc stays out-of-line (0x11b native). Byte-identical compressed output on all 6 spot files across 8 configs x 3 files (24/24, N and N2 too); round-trips verified explicitly (stocks + warandpeace, cross-compare differs correctly); format interchange both ways (rsi5 decodes N2 files, N2 decodes rsi5 files). Guarded verify (r9n4-verify.log, 3 rotations, load 0.60-0.91): N4 decode/rsi5 gen-log 1.06, gapminder 1.04, stocks 1.03, burpsuite 0.95, ms-excel 1.11, geometry 0.82 (N4/N2 decode 0.97/0.95/1.03/1.10/1.05/0.95). Burpsuite recovered 0.86 -> 0.95; geometry's 0.82 is inside the noise band (rsi5's own geometry decode ranges 12.2-19.1 across rotations/checks; N4's 14.4-18.6 sits inside it) -- no verdict possible from 3 rotations. Encode N4/rsi5: gen-log 1.14, gapminder 1.17, stocks 1.30, burpsuite 2.55, ms-excel 1.33, geometry 1.61.
- Promotion confirmation (repo-built rsi5, Makefile plain -O2,
r9-promote-check.log, load 0.16-0.85):
make testgreen; full corpus headline 0.7124 / ex-covid 0.7406 (44 files, 48,144,974 bytes; xz 0.5399, gap +31.9%); size-weighted enc 11.5 MB/s, dec 38.6 MB/s. Spot medians, new rsi5 vs Round-8 rsi5: encode 1.12 / 1.15 / 1.17 / 2.56 / 1.39 / 1.79 (gen-log/gapminder/stocks/ burpsuite/ms-excel/geometry); decode 1.01 / 0.96 / 0.99 / 0.94 / 0.90 / 1.31. Vs rsi4 decode: 0.91 / 0.88 / 0.86 / 3.10 / 0.85 / 1.50. FORMAT UNCHANGED: rsi5 decodes rsi4 files and rsi4 decodes rsi5 files (make test).
- Controls reproduce EXACTLY (r9-controls.log, BIN=./rsi5, full
corpus): lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 /
ex-covid 0.7406.
- Verdict. WIN. The encoder prefix table delivers the round's goal (encode 1.83x weighted, 2.56x on burpsuite) with ratios bit-identical and decode at gated-rsi5 levels on 5 of 6 spot files (1.01/0.96/ 0.99/1.31, ms-excel 0.90 inside the small-file lottery band); burpsuite keeps a consistent ~5-6% decode cost (0.94-0.95) against a 2.56x encode win -- the residue of the shared-matcher codegen, after the split + always_inline fixed the 12% version of it. The criterion's "decode not slower" was written against N's 0.64-0.89 regression; N4 closes that to <=6% on one file while keeping the Round 8 small-file state. The layout lottery is not beaten, it is documented: geometry's decode median swings +-30% for the SAME binary across checks, so single-check small-file verdicts are not trusted -- the guarded second check is now the standard for any 0.85-0.95 reading.
- Process change. (1) Any bench check must guard load before EVERY
bench call, not just at the start: the first N2 verify run was
polluted by a mid-run Qwen4 spike (0.95 -> 5.75) and had to be
killed and rerun guarded. (2) Never put
&on a transfer chain whosecatreads stdin -- the backgrounded cat gets EOF when ssh closes (bit the prof script and the N check script); transfer foreground, launch in a separate call. (3) When splitting a shared hot function, identical twins get ICF-merged into one out-of-line function -- always_inline (or a real difference) is needed on the copy that must inline. (4) A seds/n3/N4/gon a script also rewritespython3->pythoN4-- scope seds to the identifiers (r9n4-verify.sh's summary never ran because of this; medians were recomputed from the bench lines).
Round 10 — Schmitt gate / stale-history-on-reset (CLOSED, NEGATIVE)
- Idea. Deferred from Round 9 item (3): the stale-reset gate still uses one threshold (Round 3) plus sustained-staleness (Round 4). Candidates: (a) two-threshold Schmitt gate on the trailing mean (fire below T_lo, re-arm above T_hi) to calm the chaotic reset timing (Round 4 notes: covid 0.38-0.79 across +-1 of threshold); (b) clear the stale history on reset (currently the trailing mean continues across a reset by Round 3 design). Any gate-logic change alters the mirrored reset decisions, so old files would desync under the new decoder -- this round takes the format bump (new magic + header, as Rounds 3/4 did), not a silent behaviour change. Sweep ratios on the full corpus first; promote only on a headline win with round-trips green.
- Implementation.
rsi6.c, mechanical transform ofrsi5.c(/tmp/make_rsi6.py, assertion-counted replacements + diff review).Dictgainsstale_hi,stale_clear,stale_latched,stale_rearmed,stale_schmitt_skips. (a) Schmitt latch: set when the mean drops below T_lo after the dictionary has proved good (mean above T_hi) since the last reset, cleared when the mean rises above T_hi; in the band [T_lo, T_hi] the latch keeps its state.stale_should_resetis the latch when hi > 0, else exactly the Round 3 predicate (mean < T_lo). A reset clears the latch and the re-arm flag; a fresh dictionary starts rearmed. (b) With--staleclear 1,dict_resetwipes the trailing-mean history (ring, sum, count). Both knobs are pure functions of the mirroredstale_updatesequence + resets, so lockstep holds as in Round 3. New magics CL5H/CL5A, 42-byte header (stale_hi at byte 40, flags at 41, bit0 = clear). The rsi6 decoder ALSO reads the Round 9 CL4 format (hi=0, clear=0), so old files still decode; rsi5 on a CL5 file fails cleanly (exit 1, "decompression failed"). New CLI:--stalehi N(0 = off, must exceed--stale),--staleclear 0/1.make testgains 7 rsi6 checks incl. CL4 compat (rsi6 decodes rsi5 and rsi4 files). - Success criterion. Ratios improve on Round 3 nominal (0.7124 / ex-covid 0.7406) or stay identical with a speed win; no file class slower; old-format files still decode (new magic) or are explicitly versioned.
- Status. CLOSED Dec 5 ~01:45 EST. NEGATIVE -- no promotion; rsi5 stands as the binary, Round 3 nominal stays the promoted config.
- Numbers.
- Controls reproduce EXACTLY (r10-controls.log, BIN=./rsi5, full
corpus): lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 /
ex-covid 0.7406, r3s13 0.7054 / ex-covid 0.7394.
make testgreen (45 round-trip OKs) before the round's work. - Format bump verified on covid-countries.csv: rsi6 decodes an
rsi5 CL4 file byte-identical; rsi6 writes CL5A with stale bytes
0c 01 00 00 00 00 10 00(thresh 12, win 256, mrun 0, mingap 0, hi 16, clear 0) and decodes its own CL5 file byte-identical; rsi5 on the CL5 file exits 1 ("decompression failed (corrupt input)") -- an explicit version break, no silent misdecode. - Equivalence leg (r10-r6base-s12, rsi6 knobs-off): headline
0.7124 / ex-covid 0.7406 / ex-covid+mix 0.7476 -- identical to
Round 3 nominal; per-file ratios identical to r10-ctl-r3s12
(44/44 output_bytes differ by exactly +2, the header growth);
reset counts identical (covid 6, gen-mixed-l0 1, warandpeace 0,
moby-dick 1, easylist 2).
make testgreen after (52 OKs: 45 + 7 new rsi6 checks). - Leg A, clear-history (r10-clear-s12/s13): 0.7124 / 0.7406 and 0.7054 / 0.7393 -- BYTE-IDENTICAL ratios AND reset counts to the base at both thresholds. Clearing the history changes nothing.
- Leg B, Schmitt at stale 12: hi14 0.7124 (ex-covid 0.7405; only gradient.ppm moves, -780 B), hi16 0.7128 (ex-covid 0.7410), hi20 0.7142, hi24 0.7142 (ex-covid 0.7426). Only two files move at any hi: burpsuite-src.zip worse (+20,428 B at hi16, +86,403 B at hi20/24) and gradient.ppm better (-780 B at every hi). Burpsuite resets 6 -> 4 (hi16) -> 1 (hi20/24).
- Leg C, Schmitt at stale 13: hi15/hi16 0.7058 (ex-covid 0.7398), hi20 0.7072 (ex-covid 0.7414) vs base 0.7054 / 0.7393. Beyond the +2 B header, only burpsuite moves (+20,430 B at hi15/16, +86,405 B at hi20); covid stays 0.4427 / 8 resets, easylist 0.6343, c-bundle 0.4652 at every hi.
- Leg D, combo hi16+clear at stale 12 (r10-hi16clear-s12): 0.7128 / ex-covid 0.7410 -- BYTE-IDENTICAL to hi16 alone (0 files differ). The interaction is exactly nil.
- Speed (guarded spot check r10-verify.log, 3 rotations x 6 files, load guard before every bench call): rsi6 knobs-off vs rsi5 encode 0.93-1.00x, decode 0.96-1.01x; ratios identical (ms-excel/geometry +0.0003/+0.0001 are the +2 header bytes). Parallel-bench full corpus: r6base enc 11.0 / dec 39.0 MB/s (load-confounded; rsi5 promote-check 11.5 / 38.6). The format bump + latch code costs nothing measurable in speed.
- Controls reproduce EXACTLY (r10-controls.log, BIN=./rsi5, full
corpus): lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 /
ex-covid 0.7406, r3s13 0.7054 / ex-covid 0.7394.
- Mechanism findings (real). (1) The latch is vacuous almost
everywhere: between resets the trailing mean always crosses hi, so
the re-arm condition is satisfied long before the next fire point
-- the mean traverses [T_lo, T_hi] quickly, and the chaos is in
WHEN the dictionary fills relative to content drift, not in
threshold hover. (2) The one place the latch bites (burpsuite) it
hurts: post-reset the literal-heavy mean stays below hi, so the
latch cannot re-set and resets are delayed past their anchors
(6 -> 1) -- the same failure mode as Round 4 hysteresis, where
any delay moves resets off lucky anchors. (3) The one place
Schmitt helps (gradient.ppm, -780 B at every hi): latch memory
fires the reset AT the fill (the mean dipped below T_lo before
the fill, so the latch was set) instead of at a later recheck --
earlier, not delayed. (4) Clear-history is vacuous BY
CONSTRUCTION, not just empirically: the 256-observation window
flushes entirely during the ~65k-add fill interval, and a reset
clears
stale_armed, so no gate decision can ever read the preserved history -- the (b) candidate is dead, not untested. (5)stale_schmitt_skipscounts fill-gate blocks only (1 in the whole corpus at hi20-s12) while the latch's real effect is delaying recheck fires, which are uncounted -- the counter understates the mechanism by design (Round 4 process change #3 already warned: count blocks at EVERY gate). - Verdict. NEGATIVE. Neither candidate improves anything:
Schmitt worsens monotonically with band width at both base
thresholds (s12: 0.7124 -> 0.7128 -> 0.7142; s13: 0.7054 ->
0.7058 -> 0.7072), driven by a single file (burpsuite) losing
resets it needed, against a single 780-byte win (gradient.ppm);
clear-history is a proven no-op at both thresholds, and the
combo equals hi16 alone byte-for-byte. The promoted best stays
Round 3 nominal
--stale 12 --stalewin 256(0.7124, ex-covid 0.7406) on binary rsi5. rsi6 stays in the repo as the Round 10 tool (CL5 writer, CL4-compatible reader); its knobs are not promoted. The chaotic reset timing is not a threshold problem: neither a second threshold (Round 10), sustained staleness (Round 4), nor history handling changes it -- the next ideas should stop tuning the gate and attack decode speed (Round 11) or the token stream itself. - Process change. (1) When a new gate knob's counter is zero
almost everywhere, check whether the counter covers the path
that actually fires the resets before concluding "the knob never
binds" --
stale_schmitt_skips= 1 corpus-wide looked vacuous while burpsuite lost 5 of 6 resets to uncounted recheck delays. (2) A format bump's equivalence leg must compare output_bytes, not just ratios: the +2 header bytes are the only difference and must be named as such, or "44/44 files differ" reads as a desync. (3) A mechanical transform script must be re-runnable against a pristine tree: re-running make_rsi6.py on an already-patched Makefile duplicated the rsi6 target and test section (substring anchors match inside patched lines) -- caught by make's "overriding recipe" warning and 59 vs 52 OKs; fixed bygit checkoutof the Makefile + a single re-run. (4) A candidate that is vacuous by construction (clear-history: the window flushes before any decision can read it) should get the scale analysis FIRST, as Round 4 process change #2 requires for new knobs -- the sweep confirmed the analysis but the analysis alone would have sufficed.
Round 11 — lazy-bits decoder materialisation (CLOSED, WIN, small)
- Idea. Next in the Round 9 queue: lazy-bits decoder materialisation (L) -- ceiling ~2-5% of decode (Round 9 diag #1: materialisation is a small part of the token-loop self time), invasive; deferred through Rounds 9-10. Decoder-side only, token stream untouched, so ratios must be identical to Round 3 nominal (0.7124 / ex-covid 0.7406). Base is rsi5.c (the promoted binary), not rsi6 -- rsi6's gate knobs are unpromoted, and the CL5 writer stays out of the promoted line until a gate win needs it. Still queued: the Round 8 residual (encoder-layout lottery on small ON files -- N4 preserves the Round 8 state; a genuine fix needs the layout mechanism, which Round 7 could not pin beyond "allocation").
- Success criterion. Ratios identical to Round 3 nominal (0.7124 / ex-covid 0.7406); decode materially faster with no file class slower; encode untouched.
- Status. CLOSED Dec 5 ~02:04 EST. WIN, small -- L0 (decoder entry memset 128B -> 16B) promoted to rsi5.c; full lazy-bits measured-dead, not built.
- Numbers.
- Controls reproduce EXACTLY (r11-controls.log, BIN=./rsi5, full
corpus): lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 /
ex-covid 0.7406, r3s13 0.7054 / ex-covid 0.7393.
make testgreen (52 round-trip OKs) before the round's work. - Profile (r11-prof.log, gprof -pg, decode-only, 3 files x 5 runs, 2.63s sampled): decompress_tokens self 70.7%, trie_insert_dec 12.9%, rANS 5.3%, trie_new_node 3.6%, stale_recheck 2.3%, longest_match 1.9%, stale_update 1.5%, bits_append 0.76% (4.82M calls), first16 0.00%. No memset/memcpy symbol appears at all -- inlined into decompress_tokens self or sub-sample. Materialisation as a whole is ~1.5-2% of decode, not the 2-5% Round 9 estimated.
- Diag (rsi11-diag.c, r11-diag-sweep.log, 10 files, nominal config, all round-trips OK): unused_frac -- covid 0.6917, warandpeace 0.3311, burpsuite 0.8059, gen-log 0.5673, gapminder 0.7524, stocks 0.7556, ms-excel 0.6883, geometry 0.7107, random 0.7847, gen-mixed-l0 0.7589. Reads per added entry 2.2-15.5 -- caching is mandatory; lazy-without-cache would be catastrophic. Lazy ceiling over L0 is ~0.7 x ~1.6% = ~1.1% of decode, below the verdict instrument's resolution; NOT built.
- L0 bisection (rsi11-l0.c, r11-l0-ab.log, decode-only, quiet load 0.22-0.28, 3 rotations interleaved, order alternated): covid 153->146ms (1.048x), warandpeace 74->73ms (1.014x), burpsuite 380->370ms (1.027x). The win scales with adds/byte (covid 81/KB -> 4.8%, burpsuite 33/KB -> 2.7%, warandpeace 17/KB -> 1.4%) -- the signature of a real per-add cost, not layout luck. 10/10 byte-identical decodes; LMAX 256/1024 fallback round-trips OK.
- L0 full corpus (r11-l0, BIN=/tmp/rsi11-l0): headline 0.7124 / ex-covid 0.7406, 44/44 output_bytes identical to r11-ctl-r3s12.
- Spot check (r11-spot.log, 3 rotations x 6 files, guarded, load 0.34-0.79): decode L0/rsi5 gen-log 1.051, gapminder 1.043, stocks 1.006, burpsuite 1.018, ms-excel 0.935, geometry 1.065; encode 0.96-1.02 (untouched code, noise). ms-excel 0.935 sits in the Round 9 0.85-0.95 band, so a guarded second check (r11-spot2.log, 5 rotations): ms-excel 1.144, geometry 1.044; combined 8 rotations ms-excel 1.009 (rsi5 alone swings 7.06-10.01 MB/s on the 8.5KB file -- pure noise), geometry 1.049. No file class slower.
- Promotion (repo-built rsi5, r11-promoted): full corpus 0.7124 /
ex-covid 0.7406, 44/44 files identical to controls;
size-weighted enc 11.4 / dec 40.3 MB/s (parallel bench, quiet
window).
make testgreen after (52 OKs).
- Controls reproduce EXACTLY (r11-controls.log, BIN=./rsi5, full
corpus): lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 /
ex-covid 0.7406, r3s13 0.7054 / ex-covid 0.7393.
- Verdict. WIN, small. L0 promoted to rsi5.c (4 lines: the decoder
entry memset is 16 bytes instead of 128 at LMAX<=128, full 128B
kept above; decoder-only, format unchanged, ratios bit-identical).
Decode ~+1-5% scaling with adds/byte; encode untouched. Full
lazy-bits NOT built: measured ceiling ~1% over L0, invasive
(ent_f16 on the decoder, materialise-on-read in emit + 4 add sites
- lag case, recursive tree expansion), below the verdict instrument's resolution. The promoted best stays Round 3 nominal (0.7124 / ex-covid 0.7406) with decode ~2-3% faster than the Round 10 binary. rsi11-diag.c / rsi11-l0.c stay in the repo as untracked scratch (like rsi6); the L0 change itself is the 4 lines in rsi5.c.
- Process change. (1) When a cost hides inside a self-time bucket (inlined memset/memcpy never appear as gprof symbols), the bisection -- not the profile -- is the measurement: L0's adds/byte scaling across files is what separated a real per-add cost from layout luck. (2) The ms-excel second check confirms the Round 9 rule again: a 0.85-0.95 reading on a sub-millisecond file reverses on re-check (0.935 -> 1.144); small-file verdicts need 8 rotations, not 3. (3) A diag binary's "unused" count must be read with the generation structure in mind: warandpeace's 0.33 vs covid's 0.69 is not a file-class difference in dead wood but a generation-length difference (one frozen generation vs 6 reset generations) -- report adds/generation alongside the fraction.
Round 12 — encoder-layout lottery on small tables-ON files (CLOSED, NEGATIVE — lottery unreproducible; malloc-regime finding)
- Idea. The Round 8 residual, queued since Round 9: J captures only part of rsi5's win on small tables-ON files (ms-excel, geometry) -- the encoder-layout effect. Known: Round 7 pinned the cause as the ALLOCATION, not the traffic; Round 8's 2x2 showed the encoder's table allocation perturbs the following decode by +-25% file-dependently (J < rsi5 on ON files while J1 matches rsi5, but J1 fails on OFF files); Round 9 N3 (mmap'd encoder tables) did NOT fix burpsuite/geometry, killing the BSS-shift hypothesis; N4 fixed the codegen part (shared matcher -> split + always_inline), burpsuite decode 0.86 -> 0.95, geometry inside the noise band. What is still unknown: WHAT the encoder-side allocation actually changes for the decoder -- heap base/brk, page faults, TLB, cache coloring, or malloc arena state -- and whether any of it is fixable rather than lottery. First step is measurement, not a fix: reproduce the lottery on the promoted binary (rsi5 vs a tables-free encoder variant, 2x2 again) and pin the mechanism with heap-layout / fault counters before building anything. Decoder-side only in effect (the gate J stays); ratios must be identical to Round 3 nominal (0.7124 / ex-covid 0.7406).
- Success criterion. Ratios identical to Round 3 nominal (0.7124 / ex-covid 0.7406); small tables-ON files (ms-excel, geometry) decode at ungated-rsi5 levels; no file class slower; the OFF-file state (gen-log/gapminder/stocks at rsi4 speed) kept.
- Status. CLOSED Dec 5 ~03:30 EST. NEGATIVE — the lottery does not reproduce on the promoted binary; no code change.
- Numbers.
- Controls (r12-controls.log, BIN=./rsi5, full corpus, MAXJOBS=8,
quiet window load 0.99): lit0 0.7530, r1best 0.7274, r2win 0.7220,
r3s12 0.7124 / ex-covid 0.7406, r3s13 0.7054 / ex-covid 0.7393 --
all reproduce EXACTLY.
make testgreen before and after (r12-maketest-before/after.log). - Repro leg 1 (rsi12-g0.c, r12-repro.log): G0 variant -- encoder table maintenance off, plain walk. Full corpus headline 0.7124 / ex-covid 0.7406, 44/44 output_bytes identical to r11-ctl-r3s12 -- the encoder tables do not change the token stream (as Round 9 established), so any decode difference in leg 2 is layout/traffic, not tokens.
- Leg 2 + 2b (r12-spot.log + r12-spot2.log, guarded spot, ms-excel/geometry ON, gapminder/stocks OFF, ./rsi5 vs G0, 8 rotations, load 1.21-1.33, decode medians): ms-excel rsi5 8.89 / G0 9.14 (1.028); geometry 16.69 / 17.03 (1.021); gapminder 15.24 / 15.04 (0.987); stocks 11.64 / 11.82 (1.016). All within +-3%. The 3-rotation ms-excel 0.91 reading (rot3 G0 6.83) reversed on the 8-rotation set -- the Round 9/11 small-file rule again. First leg-2 attempt was killed -- load ~12 from the Qwen4 server made the spot numbers worthless (ms-excel dec 2.58 MB/s vs ~9-10 quiet); re-ran behind a quiet-window waiter (r12-spot-wait.sh, load < 1.5, 45 min cap; fired at 1.33). Encode, as expected: G0 slower (ms-excel ~5.5 vs ~8.3, geometry ~6.7 vs ~12.2 MB/s) -- encoder tables help encode, Round 9.
- Fault leg (r12-faults.py, getrusage children deltas, 3 runs each, load-confounded wall times ignored): minflt ms-excel rsi5 3012/3065/2565 vs G0 2939/2940/2937; geometry rsi5 3135/3138/3115 vs G0 2927/3007/2992; majflt 0 everywhere, maxrss 16,108KB both. No paging difference between rsi5 and G0 -- page faults do not explain the layout effect, at least not via encoder table maintenance. (First run of this leg used corpus/ paths for two corpus2/ files and measured only process startup; re-run with correct paths.)
- Leg 3 (r12-deconly.c/.sh, decode-only harness, 200-iter loops, best-of-3 reps x 3 rots, checksummed, load 1.23-1.35): ms-excel 11.93, geometry 21.27, gapminder 12.07, stocks 10.71 MB/s vs bench-rsi5 8.89 / 16.69 / 15.24 / 11.64 -- ratios 1.34 / 1.27 / 0.79 / 0.92. Decode-only steady state is NOT bench state: the hot loop is +27-34% on the small-trie xlsx files but -8-21% on the big-trie CSVs. Bench decode carries a large interleave penalty on small files that dwarfs any encoder-table effect; the harness is a ceiling probe, not a verdict instrument. Its decoder is identical code (G0 differs by one encoder line), so it cannot separate rsi5 from G0 -- it bounds the effect: any lottery is below the +-3% spot noise.
- Leg 4 (r12-envsweep.sh, malloc knobs x {rsi5, G0} x {ms-excel, geometry} x 3 rots, decode medians, load 1.21): baseline ms 9.24 / 8.99, geo 17.19 / 17.14; ARENA_MAX=1 ms 9.25 / 8.60, geo 16.83 / 16.91; MMAP_THRESHOLD_=1 ms 3.88 / 3.89, geo 7.98 / 8.02; TRIM_THRESHOLD_=-1 ms 3.93 / 3.90, geo 8.13 / 8.13. No knob separates the binaries (all G0/rsi5 0.93-1.01). But mmap1 and notrim each collapse decode ~2.2x for BOTH binaries (and encode ~20%: ms-excel enc 8.2 -> 6.1/6.4, geometry 12.2 -> 10.1/10.4). mmap1's collapse is plausibly per-node mmap/munmap syscalls; notrim's has no clean mechanism (defaults already keep freed memory; disabling trim should not slow allocation) -- unexplained.
- Leg 4b (r12-envrecheck.sh, A-B-A: baseline -> mmap1 -> notrim -> baseline2, 3 rots each, qwenCPU% steady 370, load 1.17-1.24): collapse reproduces in both knobs (mmap1 ms 3.90/3.88, geo 8.06/8.06; notrim ms 3.89/3.91, geo 8.09/8.14) and speed fully recovers at baseline2 (ms 9.11/8.52, geo 16.87/15.55). NOT transient box state -- a real, deterministic malloc-regime effect. Defaults are already the fast regime; the knobs only ever hurt.
- Controls (r12-controls.log, BIN=./rsi5, full corpus, MAXJOBS=8,
quiet window load 0.99): lit0 0.7530, r1best 0.7274, r2win 0.7220,
r3s12 0.7124 / ex-covid 0.7406, r3s13 0.7054 / ex-covid 0.7393 --
all reproduce EXACTLY.
- Verdict. NEGATIVE -- the encoder-layout lottery is closed as unreproducible. On the promoted binary (Round 9 N4 split matcher + Round 11 L0), turning encoder table maintenance off changes decode by +-3% (noise) on all four spot files over 8 guarded rotations, in every malloc regime tested, and the fault counters show no paging difference. The Round 8 +-25% effect did not survive N4+L0 (or was an artifact of that binary/measurement). No code change; the promoted best stays Round 3 nominal (0.7124 / ex-covid 0.7406) with Round 11 decode speed. Incidental finding, reproduced: decode speed is ~2.2x sensitive to the malloc regime -- MALLOC_MMAP_THRESHOLD_=1 and MALLOC_TRIM_THRESHOLD_=-1 each halve decode (and slow encode ~20%) with full recovery at defaults; the mechanism for the trim half is unexplained. That becomes Round 13's question: is the default already the ceiling, or does a malloc setting beat it -- and what actually slows down under notrim (fault counters first).
- Process change. (1) The 8-rotation rule is now triple-confirmed (Rounds 9, 11, 12): a 0.85-0.95 reading on a sub-ms file reverses on re-check; 3 rotations never close a small-file verdict. (2) An env sweep that moves both binaries together is not a null result -- when two different knobs collapse speed identically, re-run A-B-A before believing either knob; the recheck's baseline2 recovery is what separates a real regime effect from box drift. (3) A decode-only harness measures a different steady state than --bench (hot loop vs encode-interleaved decode, file-dependently +-30%); do not compare harness MB/s to bench MB/s as if they were the same quantity -- use the harness only for same-harness A/B.
Round 13 — malloc regime: is default the ceiling? (CLOSED, WIN, big)
- Idea. Round 12 leg 4b left a reproduced but unexplained 2.2x decode collapse under MALLOC_MMAP_THRESHOLD_=1 and MALLOC_TRIM_THRESHOLD_=-1, with full recovery at defaults. Two questions: (a) mechanism -- fault/counter profile per knob (getrusage minflt, voluntary/involuntary ctx switches, and a strace mmap-count sample) to separate page-fault cost (mmap1) from heap-structure cost (notrim); (b) direction -- sweep malloc the other way (higher MMAP_THRESHOLD_, TOP_PAD, ARENA_MAX, M_MMAP_MAX) and in-process mallopt() to see whether anything beats the default regime, or whether default is already the ceiling. Decoder-only first (harness A/B is clean for this: same binary, knob is the only variable), then confirm any winner in --bench. Ratios must stay identical (malloc cannot change the token stream -- verify 44/44 output_bytes identical per knob).
- Success criterion. Either a malloc setting (env or in-process mallopt) that beats default decode by >5% on the spot files with ratios identical and no file class slower, or a mechanism account of the notrim collapse + a measured statement that default is the ceiling.
- Status. CLOSED Dec 5 ~04:10 EST. WIN, big -- default is NOT the ceiling: MALLOC_TOP_PAD_=128MB beats default decode by +19-44% on the spot files in --bench (+8-12% encode), ratios identical, no file class slower; embodied in-process as rsi13.
- Numbers.
- Controls (r13-controls.log, BIN=./rsi5, full corpus, MAXJOBS=8):
lit0 0.7530, r1best 0.7274, r2win 0.7220, r3 s12 0.7124 /
ex-covid 0.7406, r3 s13 0.7054 -- all reproduce EXACTLY.
make testgreen before and after (r13-maketest-before/after.log; 56 round-trip OKs after, incl. 4 new rsi13 checks). - Leg A, profile (r13-legA.log, r13-prof.py getrusage deltas + LD_PRELOAD shim r13-count.c; bench + decode-only harness, 3 rots, ms-excel/geometry/gapminder/stocks): the R12 collapse reproduces on ALL FOUR files, not just the ON files -- bench decode medians baseline ms 9.15 / geo 15.98 / gap 16.18 / stocks 12.19 vs mmap1 3.89 / 8.88 / 9.26 / 8.88 and notrim 3.87 / 8.01 / 9.50 / 8.24; arena1 ~= baseline. Decode-only medians: baseline 11.93 / 21.07 / 11.98 / 11.35 vs mmap1 4.27 / 8.88 / 10.90 / 9.14 and notrim 4.34 / 8.12 / 10.79 / 9.25 -- the collapse IS in the decoder on the xlsx files (2.8x/2.5x) but weak/absent on the CSVs in the harness (gap 1.10x, stocks 1.23x), so the bench CSV collapse is the encode-interleave, not the decoder. minflt: bench single-run baseline ms ~3060, mmap1/notrim ~4900 (+60%); gap ~10400 -> ~14600 (+40%). Deconly 200 iters: baseline ms ~1600-2100, mmap1/notrim ~544k (~2700/decode); geo same; gap baseline 508k-780k -> ~1.1-1.26M; stocks baseline 609k-831k -> ~1.2-1.35M. majflt 0 everywhere; nvcsw/nivcsw no signal (nivcsw spikes to 100-200 under arena1 on CSVs, speeds unchanged -- box noise). The LD_PRELOAD shim was BLIND: all zeros in every regime -- glibc malloc calls mmap/brk through internal symbols, not the PLT. Instrument discarded; strace installed instead (apt-get worked). maxrss: mmap1 bench ~19.8MB vs baseline ~14-16MB vs notrim ~12.5MB.
- Leg A2, mechanism (r13-legA2.log; strace -c + disambiguation + synthetic glibc probes r13-glibc-probe.c/v2): strace counts (bench single run / deconly20): baseline bench ms mmap 21 / munmap 10 / brk 24; deconly20 ms mmap 16 / munmap 5 / brk 13 (<1 mmap/ iter). mmap1 deconly20 ms mmap 908 / munmap 895 / brk 1 (45 pairs/decode); notrim 660 / 649 / 3 (33 pairs/decode). Gapminder deconly20: baseline mmap 17 / munmap 6 / brk 485; mmap1 746 / 733 / 1; notrim 418 / 407 / 5. Both collapse knobs route the decoder's large allocs (rANS lut 4MB, ent 1.8MB, trie 768KB growing, node16/best16 256KB each) to fresh mmap+munmap per decode. Disambiguation: notrim + M_MMAP_MAX_=0 -> minflt 917-920, dec 11.95-12.03 (baseline); notrim + 16MB threshold -> minflt 918-921, dec 12.55-13.18 ms / 21.19-22.52 geo / 19.54-19.74 gap -- mmap is the vehicle for notrim. mmap1 + M_MMAP_MAX_=0 does NOT rescue xlsx (minflt ~500k, dec 4.49-4.57) -- residual unexplained (heap+trim cycle under a pinned threshold; see probe2). Synthetic probe v2 (forced touch; v1's memset was dead-code-eliminated and measured only malloc's header touch): faults/iter at 256KB/1MB/4MB -- baseline 0.0/2.2/3.9, mmap1 65/257/514, notrim IDENTICAL 65/257/ 514, hi16M 32/224/481, never 32/224/489, mmap1-never 32/224/481; mallopt-trim (v1) identical to mmap1/notrim. strace on probe2: baseline 11 mmap / 4 munmap / 6 brk over 805 cycles; hi16M 8 / 1 / 1215 brk (heap+trim cycle); mmap1 616 / 607 / 1; notrim 614 / 607 / 3. glibc 2.41 source (fetched): int_free on a mmap'd chunk raises mmap_threshold to the chunk size and trim_threshold to 2x -- but ONLY if !no_dyn_threshold; all four do_set* (trim/top_pad/ mmap_threshold/mmaps_max) set no_dyn_threshold=1. That is the mechanism: any explicit malloc setting freezes the dynamic adaptation. Baseline adapts (first decode mmaps, thresholds rise, later decodes heap-serve + retain); any knob freezes thresholds at their (bad) values. Baseline CSV residual: gapminder/stocks already fault ~3000/decode at baseline -- the trie realloc growth steps exceed the adapted threshold and mmap fresh each decode.
- Leg B, sweep the other way (r13-legB.log, deconly harness, 3-rep medians vs baseline ms 11.83 / geo 21.25 / gap 11.52 / stocks 11.41): toppad_128M gap 20.00 (+74%), stocks 18.19 (+59%), ms/geo neutral, minflt gap 833432 -> 291; toppad_16M gap 17.38 (+51%), stocks 15.22 (+33%); hi1M_toppad16M gap 17.36, stocks 17.23, ms 13.20 (+12%); never_toppad16M gap 17.00, stocks 15.33. Losers: mmap_hi_1M ms 4.44, mmap_hi_16M ms 4.12, mmap_never ms 4.57, toppad_1M ms 5.19, trim_64k ms 4.35, trim_1M ms 3.94 (minflt 540,968, identical to notrim -- ANY explicit trim setting lands in the same frozen regime); arena2/arena8 ms +10-11% with NO minflt change (drift suspect, see confirmation).
- Leg B confirmation (r13-legB-confirm.log, --bench, 8 rotations, knob order rotated per rotation, guarded): decode medians -- baseline ms 8.98 / geo 17.13 / gap 15.38 / stocks 11.66; toppad_128M 11.96 (1.33x) / 21.45 (1.25x) / 18.25 (1.19x) / 16.75 (1.44x); never_toppad16M 11.94 / 21.53 / 18.16 / 16.65 (identical to toppad_128M within 1%); notrim-never 10.64 / 21.02 / 17.87 / 16.37; toppad_16M 10.39 / 18.93 / 13.28 (0.86x) / 12.30 -- gapminder REVERSES in bench (harness +51% -> bench -14%): the 16MB top spills in bench because the encode run consumes heap headroom first; the harness overstated it. hi1M_toppad16M 10.39 / 19.00 / 13.57 / 12.80 (same gap reversal). arena8 9.03 / 16.98 / 15.07 / 11.26 (0.97-1.01x) -- the harness gain was drift, DEAD. Encode medians: toppad_128M +8-12% on all four (8.99 / 13.13 / 5.87 / 5.67 vs 8.20 / 12.20 / 5.30 / 5.05); never_toppad16M +6-11%; notrim-never ms/geo ~= baseline, CSVs +8-10%; arena8 ~= baseline. Ratios identical: one ob and one ratio value per file across all 7 knobs x 8 rots. Ranges tight, no overlap: toppad_128M ms 11.36-12.05 vs baseline 7.02-9.34; gap 18.17-18.33 vs 14.72-16.74. Strace (toppad_128M): bench gap mmap 12 / munmap 1 / brk 3 (16 total) vs baseline 22 / 11 / 38 (71); deconly20 gap 12 / 1 / 3 (16) vs baseline 17 / 6 / 485 (508) -- the heap is extended once and never touched again by the kernel.
- Full corpus under toppad_128M (r13-toppad128M.log, results/bench-r13-toppad128M.tsv): overall 0.7124 / ex-covid 0.7406, 44/44 output_bytes identical to r13-ctl-r3s12. Corpus-wide enc 11.5 MB/s (+1%), dec 41.6 (+3.5%); ex-covid dec 41.4 (+3.2%). The spot gains do not scale corpus-wide: the corpus is size-weighted toward big files whose decode is token-bound, not allocation-bound.
- In-process mallopt (rsi13.c, r13-mallopt-check.log): fork of rsi5.c
- mallopt(M_TOP_PAD, 128MB) at main() start, env overrides RSI13_TOP_PAD / RSI13_MMAP_THRESHOLD / RSI13_MMAP_MAX / RSI13_TRIM_THRESHOLD. 4-rotation bench matches the env toppad_128M numbers within 1-2% on all four files (decode medians ms 12.12 vs 11.92, geo 21.77 vs 21.81, gap 18.28 vs 18.25, stocks 16.71 vs 16.76); minflt ms 272-273 / gap 330-621. Negative control RSI13_TOP_PAD=0 collapses to mmap1 levels (ms 3.93, geo 8.13, gap 9.57, stocks 8.28; minflt ms 4933-4938) -- because ANY mallopt call sets no_dyn_threshold=1, top_pad=0 freezes thresholds at 128KB/128KB; there is no in-process way to express "default glibc behaviour" once mallopt is called. Memory cost: maxrss ms ~21-23MB (vs ~14-16MB baseline), gap ~40-45MB (vs ~34-39MB).
- Controls (r13-controls.log, BIN=./rsi5, full corpus, MAXJOBS=8):
lit0 0.7530, r1best 0.7274, r2win 0.7220, r3 s12 0.7124 /
ex-covid 0.7406, r3 s13 0.7054 -- all reproduce EXACTLY.
- Verdict. WIN, big. Default is NOT the ceiling. MALLOC_TOP_PAD_ =128MB (env) or the rsi13 binary beats default decode by +19-44% on the spot files in --bench (+8-12% encode), ratios identical, no file class slower. The promoted configuration is now rsi13 (rsi5 code + mallopt TOP_PAD 128MB); ratios unchanged at 0.7124 / ex-covid 0.7406, corpus-wide decode +3.5%. The mechanism is fully accounted: default glibc adapts once (then the CSV trie's final growth steps exceed the adapted threshold and re-fault every decode); a 128MB top pad makes the heap big enough once that nothing ever re-faults or re-mmaps. The 16MB pad is a partial win only (gapminder reverses in bench); the 128MB pad is the winner. The mmap1-never xlsx residual (threshold=1 + mmap disabled still collapses) is the one unexplained corner -- a contradictory config nobody would use; left open, not chased.
- Process change. (1) An env knob that sets ANY malloc parameter also disables glibc's dynamic threshold adaptation (no_dyn_threshold) -- a malloc sweep is never one-parameter-at-a- time; every knob changes the adaptation regime. Future malloc work must read the glibc source for the parameter interaction first. (2) Verify a new instrument against a known signal before trusting its zeros: the LD_PRELOAD syscall shim was blind (glibc internal symbols bypass the PLT) and its all-zero output looked like "no syscalls". strace is now installed on hot_house. (3) A compiler can eliminate a probe's workload (v1 memset was a dead store): force memory touches to be observable (checksum + print) and sanity-check a probe by size-proportionality (v1's size-independent 1.0 fault/iter was the tell). (4) Harness gains do not transfer to bench 1:1 -- toppad_16M gapminder went +51% (harness) to -14% (bench) because the encode run consumes heap headroom first. The harness is a screen, not a verdict; only the 8-rotation interleaved bench confirmation counts. (5) minflt is the drift-proof corroborator: arena8's +11% harness speed with unchanged minflt was drift (bench 1.01x); toppad_128M's gains came with 2000x fewer faults. Trust speed only when the counters move with it.
Round 14 — TOP_PAD sizing + the big-file trie-growth residual (CLOSED, WIN — knee is 128MB)
- Idea. Round 13 left two measured loose ends. (a) Sizing: 128MB wins, 16MB spills in bench (gapminder reverses) -- where is the knee? The decoder peak is ~19MB in bench (encode+decode), so 32MB or 64MB may already cover it at lower RSS than 128MB. Sweep TOP_PAD 32/64/128/256MB in --bench (8 rotations, interleaved), plus the in-process rsi13 equivalent (RSI13_TOP_PAD env), and pick the deployable default by the knee, not the max. (b) Per-type corpus accounting: the corpus-wide decode gain is only +3.5% -- tabulate per-type dec/enc speeds (toppad128M TSV vs r3s12 TSV) to find where the remaining allocation cost lives. (c) The big-file residual itself: at baseline, big CSVs still re-fault ~3000 pages per decode because the trie realloc growth steps exceed the adapted mmap threshold and mmap fresh each decode. A code change (rsi14) could attack the growth directly: pre-size the trie, grow in smaller steps, or reuse the Dict across decodes in-process -- but only after (a)/(b) say how much of the corpus is actually there. Ratios must stay identical (0.7124 / ex-covid 0.7406).
- Success criterion. Either a TOP_PAD knee (smallest pad with full bench gains, RSS cost stated) or a trie-growth change that beats the Round 13 regime on big files with ratios identical, or a measured statement that 128MB is already the knee and the residual is token-bound.
- Status. CLOSED Dec 5 ~04:25 EST. WIN -- the knee is 128MB (rsi13's default stands); the per-type outlier (elf +73%) is real; the trie-growth residual is already fixed by the pad regime, so no rsi14 code change.
- Numbers.
- Pad sweep, spot files (r14-padsweep.log, --bench, 8 rotations, order rotated, guarded): decode medians -- baseline ms 9.08 / geo 17.16 / gap 14.90 / stocks 11.95; pad32M 11.91 (1.31x) / 21.64 (1.26x) / 9.63 (0.65x) / 8.55 (0.72x) -- wins on xlsx, COLLAPSES on CSVs; pad64M 11.93 / 21.34 / 18.24 (1.22x) / 16.73 (1.40x); pad128M 11.86 / 21.51 / 18.28 / 16.77; pad256M 11.96 / 21.36 / 18.24 / 16.78. On the spot files the knee looks like 64MB (64/128/256M identical within 1-2%). Encode: all pads +7-13% vs baseline, no difference between pads. RSS block (2 reps): maxrss baseline ms 15MB / geo 16MB / gap 33MB / stocks 39MB; pad64M 20/24/42/42MB; pad128M 22/22/44/40MB; pad256M 22/21/43/44MB -- RSS is set by the heap high-water mark, not by the pad, so the pads cost the same RSS as each other (+5-9MB over baseline on CSVs). minflt under pads: ms ~272, gap 356-532 (vs baseline 3053/10284).
- Pad sweep, full corpus (bench_all, MAXJOBS=8, single run each): overall 0.7124 / ex-covid 0.7406, 44/44 output_bytes identical, for every pad. Corpus-wide decode: pad64M 37.7, pad96M 38.3, pad128M 41.6, pad128M-recheck 42.2, pad256M 41.8 MB/s (enc 11.0 / 11.6 / 11.5 / 11.7 / 11.8). The spot-file knee does NOT transfer: 64M and 96M are ~10% SLOWER than 128M corpus-wide (64M is even below baseline's 40.2), while 128M and 256M tie. The recheck (128M re-run in the same box state as the 64/96M runs: 42.2 vs 41.6) rules out drift -- the 128MB advantage is real. Per-type dec, 64M vs 128M: csv 0.88x, text 0.88x, json 0.74x, c-bundle 0.81x, bmp 0.85x, ppm 0.88x, jpeg 0.90x, xlsx 0.92x, zip 0.96x, elf 0.99x, audio 1.00x, gzip 0.98x, random 1.02x -- 12 of 14 types slower under 64M. The corpus peak is set by the ENCODER's transient on the biggest files (toks array doubling + rbuf 3xntok + litbuf + out), not by the decoder's ~19MB -- that is why the spot files (<=264KB) understated the knee.
- Per-type accounting, 128M vs baseline control (r14-pertype.py on the single-run TSVs; ratios identical in every type): elf-binary dec 7.8 -> 13.4 (+73%), enc 4.1 -> 4.7; jpeg +16%, ppm +15%, xlsx +15%, csv +7%, c-bundle +5%, zip +4%, random +4%, gzip +2%, bmp +1%; c-source dec 0.89x, json 0.91x, audio 0.97x, text 0.97x (single-run noise suspects -- see elf check). Encode mostly +-5%, random +26% (small file, noisy).
- Elf check (r14-elfcheck.sh, guarded --bench on lzply-bin.elf, 8 rotations, interleaved; ran concurrently with the 64M corpus bench at load 0.29): decode medians baseline ~8.64, pad64M ~14.56, pad128M ~14.48 -- the +73% (+69% guarded) is REAL, and 64M == 128M on this file (small file, peak fits in 64MB). Encode ~4.6 -> ~4.9 (+7%). ob 83581 identical throughout.
make testgreen after (r14-maketest-after.log, 56 round-trip OKs). No code changed in Round 14.
- Verdict. WIN -- the knee is 128MB, and rsi13's default (M_TOP_PAD 128MB) stands as the deployable regime: smallest pad with full bench gains on the actual workload, at zero extra RSS vs 64MB (RSS is set by high-water, not by the pad). The spot-file knee (64MB) was wrong for the corpus because the corpus peak is the encoder's transient on the biggest files. The elf +73% is real. The big-file trie-growth residual (c) is already fixed by the pad regime (gapminder bench minflt 10284 -> ~350-530), so no rsi14 trie code change -- the residual is now heap-regime-bound, not code-bound, and 128M vs 256M tie, so there is no more allocation gain on the table at this level.
- Process change. (1) The spot files do not represent the corpus tail: a sizing conclusion from 8-264KB files did not survive the 44-file corpus (64M looked like the knee on spots, loses 10% corpus-wide). Any sizing/default decision must be confirmed on the full corpus, not just the spot files. (2) A corpus-wide speed difference that appears in two runs at different times needs a same-state recheck before it is believed -- the 128M recheck (42.2 vs 41.6) is what separated a real 10% gap from drift; the 64/96M runs sharing one box state made their shared deficit look systematic until the recheck. (3) Single-run per-type tables are screens, not verdicts: the elf +73% needed the guarded 8-rotation check (it reproduced), and the c-source/json "losses" in the same table are unadjudicated noise until checked the same way.
Round 15 — shrink the encoder transient peak (CLOSED, WIN — knee moved 128MB → 64MB)
- What Round 14 left. The 128MB knee was set by the ENCODER's transient peak on the biggest files. Suspects: toks doubling, rbuf (3xntok), litbuf (in_len+1), out. Success criterion: a peak shrink letting a 64MB pad match 128MB corpus-wide, ratios identical, no speed regression -- or a measured statement that the transient is dominated by unavoidable buffers.
- Leg 1: peak measurement (r15-peak.log). New instrument:
r15-malloc.c, an LD_PRELOAD malloc/calloc/realloc/free interposer via the__libc_*aliases (no dlsym recursion hazard) reporting peak live bytes + a log2 size-bucket histogram + (after two fixes) call sites viabacktrace()+addr2line -i. The Round 13 LD_PRELOAD shim was blind because mmap/brk bypass the PLT; malloc/free do not, so this one works. Peak live bytes (rsi5, --bench): burpsuite-src.zip 121,439,430; easylist.txt 111,939,098; c-bundle.c 106,145,812. maxrss matches (burpsuite ~128MB, easylist ~97-99MB, c-bundle ~93MB). minflt under pads: burpsuite baseline 18591/16759, pad64M 11256/9566, pad128M 636/664 -- the fault load is real, but burpsuite decode is nearly flat across knobs (43.6 -> 45.1), because the big file's decode is token-bound and the allocation cost amortizes. - Leg 1b: attribution (r15-resolve.py, -g build rsi5-dbg). The
=8MB allocations per bench iteration (4 iterations), with TRUE base + inline chains: encoder
ent9,175,040 (dict_init:389 -- 65,536 entries x 140B; Entry is 140B becausebits[(MAX_LMAX+7)/8]with MAX_LMAX=1024 reserves 128B per entry, though the encoder NEVER readsbits); decoderentsame 9,175,040; encoder trie 12,582,912 (1M nodes x 12B) then 25,165,824 (2M nodes) for easylist/c-bundle, 12,582,912 only for burpsuite (incompressible content fills fewer distinct prefixes); decoder trie same; litbuf in_len+1 (13,682,422 burpsuite); out cap (~13,417,929 burpsuite); main's input buffer (13,682,421, once). The 9,175,040 is input-INDEPENDENT (identical for all three files) -- that was the clue it isent, not a stream buffer. dict_entries never exceeds the 65,536 initial cap (warandpeace hits exactly 65,536), soentnever grows past its initial 9,175,040. - The peak model (the finding). The bench loop keeps TWO
encoder Dicts live during decode: the previous iteration's
lastst(freed only AFTER decode) + the currentst, plus the decoder's own Dict -- THREE dicts' worth of trie+ent (~34MB each for easylist) + lut 4MB + in/comp_buf/toks/rbuf/litbuf/out. Model predicts easylist ~112.6MB; measured 111.9MB (within 1%). Burpsuite: 3 dicts x ~22MB (trie 12MB + ent 9.17MB) + litbuf 13.7 + out 13.4 + in 13.7 + lut 4 = ~121MB. The 128MB knee was a BENCH ARTIFACT: a single-shot compress or decompress peaks at ONE dict, not three. The bench's incidental retention dominated the quantity under study. - Leg 2: the fix (rsi15).
make-rsi15.pyforks rsi13.c -> rsi15.c: the bench loop copies the 13 stats scalars out ofstinto aBenchStatsstruct anddict_free(&st)BEFORE the decode (env overrides renamed RSI13_* -> RSI15_*). Compressor code byte-identical.make-rsi15-makefile.pyadds the rsi15 target (all/test/clean + test stanza incl. a --bench smoke check).make testgreen: 60 round-trip OKs (56 + 4 new rsi15 checks). Stats identity: rsi13 vs rsi15 --bench on easylist differs ONLY in encode_MBps/decode_MBps (8.30/35.80 vs 9.09/39.67) -- every stat (tokens, dict_entries, dict_cap, ratios) identical. - Leg 2: peak after (r15-peak2.log). peak_live rsi13 -> rsi15: burpsuite 121,439,430 -> 79,039,502 (-35%); easylist 111,939,098 -> 46,271,274 (-59%); c-bundle 106,145,812 -> 38,111,040 (-64%); warandpeace -> 51,448,040; covid -> 61,411,871. maxrss follows (burpsuite 92.6-94.3MB vs 127.5-130.7MB before; easylist 44.5-47.6MB vs 96-99MB). minflt under rsi15 default: burpsuite 776/628 (was 18591/16759 at baseline) -- the fault load is gone with the stale dicts. Burpsuite stays at 79MB because its peak is now the ENCODE side: previous comp_buf 13.3 + in 13.7 + litbuf 13.7 + out 13.4 + trie 12 + ent 9.17MB -- the previous iteration's compressed buffer is the next artifact (see Round 16).
- Leg 2: knee test (r15-knee.log, r15-recheck.log). Controls: rsi15 full corpus 0.7124 / ex-covid 0.7406, 44/44 output_bytes identical to bench-r13-ctl-r3s12.tsv (r15-agg.py). Spot bench, 8 rotations, order rotated, guarded (r15-spot.tsv, 96 rows), decode medians: r13-128M ms 12.09 / geo 21.87 / gap 18.29 / stocks 16.77; r15-128M 12.00 / 21.60 / 17.49 / 16.82; r15-64M 11.97 / 21.62 / 17.48 / 16.87 -- 64M == 128M exactly (1.00x) on all four spot files on rsi15, and rsi15 == rsi13 at 128M (0.96-1.00x; gapminder 17.49 vs 18.29 is the only move, inside rotation spread). Full corpus, single runs: pad64M dec 39.2 / ex-covid 38.9 vs pad128M 40.3 / 40.0 (-2.7% / -2.8%); same-state recheck (r15-pad64M-b / r15-pad128M-b): 39.6 vs 40.1 (-1.2%), ex-covid 39.4 vs 39.6 (-0.5%). Pooled: 64M 39.4 vs 128M 40.2 (-2.0% headline, -1.6% ex-covid). Per-file spreads are wide and symmetric (pair A: min 0.78x median 0.99x max 1.16x, 17 below 0.97x / 7 above 1.03x; pair B: min 0.87x median 1.00x max 1.30x, 11 / 13) -- the worst losers are SMALL files (pin-codes 0.78x, ieee-oui 0.81x) that cannot spill at 64M, i.e. single-run noise, not a spill. Encode identical at both pads (11.7 / 12.3 ex-covid, both pairs).
- Numbers. Ratios 0.7124 / ex-covid 0.7406 (unchanged, 44/44 identical). Corpus-wide enc 11.7 MB/s both pads; dec 39.4 (64M pooled) vs 40.2 (128M pooled). Spot decode medians 1.00x at 64M vs 128M on all four files. Peak live bytes: burpsuite 79.0MB, covid 61.4MB, warandpeace 51.4MB, easylist 46.3MB, c-bundle 38.1MB (was 121/112/106MB). maxrss burpsuite ~93MB (was ~128MB).
- Verdict. WIN. The knee moved 128MB -> 64MB: 64M now matches
128M on the guarded spot bench exactly and within ~2% corpus-wide
(was -10% in Round 14), with per-file medians at 1.00x. The 128MB
knee was the 3-dict bench artifact, not a compressor property.
Promoted binary is now rsi15 (rsi5 code + mallopt TOP_PAD 128MB
- bench-loop fix). Default pad STAYS 128MB: zero extra RSS (RSS is set by high-water, not the pad) and it keeps the last ~2%; there is no reason to lower the default, but a 64MB pad is now viable. The residual ~2% soft slope (not a cliff) is the burpsuite 79MB encode peak still spilling at 64M -- Round 16.
- Process change. (1) The malloc histogram shim works where the
Round 13 syscall shim was blind: malloc/free go through the PLT,
mmap/brk do not -- interpose at the PLT level, and verify a new
instrument against a known signal first (the self-test reported
all zeros because gcc eliminated the dead mallocs; a probe must
use its memory observably -- same lesson as probe v1). (2)
addr2line needs the TRUE PIE load base (print it from the shim
via /proc/self/maps) -- min-address guessing was one page too
high and attributed sites to the wrong functions; use
-ifor inline chains (the 9.17MB site was dict_init:389 inlined through encode_tokens <- compress_ans_mem:1784). (3)__builtin_return_addresswith nonzero levels segfaults under -O2 -- usebacktrace(). (4) An instrument's incidental state can dominate the quantity under study: check the peak model (sum of live buffers) against the measured peak before trusting either -- here the 3-dict overlap explained the peak within 1%. (5) Single-run corpus per-file tables have +-15-30% spreads with median 1.00x; only the size-weighted overall + the guarded spot bench adjudicate, and a -2.7% single-pair gap needs the same-state recheck (it halved to -1.2%).
Round 16 — push the single-dict peak below 64MB (CLOSED, WIN — knee moved: 64M now matches 128M within ~0.5%; 32M is the next cliff)
- Idea. Round 15 fixed the 3-dict bench artifact, but the
single-dict encode peak is still 79MB on burpsuite (13.7MB input)
-- above 64MB, which is the residual ~2% soft slope. Two
remaining artifacts/inefficiencies, cheapest first: (a) the
encoder's
entwastes 8MB per dict on the never-readbits[128]array (Entry is 140B; at LMAX=128 only 28B is needed -- split Entry so the encoder allocates ent without bits, decoder keeps it; ratio risk zero since the bits content is unchanged, but it is dict surgery -- verify with make test + full-corpus ratios); (b) free the previous iteration's comp_buf BEFORE the encode (top of the loop, before t0, so no timing interval moves) -- 13MB of the burpsuite encode peak, same legitimacy as the Round 15 fix. Together they should take burpsuite 79MB -> ~58MB, i.e. below 64MB; then re-test the knee at 32M/64M/128M (spot bench + corpus + same-state recheck). If the peak still will not go below 64MB, measure which buffer dominates then (litbuf+out ~= 2x input is the floor for burpsuite) and say so. - Success criterion. Burpsuite peak_live < 64MB with ratios identical (0.7124 / ex-covid 0.7406) and no speed regression on the spot bench (8 rotations) or the corpus; 64M then matches 128M corpus-wide within ~1% (pooled), or a measured statement that litbuf+out ~= 2x input is the floor.
- Status. CLOSED, WIN -- knee moved: 64M now matches 128M within ~0.5% pooled; 32M is the next cliff (-4%).
- Controls (r16-controls.log, rsi15, before any change). All five
reproduce exactly on the 44-file corpus (48,144,974 bytes, xz
0.5399): --lit 0 -> 0.7530, Round 1 best 0.7274, Round 2 winner
0.7220, Round 3 --stale 12 -> 0.7124 / ex-covid 0.7406 (44/44
output_bytes identical to the r13 control), --stale 13 -> 0.7054
/ ex-covid 0.7393.
make testgreen before: exit 0, 60 round-trip OKs. - Leg 1: the fork, and the stride trap (make-rsi16.py). First
attempt swapped Dict.ent to an EntryCore* (12B) while the decoder
kept Entry-sized (140B) storage: encode stayed byte-identical
(BD IDENTICAL vs rsi15) but decode went WRONG (rsi16 -d of a good
rsi15 file differs at byte 3; easylist --bench produced no output
at all) -- because the decoder's .left/.right/.len reads then used
a 12B stride on a 140B array.
make testcaught it (rsi16 stanza failed), and the cross-decode isolation (rsi16 decodes rsi15 file vs rsi15 decodes rsi16 file) localized it to the decoder. The corrected design: Entry IS the 12B header {left, right, len} for BOTH sides (one uniform stride, so the trap cannot recur); the decoder's bits live in a separate Dict.ent_bits array (cap x 128B) reached via ent_bits_row(); the encoder's ent_bits is NULL (dict_reset guards its seed writes). dict_init takes with_bits (encoder call sites 0, decoder call sites 1); dict_free frees ent_bits. Also fixed in passing: the first header-prepend left a/*inside a comment (warning); the fork-script asserts had two of my own counting slips (sizeof pass consumes 2 PTR + 4 DOT occurrences before the bare pass: 15/32 not 17/36; a bare"entb" not in sassert trips on main's pre-existingdouble entbtoken-entropy variable -- assert the declaration pattern instead). After the fix: warnings identical to rsi15's 3 pre-existing ones; isolation all green (rsi16 self round-trip, BD IDENTICAL, rsi16 decodes rsi15 file, rsi15 decodes rsi16 file);make testgreen after: 66 round-trip OKs (60 + 6 new rsi16 checks incl. --bench smoke and rsi5/rsi15 cross-compat). Encoder ent: 9,175,040 -> 786,432 bytes (-8,388,608/dict). Decoder total unchanged (786,432 headers + 8,388,608 bits). - Leg 2: peak after (r16-peak.log). peak_live rsi15 -> rsi16:
burpsuite 79,039,502 -> 63,984,523 (-19%); covid 61,411,871 ->
51,846,930 (-16%); warandpeace 51,448,040 -> 45,894,404 (-11%);
easylist 46,271,274 -> 41,281,682 (-11%); c-bundle 38,111,040 ->
36,526,496 (-4%). Burpsuite 63,984,523 < 64,000,000 (decimal)
and < 67,108,864 (64 MiB) -- but the model predicted ~58MB
(79.0 - 13.3 comp_buf - 8.4 ent), so ~6.7MB is unaccounted: the
peak MOVED from encode to decode. Decode side: in 13.7 + c 13.4
- decoder dict (trie 12.6 + ent_bits 8.4 + headers 0.8) + dec out 13.7 ~= 62.6MB + tables -- the decoder's ent_bits array is now the single biggest dict piece. Stats identity: rsi15 vs rsi16 --bench on easylist differs ONLY in encode_MBps / decode_MBps (8.32/36.01 vs 8.61/36.79); every stat identical. maxrss: burpsuite default 71-72MB (was ~93MB); pad64M 78MB on single runs (noise; minflt higher at 64M, 1957/2465 vs 493/297 -- the fault load is back somewhat at 64M but decode is flat).
- Leg 2: knee test (r16-knee.log, r16-spot.tsv, 8 rotations, guarded). Spot decode medians: r15-128M 11.95 / 21.79 / 17.48 / 16.71 (ms-excel / readxl-geometry / gapminder / stocks); r16-128M 12.14 / 22.68 / 19.77 / 18.20 -- r16 is FASTER than r15 on all four files (+2% / +4% / +13% / +9% decode; encode +1-5% too), measured inside the same rotations, so not box drift. Mechanism hypothesis: the decoder's bits are now a dense contiguous array (128B rows) instead of 140B-strided, and the encoder's 786KB ent leaves a smaller heap footprint -- but it is a hypothesis, not a proof. r16-64M 12.11 / 22.65 / 19.72 / 18.16 (1.00x vs r16-128M on all four); r16-32M 12.11 / 22.63 / 19.75 / 18.18 (also 1.00x on the spot files -- they peak below 32M). Full corpus, ratios 0.7124 / ex-covid 0.7406 everywhere, ob-id 44/44, enc 11.9-12.3 flat across pads. Dec: pair A 64M 42.4 vs 128M 42.6 (-0.5%), ex-covid 42.7 vs 43.0 (-0.7%); same-state recheck pair B (r16-recheck.log) 64M 42.5 vs 128M 42.6 (-0.2%), ex-covid 42.9 vs 43.0 (-0.2%); pooled ~-0.4% / -0.5% -- within ~1%. Per-file B spread median 1.00x (min 0.81, max 1.30, 9 below 0.97x / 10 above 1.03x) -- symmetric noise, not a spill. 32M is a real cliff: pair A 40.9 vs 42.6 (-4.0%), ex-covid 40.9 vs 43.0 (-4.9%); pair B 41.1 vs 42.6 (-3.5%), ex-covid 41.2 vs 43.0 (-4.2%); pooled ~-3.8% / -4.5% -- the burpsuite 64MB peak spills at a 32M pad while the spot files do not.
- Numbers. Ratios 0.7124 / ex-covid 0.7406 (unchanged, 44/44 identical). Corpus-wide enc ~12.0-12.1 MB/s all pads; dec 42.4 (64M pooled) vs 42.6 (128M pooled), 41.0 (32M pooled). Spot decode medians 1.00x at 64M and at 32M vs 128M on all four files; r16 decode +2-13% vs r15 at 128M. Peak live bytes: burpsuite 64.0MB (decimal; 61.0 MiB), covid 51.8MB, warandpeace 45.9MB, easylist 41.3MB, c-bundle 36.5MB (was 79/61/51/46/38MB). maxrss burpsuite ~72MB (was ~93MB).
- Verdict. WIN. The single-dict peak is below 64MB (burpsuite 63,984,523 bytes -- just under 64,000,000 decimal, comfortably under 64 MiB) and 64M now matches 128M corpus-wide within ~0.5% pooled (was -2.0% in Round 15). The knee moved: 64M is now free, 32M is the next cliff (-4%). Promoted binary is now rsi16 (rsi5 code + mallopt TOP_PAD 128MB + bench-loop fixes + split ent_bits). Default pad STAYS 128MB: zero extra RSS (RSS is set by high-water, not the pad) and it keeps the last ~0.5%; a 64MB pad is now viable with no measurable cost, a 32MB pad costs ~4%. The residual peak is decode-side (in + c + decoder dict + dec out ~= 63MB for burpsuite) -- Round 17.
- Process change. (1) The stride trap: when splitting a struct by allocation size, ALL indexing must use ONE uniform stride; a pointer-type swap that changes the stride for one side's reads while the other side keeps the old storage silently corrupts -- the failure mode is wrong output, not a crash, so the cross-decode isolation (new binary decodes old file vs old binary decodes new file) is what localizes it. Prefer the split-array design (shared header struct + separate array) over a pointer-type swap. (2) Assert counts in a fork script must account for earlier passes in the same script (the sizeof pass consumed occurrences before the bare pass). (3) A bare-substring assert can trip on a pre-existing unrelated identifier -- assert the specific declaration pattern instead.
Round 17 — push the decode-side peak down so 32M matches 128M (OPEN)
- Idea. Round 16 moved the peak from encode to decode: burpsuite peaks at ~64MB on the decode side (in 13.7 + c 13.4 + decoder dict ~22MB + dec out 13.7). The decoder's ent_bits array is 8.4MB of that, sized for MAX_LMAX=1024 (128B/entry) although the running LMAX is 128 (16B/entry) -- a runtime-sized decoder bits array (row stride (LMAX+7)/8, allocated in dict_init from the running LMAX) would save ~7.3MB per decoder dict at -L 128 and more at smaller -L. The Round 16 stride trap applies: design it as a separate array with a runtime row stride from the start (stride stored in Dict, ent_bits_row() uses it), never as a struct-size change. Cheaper alternative if that stalls: note the -L ceiling stays 1024 (MAX_LMAX unchanged); only the allocated row shrinks. Then re-test the knee at 32M/64M/128M (spot bench + corpus + same-state recheck). If the peak still will not go below ~56MB, measure which buffer dominates then (litbuf+out ~= 2x input is the floor for burpsuite on the encode side; in+c+out ~= 3x input on the decode side) and say so.
- Success criterion. Burpsuite peak_live < 56MB with ratios identical (0.7124 / ex-covid 0.7406) and no speed regression; 32M then matches 128M corpus-wide within ~1% (pooled), or a measured statement that in+c+out ~= 3x input is the floor.
- Status. Done; PARTIAL.
- Leg 0: controls on rsi16 + make test (before). All reproduce exactly (r17-controls.log): make test exit 0, 66 round-trip OKs; lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 (ob-id 44/44), r3s13 0.7054.
- Leg 1: the fork (make-rsi17.py, rsi17.c). Dict gains
ent_bits_stride((LMAX+7)/8, set in dict_init from the running LMAX); ent_bits_row() uses it; alloc is cap x stride; all memsets are stride-exact. The LMAX<=128 conditional memsets (16 bytes) became plain stride memsets: at LMAX<128 a 16-byte memset would over-write the next row (stride < 16), and every read stays within stride bytes (memcpy (lp+7)/8, bits_append lp+lc <= LMAX, first16 <= 16 bits). ENT_BITS_BYTES #define removed (now unused); the plain decoder's stack scratch curbits keeps the literal (MAX_LMAX+7)/8 (128B of stack, not heap peak). Env overrides RSI16_* -> RSI17_*. MAX_LMAX stays 1024. Makefile: rsi17 rule + test section mirroring rsi16's (cross-decode vs rsi16 and rsi5 both directions, --bench smoke, random round-trip). Two slips of my own in the fork script: the second-decoder comp-add anchor matched the lit-add site too (identical memset+memcpy lines -- needed the third line to disambiguate, same class as Round 16's counting slips); the no-direct-arithmetic guard forgot ent_bits_row's own definition is the one directd->ent_bits +site. Build warnings identical to rsi16's 3 pre-existing ones (line numbers shifted by the header).make testafter: exit 0, 72 round-trip OKs (66 + 6 new rsi17 checks). Stats identity: rsi16 vs rsi17 --bench on easylist differs ONLY in encode/decode MBps (8.56/35.28 -> 9.19/42.22 single-run). - Leg 2: peak (r17-peak.log). peak_live rsi16 -> rsi17: burpsuite 63,984,523 -> 57,232,965 (-10.6%, -6,751,558); covid 51,846,930 -> 50,068,205 (-3.4%); warandpeace 45,894,404 -> 41,271,484 (-10.1%); easylist 41,281,682 -> 36,428,052 (-11.8%); c-bundle 36,526,496 -> 29,305,918 (-19.8%). Allocation-level the saving is exact: the 2^23-24 bucket drops 33,554,432 bytes across the run (4 x 8,388,608 decoder ent_bits allocs gone) and the 2^20-21 bucket gains 4,194,304 (4 x 1,048,576); total_alloc 454,387,343 -> 425,027,215 (-29,360,128 = exactly 4 x 7,340,032). The peak's 0.59MB shortfall vs the predicted 7.34MB is peak-instant mix, not a missing saving. maxrss burpsuite ~72MB flat (72128-72408 KB default; 71136-72724 KB pad64M).
- Leg 2: knee (r17-knee.log, r17-spot.tsv, 8 rotations, guarded). Ratios 0.7124 / ex-covid 0.7406 everywhere, ob-id 44/44. Spot decode medians: r16-128M 12.14 / 22.71 / 19.72 / 18.17; r17-128M 12.07 / 22.59 / 19.47 / 17.93 (-0.5% / -0.5% / -1.3% / -1.3% -- inside the small-file noise band); r17-64M 12.09 / 22.61 / 19.48 / 17.94; r17-32M 12.05 / 22.59 / 19.46 / 17.88 (1.00x on the spot files, as in Round 16). Corpus-wide decode: 128M 46.2, 64M 46.4 (+0.4%), 32M 44.0 (-4.8%); ex-covid 46.4 / 46.1 / 44.1. Encode flat ~12.0 MB/s all pads. Same-state recheck pair B (r17-recheck.log): 32M-b 43.9 vs 128M-b 45.3 (-3.1%, ex-covid -2.6%); pooled 32M 43.95 vs 128M 45.75 (-3.9%, ex-covid -3.8%). Per-file B: median 0.99x, min 0.84, max 1.16, 17 below 0.97x / 10 above 1.03x -- asymmetric toward slower, a real spill (contrast Round 16 pair B for 64M: symmetric 9/10). 64M matches 128M within ~1% (pooled +0.4% / -0.6% ex-covid); 32M is still a real cliff at ~-4%.
- Speed note. Corpus-wide decode is UP: r17 pooled 128M 45.75 vs r16 pooled 42.6 (+7.4%), and the easylist stats-identity single run went 35.28 -> 42.22 (+20%). Mechanism (same direction as the Round 16 hypothesis, now with corpus-wide evidence): 16B rows vs 128B rows is 8x less cache traffic per row touch on big files; the small spot files show ~flat because decode there is fixed-cost dominated. Spot ENCODE is -3-5% on the four small files (8.94 vs 9.18 etc.) with corpus encode flat (11.9-12.1 vs 11.9-12.3) -- the encoder never touches ent_bits (NULL), so there is no code mechanism for an encode slowdown; this is small-file noise, noted not chased.
- Floor measurement. Burpsuite in+c+out = 13.69 + 13.29 + 13.69 = 40.67MB ~= 2.97x input. Peak is 57.23MB, so ~16.6MB sits above in+c+out: the decoder dict (trie ~12.6 + ent_bits 1.05 + headers 0.79 ~= 14.4MB) + node16/best16 tables 0.5MB + token array / litbuf / misc ~1.6MB. The floor is therefore in+c+out+dict, NOT in+c+out alone -- the decoder trie is now the dominant dict piece and the binding constraint on the peak.
- Numbers. Ratios 0.7124 / ex-covid 0.7406 (unchanged, 44/44 identical). Corpus-wide enc ~12.0 MB/s all pads; dec 46.2 (128M pooled 45.75 across pairs A/B) vs 42.6 in Round 16 (+7.4%); 64M 46.4 (matches 128M), 32M pooled 43.95 (-3.9%). Spot decode medians ~1.00x at 64M and 32M vs 128M. Peak live bytes: burpsuite 57.2MB (54.6 MiB), covid 50.1MB, warandpeace 41.3MB, easylist 36.4MB, c-bundle 29.3MB (was 64.0/51.8/45.9/41.3/36.5MB). maxrss burpsuite ~72MB (flat).
- Verdict. PARTIAL. The cut worked exactly as designed -- the allocation-level saving is exact (4 x 7,340,032 bytes), the peak fell 10.6%, ratios are identical, and decode is +7% corpus-wide -- but the round's stated goal was not met: burpsuite peak is 57.23MB, missing the <56MB bar by 1.23MB, and 32M still cliffs at ~-4% pooled (two pairs, same as Round 16), so 32M does not match 128M within ~1%. The measured floor is in+c+out+dict, and the decoder trie (~12.6MB) is now the binding piece -- Round 18. Promoted binary is now rsi17 (strictly better: lower peak, faster decode, identical ratios). Default pad STAYS 128MB; a 64MB pad is still free, a 32MB pad still costs ~4%.
- Process change. (1) Fork-script anchors must include a distinguishing following line when two sites share the first two lines (comp-add vs lit-add) -- count==2 is the signal, not a reason to relax the assert. (2) A "no direct access" guard must exempt the accessor's own definition (ent_bits_row's body is the one legitimate direct arithmetic site). (3) Sed-derived scripts (r17-peak.sh, r17-recheck.sh) kept stale "R16 ..." labels in echo strings the patterns didn't cover -- check the DONE echo and prof labels after a sed fork, not just the binary names. (Fixed in place: r17-peak.sh DONE echo + rss17 labels, r17-recheck.sh DONE echo.)
Round 18 — shrink the decoder trie, the new binding piece (CLOSED, WIN, qualified)
- Idea. Round 17 measured the floor: burpsuite peak 57.23MB = in+c+out 40.67MB + decoder dict ~14.4MB + tables 0.5MB + misc ~1.6MB. The trie (~12.6MB, ~1M nodes x 12B TrieNode {child[2], dict_idx}) is now the dominant dict piece and the binding constraint. Pack the node to 8B (one uint64: two 22-bit child indices + 20-bit dict_idx, both +1-biased) behind accessors, then re-test the knee at 32M/64M/128M. The 56MB bar is 1.23MB away; a trie cut of ~4MB would clear it with margin.
- Success criterion. Burpsuite peak_live < 56MB with ratios identical (0.7124 / ex-covid 0.7406) and no speed regression; 32M then matches 128M corpus-wide within ~1% (pooled), or a measured statement of which buffer dominates the remaining peak and why it cannot shrink.
- Status. Done; WIN, qualified (peak goal met with margin, ratios identical, 32M cliff halved but not closed, decode cost measured and bounded -- see Verdict).
- Leg 0: controls on rsi17 + make test (before). All reproduce exactly (r18-controls.log): make test exit 0, 72 round-trip OKs; lit0 0.7530, r1best 0.7274, r2win 0.7220, r3s12 0.7124 (ob-id 44/44), r3s13 0.7054.
- Leg 1: measurement (rsi18-probe.c, scratch fork of rsi17.c +
stderr probe; r18-probe-corpus.tsv, serial, all 44 files).
Burpsuite decode: trie_n=1,002,994 trie_cap=1,048,576
trie_bytes=12,582,912 (6 resets, next_idx 56018, ntok 326,309 ->
toks 652,618B, lit_len 12,815,138 -- litbuf is a pointer into
in, no separate alloc -- out_len 13,682,421, tables=1). So the trie is 12.58MB of the ~16.6MB above in+c+out; the rest is ent 0.79 + ent_bits 1.05 + ent_node 0.26 + node16/best16 0.50 + toks 0.65 + misc ~0.3MB. Corpus-wide max trie_n = 1,954,129 on gen-mixed-l0.zip (end trie_n only 1,070,798; cap 2,097,152 -> 25,165,824 bytes on a 746KB file -- cap is sticky across resets). Next: gen-numeric.csv 1,663,802; data.json 1,612,485; pride-and-prejudice 1,597,800; covid 1,578,108; c-bundle 1,486,567; warandpeace 1,435,176. Tables on for 17/44 files. Max ntok 1,629,126 (covid) -> toks array 3,258,252 bytes. Consequences: (a) 21-bit children would NOT be safe (corpus max 1.95M is 93% of 2^21-1) -- 22-bit children chosen, 2.1x headroom. (b) Node-cap / prune (candidate b) is a dead end: every trie node is a live path node (no dead nodes within an epoch; resets discard whole epochs). (c) Freeing the token array before decode (candidate c) is impossible: decompress_tokens consumes toks sequentially; it IS the decode input. (d) Shrinking trie_cap on reset would not move the peak either: the peak instant is at/near the max epoch (burpsuite max_n == end trie_n). - Leg 2: the fork (make-rsi18.py, rsi18.c). TrieNode is now one
uint64 word: child[0]+1 and child[1]+1 in 22 bits each (bits
0..21, 22..43), dict_idx+1 in 20 bits (44..63). All access through
trie_child/trie_set_child/trie_dict/trie_set_dict; ceilings
enforced loudly (trie_new_node dies past TRIE_NODE_MAX = 2^22-2,
dict_init dies if cap > 2^20-1; MAX_W=16 caps entries at 65,536).
Env overrides RSI17_* -> RSI18_*. Makefile: rsi18 rule + test
section mirroring rsi17's (cross-decode vs rsi17 and rsi5 both
directions). BUG FOUND BY TOKDUMP, fixed in the fork (sentinel
mismatch): the first build stored children RAW (0 = none), but
every walk/insert site tests
ch < 0. A missing child returned 0, passed the test, and the walk cycled root -> seed -> root ... to the end of the input (debug print: pos=0 best=1 len=511 on a 64-byte file; --legacy -c wrote a 17-byte file = header only) while inserts clobbered the root's dict. The encoder emitted only seed tokens (distinct=6 on easylist) and every decode failed. Fix: BOTH fields are +1-biased and trie_child returns -1 for a missing child -- the fix lives in the one accessor, not in 11 call sites (and thend < 0tests on node16 stay< 0, since node16 uses raw -1). Also caught by the same tokdump round: my first.dict_idxcount in the fork script was 24, true count 30 -- theif (d->trie[nd].dict_idx >= 0) { best_idx = d->trie[nd].dict_idx; ... }lines carry TWO occurrences each. Verification of the fixed fork before any sweep: standalone accessor unit test OK (r18-unit-trie.c, incl. missing child == -1, zero word == empty, max child 4,194,302, dict 65,535); tokdump identical rsi17 vs rsi18 on the 2000-byte easylist head (nominal config); stats identity on easylist differs ONLY in MBps (8.49/38.39 -> 8.23/34.26 single-run). Build warnings identical to rsi17's 3 pre-existing ones.make testafter (ternary build): exit 0, 78 round-trip OKs (72 + 6 new rsi18 checks). - Leg 3: peak (r18-peak.log). peak_live rsi17 -> rsi18: burpsuite 57,232,965 -> 53,038,661 (-7.3%, -4,194,304 = EXACTLY 1,048,576 x 4B, the predicted trie saving); covid 50,068,205 -> 41,679,597 (-16.8%, -8,388,608 = 2,097,152 x 4B); warandpeace 41,271,484 -> 32,882,876 (-20.3%); easylist 36,428,052 -> 28,039,444 (-23.0%); c-bundle 29,305,918 -> 20,917,310 (-28.6%). (The four non-burpsuite files all sit at trie_cap 2,097,152, so each saves the full 8,388,608.) total_alloc burpsuite 425,027,215 -> 360,015,503 (-65,011,712; the realloc growth chain is 2/3 size at every step). maxrss burpsuite ~72MB -> ~64MB (63880-64248 KB default; 63756-64788 KB pad64M). The 56MB bar is CLEARED: burpsuite peak 53.04MB, 2.96MB of margin.
- Leg 4: knee (r18-knee.log, r18-spot.tsv, 8 rotations, guarded; ternary build). Ratios 0.7124 / ex-covid 0.7406 everywhere, ob-id 44/44. Spot decode medians (r17-128M -> r18-128M): ms-excel 12.09 -> 11.72 (-3.1%), readxl 22.61 -> 21.82 (-3.5%), gapminder 19.47 -> 15.69 (-19.4%), stocks 17.95 -> 14.53 (-19.1%). Spot encode: 8.91 -> 8.39 (-5.8%), 13.12 -> 12.43 (-5.3%), 5.83 -> 5.06 (-13.2%), 5.64 -> 4.97 (-11.9%). The r17 anchor reproduced Round 17's medians within 1.3%, so the drop is real, not noise. Corpus-wide (ternary): 128M dec 43.5, 64M 43.0, 32M 42.7; ex-covid 43.2 / 43.0 / 42.5. 32M vs 128M: -1.8% (-2.5% vs the control run) -- the cliff HALVED vs Round 17's pooled -3.9%, but not yet <1%. Pattern: the two -19% files are token-dense, tables-OFF (lit_len 1,307 / 2,404 bytes; tables=0 in the probe) CSVs; the -3% files are literal-heavy, tables-ON xlsx. The packed node costs ALU/latency on every trie step, and tables-off files pay it on every walk bit.
- Leg 4b: branchless trie_child (r18-spot2.tsv, decode loop, asm).
The first build's trie_child used a ternary (test+cmove per step).
Branchless form
(int32_t)field - 1(0 -> -1 exactly, field never- recovered the ENCODE regression almost fully (spot2 encode
medians -2.8% / -3.6% / -3.1% / -3.4% vs r17) but DECODE barely
moved (spot2: -5.8% / -5.7% / -20.6% / -20.1%). Decode-only loop
(200x -d, median of 3): gapminder rsi17 1446ms -> rsi18 1638ms
(-11.8%); stocks 1343 -> 1506 (-10.8%); ms-excel 456 -> 464
(-1.7%); warandpeace 11788 -> 12038 (-2.1%). (The loop dilutes
the gap with identical file I/O; --bench -20% is the truer
in-memory figure.) Warandpeace shows only -2% because its decode
is dominated by the rANS token decode (882K tokens), which is
identical; the trie share is small there. Gapminder's 26.7K tokens
leave the trie inserts exposed. objdump of longest_match (rsi18):
the walk is already near-optimal for this packing -- trie_dict is
CSE'd to one computation per step, and the none-test reuses the
AND's flags (LEA sets no flags, so the
jnetests field != 0). The remaining cost is inherent: the chase gains a shift+and+sub (~2-3 cycles) of dependent latency per step over the old direct child load. A raw-0 +ch <= 0variant would save only the final sub (~1 cycle/step) at the cost of touching 11 call sites with the exact sentinel class that already bit once this round -- not attempted; left for Round 19 if the decode cost is judged worth chasing.
- recovered the ENCODE regression almost fully (spot2 encode
medians -2.8% / -3.6% / -3.1% / -3.4% vs r17) but DECODE barely
moved (spot2: -5.8% / -5.7% / -20.6% / -20.1%). Decode-only loop
(200x -d, median of 3): gapminder rsi17 1446ms -> rsi18 1638ms
(-11.8%); stocks 1343 -> 1506 (-10.8%); ms-excel 456 -> 464
(-1.7%); warandpeace 11788 -> 12038 (-2.1%). (The loop dilutes
the gap with identical file I/O; --bench -20% is the truer
in-memory figure.) Warandpeace shows only -2% because its decode
is dominated by the rANS token decode (882K tokens), which is
identical; the trie share is small there. Gapminder's 26.7K tokens
leave the trie inserts exposed. objdump of longest_match (rsi18):
the walk is already near-optimal for this packing -- trie_dict is
CSE'd to one computation per step, and the none-test reuses the
AND's flags (LEA sets no flags, so the
- Leg 5: recheck2 (r18-recheck2.log; branchless binary, same-state;
the knee ran on the ternary build, so its corpus numbers are stale
for the shipped binary).
make teston the final binary: exit 0, 78 round-trip OKs. Pair B: r18-pad128M-b dec 43.9, r18-pad32M-b dec 43.1 (-1.8%; ex-covid 43.8 -> 43.0, -1.8%). Pooled with pair A (42.7 vs 43.5): 32M 42.9 vs 128M 43.7 = -1.8% pooled. Per-file pair B: median 0.99x, min 0.87, max 1.22, 10 below 0.97x / 7 above 1.03x. Same-state r17 anchor: r18-r17-128M dec 45.4 (ex-covid 45.4) vs r18-pad128M-b 43.9 -> rsi18 decode -3.3% corpus-wide same-state (ex-covid -3.5%); corpus encode flat within run-to-run noise (spot medians -3%). - Floor update. Burpsuite peak 53.04MB = in+c+out 40.67MB +
dict ~11.0MB (trie 8.39 + ent_bits 1.05 + ent 0.79 + ent_node 0.26
- tables 0.50) + toks 0.65MB + misc ~0.7MB. The trie is STILL the biggest dict piece at 8.39MB.
- Numbers. Ratios 0.7124 / ex-covid 0.7406 (unchanged, 44/44 identical). Corpus-wide enc ~12.7 MB/s, dec 43.9 (128M, branchless pair B) vs r17 45.4 same-state (-3.3%); 64M 43.0, 32M pooled 42.9 (-1.8%). Spot decode medians (spot2): 11.36 / 21.39 / 15.43 / 14.34 vs r17 12.06 / 22.68 / 19.44 / 17.94; spot encode -3% approx. Peak live bytes: burpsuite 53.0MB, covid 41.7MB, warandpeace 32.9MB, easylist 28.0MB, c-bundle 20.9MB (was 57.2/50.1/41.3/36.4/29.3MB). maxrss burpsuite ~64MB (was ~72MB).
- Verdict. WIN, qualified. The peak goal is met with margin (burpsuite 53.04MB < 56MB; all five big files down 7-29%), ratios are identical, and the 32M cliff halved (-3.9% pooled in Round 17 -> -1.8% pooled here, pairs A and B agreeing exactly) -- but the round's success criterion is not fully met: 32M does not match 128M within ~1%, and decode regressed -3.3% corpus-wide same-state (-20% worst case on small token-dense tables-off files; encode recovered to ~-3% spot after the branchless fix). Promoted binary is now rsi18: the peak is the binding constraint the last three rounds chased, the cost is bounded and measured, and Round 19 owns the decode recovery. Default pad STAYS 128MB; a 64MB pad is still free, a 32MB pad now costs ~2% (was ~4%).
- Process change. (1) A packed "none" must return the exact
sentinel the call sites already test (
ch < 0needs -1, not a raw 0 that "can't occur") -- fix sentinel mismatches in the one accessor, never by re-testing at 11 sites. (2) Count asserts in a fork script need grep-verified per-pattern counts: theif (x) { best = x; }lines carry TWO occurrences each, which is exactly what a hand count misses. (3) A fork-script change that alters speeds invalidates the knee corpus numbers -- re-run them on the FINAL binary (recheck2) before reporting; the knee's ternary-build numbers were stale after the branchless rebuild. (4) files.tsv has 3 columns:read -r f relsilently swallows the type into the path and all 44 runs fail -- alwaysread -r f rel _rest. (5) Cross-binary speed claims need a same-state anchor: Leg-0 controls hours apart cannot ground a -4% claim; recheck2's back-to-back r17 run can.
Round 19 — recover the decode cost of the packed trie (OPEN)
- Idea. Round 18 bought the peak (53.0MB) at decode's expense:
corpus-wide -3.3% same-state, worst -20% on small token-dense
tables-off files (spot2). The asm says the walk is already
near-optimal for the +1-biased packing (trie_dict CSE'd, none-test
reuses the AND's flags); the remaining cost is ~2-3 cycles of
dependent latency per trie step on the chase. Candidates: (a) raw-0
child storage +
ch <= 0at the 11 walk/insert sites -- saves the final sub (~1 cycle/step); the sentinel risk is real (it bit in Round 18), so verify with tokdump + the full make test + spot2 before trusting it; (b) audit the insert path for redundant unpacks the way the walk was audited; (c) re-examine the Round 8 tables gate for token-dense files -- tables-ON files lost only ~6% decode, tables-OFF files ~20%, so forcing tables on for token-dense decodes may be cheaper than the 0.5MB they cost. Then re-test the knee at 32M/64M/128M. The 32M cliff (-1.8% pooled) is still open alongside. - Success criterion. Spot decode medians within ~5% of r17 on all four files with peak staying < 56MB and ratios identical (0.7124 / ex-covid 0.7406); or a measured statement that the packed-node chase latency is the floor and the -3% corpus cost is the price of the 4.2MB peak cut.
- Status. Idea selected; not started.
- Numbers. (pending)
- Verdict. (pending)
- Process change. (pending)