Repository navigation
[validation] lazy: skip match counts that cannot beat the current score - #1
Draft
jeffchen006 wants to merge 1 commit into
Draft
jeffchen006 wants to merge 1 commit into
jeffchen006 wants to merge 1 commit into
Conversation
jeffchen006
force-pushed
the
perf/lazy-match-length-floor
branch
from
October 22, 2026 15:16
09fd6a0 to
222606c
Compare
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.
Fork CI validation for a proposed upstream PR. Compatibility repairs are on this fork's dev branch; the optimization branch remains focused.
What and why
Avoid fully counting lazy-search candidates whose lengths cannot improve the current length/offset score. Hash-chain and row searches accept a useful-length floor; initial/extDict searches keep the existing floor and the binary-tree wrapper keeps its existing behavior.
A candidate replaces the current solution only if
4*ml2 - highbit(ofb2) > gain1. Searched matches haveofb2 >= ZSTD_REP_NUM+1, hencehighbit(ofb2) >= 2: lengthsml2 <= floor((gain1+2)/4)cannot improve the score. The higher floor is used only with a current match length >=8 and is capped below the remaining input length. No public API, format or compression parameter changes.RFC status: performance trade-offs remain unresolved. The Mac L9 benefit reproduces, but an x86/GCC random-input slowdown reproduces too. This is not a general performance-win claim.
Measurements
Baseline
49cf51799ea051457f57243527aa2058f999f005(dev); candidate222606cee24d2fc3cb1c514640903a21b6f40dfc. The original measured commit09fd6a0has the identical full source treed821a0cc6f0fc989bc95675bc8b734102382de53.Apple M4 Max (14 cores/36 GiB), macOS 26.3, Apple Clang 17/GCC 15.2; AMD EPYC 9654, Ubuntu 22.04, Clang 14/GCC 11.4. Separate binaries,
CFLAGS=-O3 DEBUGLEVEL=0 HAVE_ZLIB=0 HAVE_LZMA=0 HAVE_LZ4=0, single thread. Silesia is all 12 files, 211938580 bytes, concatenated alphabetically, not tar. Other inputs include official enwik8 and seeded 16 MiB random data.Fresh independent checks use five alternating pairs, built-in
-q -bLEVEL -i5 DATA. Throughputs are separate medians; changes are medians of paired ratios. Ranges are individual pair extrema, not confidence intervals.The original separate seven-round Mac/Clang experiment found Silesia L9+3.65%, L6+0.55%, L1/L3 near neutral; per-file geometric means were L9+3.16%, L6+0.58%. Fresh longer Mac/Clang L6 file checks remain mixed: x-ray-1.18%, sao-1.02%, osdb-0.54%. These datasets/configurations are not pooled into one score.
The supplemental screen covers levels 5/6/7/9/12/13, random/text/mixed inputs, row/hash-chain, 32 KiB chunks, 1/32 KiB streaming and raw-dictionary compression. Both throughput directions, compressed sizes, all losses, A/A controls, outliers, code-size growth and fixed-work counter/profile diagnostics are retained in the full report.
GCC random-data A/A ranges from -1.78% to +1.37%. A separate fixed-work diagnostic has nearly unchanged GCC instruction/cycle counts, so the cause of the in-memory slowdown remains unresolved; it is not proof of an algorithmic or architecture-specific regression.
Mac desktop apps remained open; CPU placement/frequency/ASLR were uncontrolled. EPYC is shared: benchmark affinity and scheduling/SMT guards do not control shared memory/cache/frequency. Initial EPYC A/A had several-percent variation. Initial Mac A/A overlapped data transfer and is excluded; fresh final and data-matched random A/A controls are separate. No architecture-wide, decoder, dictionary or streaming improvement is claimed. No alignment-perturbation experiment was performed.
Validation and evidence
make checkpassed baseline/candidate; bounded ASan/UBSan fuzzer 60s and streaming 30s passed.make staticAnalyzeactually analyzed 41 units includingzstd_lazy.cfor baseline, candidate and the separate CLI fix. All three exit 2 with the same 12 inherited diagnostics; no new diagnostics. This is not a clean static-analysis pass. Analyzer/tool versions, diagnostics and reproduction commands are retained.Related work
Searched open/historical issues and PRs. facebook#4841 changes the same matchfinder area differently; this floor has not been benchmarked in combination with it. facebook#2587 concerns another continuation-search idea. Merged facebook#3552/facebook#3295/facebook#4165/facebook#3543/facebook#4418 informed the expanded validation; their evidence does not establish a universal acceptance threshold.
Checklist
CLA signed (contributor confirmation).
Tools used
An AI-assisted optimization pipeline produced the candidate; Codex assisted with validation, benchmarking, analysis and PR preparation.