Repository navigation
test(matching): add ZSO-1 acceptance tests for bithash prefilter - #4621
Merged
Merged
Conversation
Adds the two ZSO-1 acceptance tests that complement the bithash prefilter implementation already merged in PR #3737: - bithash_rejects_at_least_seven_eighths_of_known_misses: builds a filter with N=1000 inserted rsums and probes with N=1000 disjoint known-miss rsums, asserting at least 87% reject at the bithash gate. Measured rate on this run: 97.2%. - bithash_state_does_not_leak_between_independent_indexes: builds two DeltaSignatureIndex values from distinct basis bytes and confirms a probe for blocks indexed in one never matches in the other, pinning the per-NDX lifecycle relied on by the ZSO-7 audit (docs/audits/zso-7-inc-recurse-per-segment-state-2026-05-21.md). No production code changes. Wire-byte parity is unaffected; golden tests stay green. Bithash design follows zsync 0.6.2 librcksum (Colin Phipps, http://zsync.moria.org.uk/, README acknowledgement added in PR #4597).
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Adds the two ZSO-1 acceptance tests that complement the bithash prefilter implementation already merged in PR #3737: - bithash_rejects_at_least_seven_eighths_of_known_misses: builds a filter with N=1000 inserted rsums and probes with N=1000 disjoint known-miss rsums, asserting at least 87% reject at the bithash gate. Measured rate on this run: 97.2%. - bithash_state_does_not_leak_between_independent_indexes: builds two DeltaSignatureIndex values from distinct basis bytes and confirms a probe for blocks indexed in one never matches in the other, pinning the per-NDX lifecycle relied on by the ZSO-7 audit (docs/audits/zso-7-inc-recurse-per-segment-state-2026-05-21.md). No production code changes. Wire-byte parity is unaffected; golden tests stay green. Bithash design follows zsync 0.6.2 librcksum (Colin Phipps, http://zsync.moria.org.uk/, README acknowledgement added in PR #4597).
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
Adds the two ZSO-1 acceptance tests that complement the bithash prefilter implementation already merged via PR #3737. The production code (insert at index build, probe before the
CompactLookupwalk, clear on rebuild) is in place on master; this PR pins the acceptance contract from the ZSO-1 brief in unit tests so future refactors can't silently regress the prefilter behaviour.bithash_rejects_at_least_seven_eighths_of_known_misses— builds a filter with N=1000 inserted rsums and probes with N=1000 disjoint known-miss rsums, asserting at least 87% reject at the bithash gate. Measured rate locally: 97.2%, comfortably above the 7/8 zsync density bound.bithash_state_does_not_leak_between_independent_indexes— builds twoDeltaSignatureIndexvalues from distinct basis bytes and confirms a probe for blocks indexed in one never matches in the other, pinning the per-NDX lifecycle relied on by the ZSO-7 audit atdocs/audits/zso-7-inc-recurse-per-segment-state-2026-05-21.md.Background
ZSO-1 (#2509) is the first of four zsync-inspired in-memory speedups for the matching pipeline. The bithash prefilter is a one-sided, 8x-oversized bit array probed between the
tag_table[sum1]gate and theCompactLookupwalk infind_match_*. It rejects ~7/8 of post-tag misses in O(1) using the full 32-bit rolling sum, all without touching the wire format.Production sites verified against the audit citations:
DeltaSignatureIndexatcrates/matching/src/index/mod.rs:70crates/matching/src/index/mod.rs:155(find_match_bytes_filtered) and:211(find_match_slices_filtered)populate_indexandrebuildincrates/matching/src/index/builder.rs:32,127The line numbers cited in the ZSO-1 brief have drifted slightly since the audit (the field sits at
mod.rs:70, not:44; probes are at:155/:211, not:165; clear is atbuilder.rs:127as cited). Behaviour matches the design exactly.Wire-byte parity
No protocol or serialisation surface is touched.
cargo nextest run -p protocol --all-features -E 'test(golden)'passes unchanged (407 tests).Acknowledgement
Bithash design follows zsync 0.6.2
librcksum(Colin Phipps, http://zsync.moria.org.uk/), per the README acknowledgement landed in PR #4597.Test plan
cargo nextest run -p matching --all-features— 320 tests pass.cargo nextest run -p protocol --all-features -E 'test(golden)'— 407 tests pass, no golden-byte drift.cargo fmt --all -- --check— clean.cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings— clean.