Repository navigation
Conversation
When at least 8 entries remained in the bucket, get_count binary-searched the entire rest of the bucket. Callers usually need only small counts (is_too_frequent calls it only when the count is at most the filter cutoff), but for repetitive seeds the rest of the bucket can contain hundreds of thousands of entries, so most binary search probes were cache misses far away from the entry. get_count now gallops from the entry: it probes offsets 1, 2, 4, ... until an entry no longer matches and then binary-searches between the last two probes. This needs O(log count) steps and only touches entries close to this one. The result is identical; a new test compares get_count with the previous implementation. Speedup on top of index prefetching (#XXX) on an Apple M4 Max, -x, 1 thread, median of 5 runs, measured with a prototype of this change: - CHM13, 150 nt reads: finding hits -7%, total mapping time -4% - CHM13, 10 kb reads: finding hits -3%, total mapping time -1% - maize, 150 nt reads: finding hits -7%, total mapping time -4% - maize, 10 kb reads: finding hits -3%, total mapping time -1% - chrY, 150 nt reads: finding hits -4%, total mapping time -1% - chrY, 10 kb reads: finding hits -3%, total mapping time -0.4%
Collaborator
|
The benefits from this PR are unclear. I’m not posting the plots because the runtime difference is not really visible in them, but here is the table: Comparing this PR, rebased on main, to commit c841de3:
Average accuracy change: +0.000000 |
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.
When at least 8 entries remained in the bucket, get_count binary-searched
the entire rest of the bucket. Callers usually need only small counts
(is_too_frequent calls it only when the count is at most the filter
cutoff), but for repetitive seeds the rest of the bucket can contain
hundreds of thousands of entries, so most binary search probes were
cache misses far away from the entry.
get_count now gallops from the entry: it probes offsets 1, 2, 4, ...
until an entry no longer matches and then binary-searches between the
last two probes. This needs O(log count) steps and only touches entries
close to this one. The result is identical; a new test compares
get_count with the previous implementation.
Speedup on top of index prefetching (#642) on an Apple M4 Max, -x,
1 thread, median of 5 runs, measured with a prototype of this change: