Skip to content

perf(pz2): auto-greedy parse — blob 31.0%, Pareto-superior to pzstd -3#145

Merged
ChrisLundquist merged 1 commit into
masterfrom
claude/pz2-auto-greedy
Jun 10, 2026
Merged

perf(pz2): auto-greedy parse — blob 31.0%, Pareto-superior to pzstd -3#145
ChrisLundquist merged 1 commit into
masterfrom
claude/pz2-auto-greedy

Conversation

@ChrisLundquist

Copy link
Copy Markdown
Owner

Summary

The per-file probe (examples/pz2_parse_probe.rs, all 12 Silesia files, 2 MiB blocks) overturned the inherited "greedy regresses structured data" rule for the pz2 wire: greedy ≤ lazy on 11/12 files (dickens −3.2pp, reymont −3.0, sao −2.3, webster/mr −1.9; worst case mozilla +0.03pp = noise). The lazy deferral's advantage belonged to the flag-stream wire and smaller windows, not to the parse itself at 2 MiB reach.

Pz2's Auto strategy now parses greedy per block, with one guard (pz2_auto_greedy): near-random blocks (entropy > 7.5, match density < 0.1 — same rule as select_pipeline) stay lazy since there's no ratio to buy. Explicit --lazy/--greedy respected; other pipelines untouched.

Results (blob e2e, warm-cache hyperfine)

codec ratio decode wall encode wall
pz pz2 (this PR) 31.04% 16.8 ms (12.0 GiB/s) 3.15 s (64 MiB/s)
pz pz2 (lazy, prior) 32.00% 17.9 ms 1.89 s
pzstd -3 -p18 31.40% 22.9 ms
zstd -3 (1 thread) 31.40% 139.2 ms

Decode got faster with greedy — fewer, longer sequences mean fewer entropy symbols and fewer splice iterations (user CPU 181 → 172 ms).

pz2 is now Pareto-superior to pzstd -3 on (ratio, parallel decode): 0.36pp better ratio AND 1.36× faster wall. Encode at 64 MiB/s all-cores is the deliberate decode-first (P1) trade, recoverable later via GPU candidate generation.

Test plan

  • 741 + 592 tests pass; fmt + clippy clean
  • 202 MB blob round-trip verified via CLI at the new default
  • Probe table in clean-slate-codec.md §10

🤖 Generated with Claude Code

The per-file probe (examples/pz2_parse_probe.rs, 2 MiB blocks) overturned
the inherited "greedy regresses structured data" rule for the pz2 wire:
greedy <= lazy on 11/12 Silesia files (dickens -3.2pp, reymont -3.0,
sao -2.3; worst case mozilla +0.03pp = noise). The lazy deferral's win
belonged to the flag-stream wire and smaller windows, not to the parse
itself at 2 MiB reach.

Pz2's Auto strategy now parses greedy per block, with one guard
(pz2_auto_greedy): near-random blocks (entropy > 7.5, match density < 0.1
— same rule as select_pipeline) stay lazy since there is no ratio to buy.
Explicit --lazy / --greedy respected; other pipelines untouched.

Blob e2e: 32.00% -> 31.04% (vs pzstd/zstd-3 31.40%), decode IMPROVES
17.9 -> 16.8 ms all-cores (fewer, longer sequences; 12.0 GiB/s, 1.36x
faster than pzstd -3), encode 1.89 -> 3.15 s (64 MiB/s — the P1 trade).
pz2 is now Pareto-superior to pzstd -3 on (ratio, parallel decode) and
dominates lzf on every axis except encode.

741 + 592 tests, fmt, clippy clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ChrisLundquist ChrisLundquist merged commit a84054e into master Jun 10, 2026
@ChrisLundquist ChrisLundquist deleted the claude/pz2-auto-greedy branch June 10, 2026 18:03
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