spike(pz2): cross-block dict tier PASSES — segment-scoped head dict, blob 30.48%#146
Merged
Merged
Conversation
…blob 30.48% Executes the roadmap's spike #2 (previously planned, never run — the design doc's "as spiked" citation was aspirational). New library APIs: pz2::encode_with_prefix (matches may reach into a dict prefix; parse over prefix||block, prefix tokens dropped, straddles re-emitted as literals) and pz2::decode_with_prefix (primed output buffer), plus examples/pz2_dict_probe.rs with three modes: sliding prefix (ceiling), fixed head dict, per-32MiB-segment head dict. All round-trip-verified. Findings (clean-slate-codec.md section 11): 1. Per-file redundancy is GLOBAL, not local-recency: a fixed head dict captures 66-100% of the sliding ceiling (samba -1.35pp, webster -1.08, nci -0.61 at 16 MiB) — no decode serialization needed. 2. The dict must be scoped per SEGMENT: on the concatenated blob a global head captures only -0.15pp (alien content), while per-32MiB-segment heads capture -0.57pp -> 30.48%, ~0.9pp under pzstd-3. Production architecture documented: Pz2d segments with [dict_len] + framed blocks, 2-wave Arc-shared decode (worker arenas or two-region splice — naive per-block priming ruled out by arithmetic), and the encode-side blocker: a frozen shared match-finder (next commit). Tests: prefix round-trip + wrong-prefix safety unit test; 9 pz2 tests pass; fmt/clippy clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 10, 2026
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.
Summary
Executes the roadmap's dict-tier spike (#2 — previously planned but never run). Adds
pz2::encode_with_prefix/decode_with_prefixand a three-mode probe; measures the design fork that decides the production format.Findings
1. Per-file redundancy is global, not local-recency. A fixed head dict captures 66–100% of the sliding-prefix ceiling — the dict tier needs no decode serialization:
2. The dict must be segment-scoped. On the concatenated blob, a global head dict is nearly useless (−0.15pp — the head is dickens, alien to later content); per-32 MiB-segment heads recover it:
30.48% is ~0.9pp under pzstd-3 (31.40%) at unchanged decode parallelism — P2's segment tier earning its place.
Production architecture (documented in §11)
Pz2dsegments ([dict_len]+ framed blocks), 2-wave Arc-shared decode with worker arenas, and the encode-side prerequisite: a frozen shared match-finder (dict chains built once, consulted by all workers) — that's the next commit; the spike's per-block re-parse is measurement-only.Test plan
test_prefix_round_tripunit test (dict reach asserted smaller than cold encode; wrong-prefix decode must not panic)decode_with_prefix🤖 Generated with Claude Code