feat(pz2): frozen shared match-finder — dict-tier encode at 3x spike speed, same ratio#147
Merged
Merged
Conversation
…speed, same ratio The encode-side prerequisite for the Pz2d dict tier (#146 findings): - lz77::FrozenDict: immutable hash-chain tables built ONCE over a dict prefix (one insert per position, no chain walks), Arc-shared by all workers. Dict-relative coordinates; the parse input must carry the dict as its prefix (worker arena = dict||block) so compares read one buffer. - HashChainFinder::set_frozen_dict + a second chain walk in find_best over the frozen tables after the block-local walk (shared chain budget, recency first). The pos >= dict.len guard makes every read in-bounds regardless of caller behavior. - lzseq::tokenize_with_dict(input, start, dict, config): parse starts at the dict boundary — no dict re-parse, no token-skip/straddle handling (tokenize_with_config delegates with (0, None)). - pz2::encode_with_frozen_dict (wire-writing extracted into a shared encode_sequences; output decodes with the existing decode_with_prefix). Measured (pz2_dict_probe --frozen, per-32MiB-segment, blob): - ratio IDENTICAL to the re-parse spike: 30.475% at 16 MiB dict (-0.57pp vs no dict, ~0.9pp under pzstd-3) - encode 70.5s vs the spike's 208.8s ST (3x); remaining cost is the dict chain walks themselves (5.3x no-dict baseline) - a 32-byte weak-local-match gate was measured and REJECTED (-8% time, +0.018pp: most text positions have weak local matches — the walk is inherent; tune via dict chain caps at integration time) Remaining for shipping Pz2d (documented in section 11): container segment framing, 2-wave parallel decode with Arc dict + worker arenas, encode-cost tuning pass. 594 + 741 tests, fmt, clippy clean. 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.
Summary
Builds the encode-side prerequisite identified in #146: a frozen shared match-finder so the dict tier doesn't re-parse the dictionary per block.
lz77::FrozenDict— immutable hash-chain tables built once over the dict (insert-only, no walks),Arc-shared across workers. Coordinates are dict-relative; workers hold adict‖blockarena so compares read one contiguous buffer and no two-region logic exists anywhere.find_bestgrows one extra chain walk over the frozen tables after the block-local walk (shared budget, recency first), with apos >= dict.lenguard making every read provably in-bounds.lzseq::tokenize_with_dict(input, start, dict, config)— the parse starts at the dict boundary: no dict re-parse, and the spike's token-skipping/straddle handling disappears.pz2::encode_with_frozen_dict— wire-compatible with the existingdecode_with_prefix.Measurements (per-32 MiB-segment head dict, blob)
Identical ratio at 3× the speed. The remaining 5.3× over baseline is the dict chain walks themselves — a 32-byte weak-local-match gate was measured and rejected (−8% time for +0.018pp; most text positions have weak local matches, so the walk is inherent). Integration-time tuning levers: dict-specific chain caps, sampled insertion, 4 MiB dicts (−0.31pp at 33.7 s).
What remains for
Pz2d: container segment framing, 2-wave parallel decode (Arc dict + worker arenas), and the tuning pass — all documented inclean-slate-codec.md§11.Test plan
test_frozen_dict_round_trip(wire-compat withdecode_with_prefix, dict-reach assertion, empty-dict path)--frozenprobe round-trip-verifies every block🤖 Generated with Claude Code