perf(pz2d): cap frozen-dict chain walks at 16 links — encode −44% for +0.06pp#152
Merged
Merged
Conversation
…14.1 s (-44%) for +0.06pp The pz2d encode inflation (§11b: 2.9x concurrent CPU blowup) is the frozen-dict walk itself — every link is a random read into a cold multi-MiB prev array, multiplied across 7 concurrent segments. Frozen walks in find_best now get their own budget (lz77::DICT_CHAIN_CAP), applied on top of the live walk's leftover max_chain, so walking less attacks the inflation at its source. Blob e2e sweep: 64 -> 25.0 s/30.475%, 32 -> 18.6/30.500, 24 -> 16.4/30.515, 16 -> 14.1/30.535 (shipped), 8 -> 12.65/30.570. No sharp knee; 16 trades +0.06pp (still 0.87pp under pzstd-3) for -44% encode wall and -40% CPU; below 16 the returns invert. Decode is neutral-to-better on the capped wire (39.0 vs 40.5 ms same-session — fewer far-dict matches, fewer random dict reads). Also re-anchored §11c's decode headline same-session: master v1 44.9 ms vs arena 39.1 ms (1.15x) — the -13% holds; absolute walls drift ±10% with machine state, so compare binaries within one hyperfine invocation only. Ledger: clean-slate-codec.md §11d. Suite: 745 + 598 green, fmt/clippy clean, blob round-trip verified. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Task #12 part 2 (encode cache tuning). The pz2d encode inflation (§11b: 2.9× concurrent CPU blowup) is the frozen-dict walk itself — every chain link is a random read into a cold multi-MiB prev array, multiplied across 7 concurrent segments. The weak-local-match gate was already measured dead (−8% for +0.018pp), so the remaining §11b lever was a dict-specific budget: frozen walks in
find_bestnow cap atlz77::DICT_CHAIN_CAP = 16links, on top of (never exceeding) the live walk's leftovermax_chain.Measured (202 MB Silesia blob, e2e CLI encode)
No sharp knee; 16 is the judgment call — −44% wall and −40% CPU for +0.06pp, keeping pz2d 0.87pp under pzstd-3. Below 16 the returns invert. Decode is neutral-to-better on the capped wire (39.0 vs 40.5 ms, same-session hyperfine — fewer far-dict matches = fewer random dict reads).
Also re-anchored §11c's decode headline in one hyperfine invocation: master v1 44.9 ms vs arena 39.1 ms (1.15×) — PR #150's −13% holds; absolute walls drift ±10% with machine state, which is now noted in the ledger (compare binaries within a single hyperfine run only).
Validation
Round-trip verified on the blob at cap 16. Suite: 745 + 598 unit tests green, doctests pass, fmt/clippy clean. Only pz2d's encode path consults the frozen dict, so no other pipeline is affected; decode is untouched. Ledger: clean-slate-codec.md §11d.
🤖 Generated with Claude Code