Modify Teddy's match verification.#275
Closed
jneem wants to merge 2 commits intorust-lang:masterfrom
jneem:master
Closed
Modify Teddy's match verification.#275jneem wants to merge 2 commits intorust-lang:masterfrom jneem:master
jneem wants to merge 2 commits intorust-lang:masterfrom
jneem:master
Conversation
Once Teddy finds a fingerprint, it needs to check if there is really a match. The old approach was to iterate over the set bits of both 64-bit halves of the fingerprint-checking vector. The new approach first extracts a bitfield that tells which bytes of the fingerprint-checking vector are non-zero. Then it iterates over those bytes. This seems to be faster (up to about 10% in some benchmarks). It seems like the main reason that this approach is faster is that most matched fingerprints only match in one place. The new code narrows in on the important place more quickly, whereas the old code wasted time unnecessarily examining an empty u64. The gain seems to be larger with AVX2 support (which is not included in this patch). Presumably it would be even larger with AVX512.
Member
|
I rebased, squashed and merged this in 12cb63b Thanks! |
Member
|
@jneem I somehow missed your comment about AVX2. Are you working on that? That'd be delicious. :-) |
Contributor
Author
|
Yes, but it's in a separate crate (https://github.com/jneem/teddy), which has diverged a bit. It also implements aligned loads, which gives another 10% or so. |
This was referenced Oct 13, 2025
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.
Once Teddy finds a fingerprint, it needs to check if there is really a
match. The old approach was to iterate over the set bits of both 64-bit
halves of the fingerprint-checking vector. The new approach first
extracts a bitfield that tells which bytes of the fingerprint-checking
vector are non-zero. Then it iterates over those bytes. This seems to
be faster (up to about 10% in some benchmarks).
It seems like the main reason that this approach is faster is that most
matched fingerprints only match in one place. The new code narrows in
on the important place more quickly, whereas the old code wasted time
unnecessarily examining an empty u64.
The gain seems to be larger with AVX2 support (which is not included in
this patch). Presumably it would be even larger with AVX512.
Here are some benchmarks (on a Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz). I've left only the ones that actually use Teddy.
Before:
After: