Skip to content

spike(pz2): cross-block dict tier PASSES — segment-scoped head dict, blob 30.48%#146

Merged
ChrisLundquist merged 1 commit into
masterfrom
claude/pz2-dict-spike
Jun 10, 2026
Merged

spike(pz2): cross-block dict tier PASSES — segment-scoped head dict, blob 30.48%#146
ChrisLundquist merged 1 commit into
masterfrom
claude/pz2-dict-spike

Conversation

@ChrisLundquist

Copy link
Copy Markdown
Owner

Summary

Executes the roadmap's dict-tier spike (#2 — previously planned but never run). Adds pz2::encode_with_prefix/decode_with_prefix and 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:

file sliding @16Mi head @16Mi capture
samba −1.344 −1.347 ~100%
webster −1.111 −1.075 97%
nci −0.673 −0.606 90%
mozilla −0.745 −0.494 66%

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:

blob dict 4Mi dict 16Mi
global head −0.155 −0.138
per-segment head −0.310 −0.569 → 30.48%

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)

Pz2d segments ([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

  • New test_prefix_round_trip unit test (dict reach asserted smaller than cold encode; wrong-prefix decode must not panic)
  • Every probe encode round-trip-verified via decode_with_prefix
  • 9 pz2 tests, fmt, clippy clean

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant