Repository navigation
perf(match): replace FxHashMap with flat open-addressing CompactLookup (#2072) - #3994
Merged
Merged
Conversation
#2072) Replace the pointer-chasing FxHashMap<(u16, u16), Vec<usize>> in DeltaSignatureIndex with a flat open-addressing hash table using Robin Hood probing. Each entry is 8 bytes (packed rsum key + block index), fitting 8 entries per 64-byte cache line. This eliminates heap-allocated Vec<usize> buckets and their pointer indirection, improving cache locality during the block-matching hot loop. The CompactLookup iterator terminates early using the Robin Hood invariant (no matching entry can exist beyond a slot whose probe distance is less than the scan distance). Also removes the now-unused `parallel` feature and rayon optional dependency from the match crate, since the parallel candidate verification path was only possible with the old Vec-based buckets.
Tests reference capacity() to verify allocation reuse across rebuild.
3 tasks
oferchen
added a commit
that referenced
this pull request
May 14, 2026
Introduces CHANGELOG.md and records the four zsync-inspired internal optimizations to the receiver block-match path: bithash prefilter (#3737), sequential-match extension (#3751), matched-block pruning (#3748), and compact-key layout (#3994). All four are wire-compatible refactors of the in-memory match index; golden-byte fixtures and interop against upstream rsync 3.0.9 / 3.1.3 / 3.4.1 are unchanged. Closes #2087.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
#2072) (#3994) * perf(match): replace FxHashMap with flat open-addressing CompactLookup (#2072) Replace the pointer-chasing FxHashMap<(u16, u16), Vec<usize>> in DeltaSignatureIndex with a flat open-addressing hash table using Robin Hood probing. Each entry is 8 bytes (packed rsum key + block index), fitting 8 entries per 64-byte cache line. This eliminates heap-allocated Vec<usize> buckets and their pointer indirection, improving cache locality during the block-matching hot loop. The CompactLookup iterator terminates early using the Robin Hood invariant (no matching entry can exist beyond a slot whose probe distance is less than the scan distance). Also removes the now-unused `parallel` feature and rayon optional dependency from the match crate, since the parallel candidate verification path was only possible with the old Vec-based buckets. * fix: regenerate Cargo.lock after removing rayon from matching crate * fix(match): add capacity() method to CompactLookup Tests reference capacity() to verify allocation reuse across rebuild.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
Introduces CHANGELOG.md and records the four zsync-inspired internal optimizations to the receiver block-match path: bithash prefilter (#3737), sequential-match extension (#3751), matched-block pruning (#3748), and compact-key layout (#3994). All four are wire-compatible refactors of the in-memory match index; golden-byte fixtures and interop against upstream rsync 3.0.9 / 3.1.3 / 3.4.1 are unchanged. Closes #2087.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#2072) (#3994) * perf(match): replace FxHashMap with flat open-addressing CompactLookup (#2072) Replace the pointer-chasing FxHashMap<(u16, u16), Vec<usize>> in DeltaSignatureIndex with a flat open-addressing hash table using Robin Hood probing. Each entry is 8 bytes (packed rsum key + block index), fitting 8 entries per 64-byte cache line. This eliminates heap-allocated Vec<usize> buckets and their pointer indirection, improving cache locality during the block-matching hot loop. The CompactLookup iterator terminates early using the Robin Hood invariant (no matching entry can exist beyond a slot whose probe distance is less than the scan distance). Also removes the now-unused `parallel` feature and rayon optional dependency from the match crate, since the parallel candidate verification path was only possible with the old Vec-based buckets. * fix: regenerate Cargo.lock after removing rayon from matching crate * fix(match): add capacity() method to CompactLookup Tests reference capacity() to verify allocation reuse across rebuild.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Introduces CHANGELOG.md and records the four zsync-inspired internal optimizations to the receiver block-match path: bithash prefilter (#3737), sequential-match extension (#3751), matched-block pruning (#3748), and compact-key layout (#3994). All four are wire-compatible refactors of the in-memory match index; golden-byte fixtures and interop against upstream rsync 3.0.9 / 3.1.3 / 3.4.1 are unchanged. Closes #2087.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#2072) (#3994) * perf(match): replace FxHashMap with flat open-addressing CompactLookup (#2072) Replace the pointer-chasing FxHashMap<(u16, u16), Vec<usize>> in DeltaSignatureIndex with a flat open-addressing hash table using Robin Hood probing. Each entry is 8 bytes (packed rsum key + block index), fitting 8 entries per 64-byte cache line. This eliminates heap-allocated Vec<usize> buckets and their pointer indirection, improving cache locality during the block-matching hot loop. The CompactLookup iterator terminates early using the Robin Hood invariant (no matching entry can exist beyond a slot whose probe distance is less than the scan distance). Also removes the now-unused `parallel` feature and rayon optional dependency from the match crate, since the parallel candidate verification path was only possible with the old Vec-based buckets. * fix: regenerate Cargo.lock after removing rayon from matching crate * fix(match): add capacity() method to CompactLookup Tests reference capacity() to verify allocation reuse across rebuild.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Introduces CHANGELOG.md and records the four zsync-inspired internal optimizations to the receiver block-match path: bithash prefilter (#3737), sequential-match extension (#3751), matched-block pruning (#3748), and compact-key layout (#3994). All four are wire-compatible refactors of the in-memory match index; golden-byte fixtures and interop against upstream rsync 3.0.9 / 3.1.3 / 3.4.1 are unchanged. Closes #2087.
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
FxHashMap<(u16, u16), Vec<usize>>inDeltaSignatureIndexwithCompactLookup, a flat open-addressing hash table using Robin Hood probingVec<usize>bucketsparallelfeature and rayon optional dependency from the match crate (parallel candidate verification was only possible with the old Vec-based buckets)Design
Adapts zsync's
librcksum/hash.cflat layout for the delta match index. The probe chain uses the Robin Hood invariant for early termination: iteration stops when encountering an entry whose probe distance is less than the current scan distance, since no matching entry can exist beyond that point.Load factor is kept below 25% (4x over-allocation) to maintain probe-chain locality. The
u32::MAXsentinel key is reserved for empty slots - the probability of a real rsum hitting this value is negligible, and the tag_table + bithash filters would catch it first.Test plan
compact_lookup.rscovering insert/find, missing keys, duplicate keys, distinct keys, clear, stress (10K entries), probe distance wrapping, and key packing