Performance improvements for MvccIterator#10
Open
mynameborat wants to merge 1 commit into
Open
Conversation
1. into_results() on IndexQueryHandle — added to the trait and implemented in both SingleQueryHandle (moves out results from QueryResultHandle) and ShardedQueryHandle (moves out results vec). Used in iterators when !has_more() to avoid cloning the final batch. 2. Reverse+pop pattern — both PlainRangeIterator and MvccRangeIterator now reverse batches on receipt and use pop() instead of remove(0). This changes batch draining from O(n^2) to O(n) per batch. 3. Cached MvccQueryFilter Arc — the filter is created once in MvccRangeIterator::new() and reused via Arc::clone() in seek(), avoiding repeated Arc::new(MvccQueryFilter::new(...)) allocations. Range Scan Benchmark Results ┌────────┬─────────┬─────────┬─────────────┬─────────────┐ │ Keys │ Before │ After │ Speedup │ Throughput │ ├────────┼─────────┼─────────┼─────────────┼─────────────┤ │ 10 │ 2.60 us │ 2.29 us │ 1.1x (-12%) │ 4.4 Melem/s │ ├────────┼─────────┼─────────┼─────────────┼─────────────┤ │ 100 │ 19.9 us │ 11.8 us │ 1.7x (-41%) │ 8.5 Melem/s │ ├────────┼─────────┼─────────┼─────────────┼─────────────┤ │ 1,000 │ 277 us │ 148 us │ 1.9x (-47%) │ 6.8 Melem/s │ ├────────┼─────────┼─────────┼─────────────┼─────────────┤ │ 5,000 │ 1.37 ms │ 771 us │ 1.8x (-43%) │ 6.5 Melem/s │ ├────────┼─────────┼─────────┼─────────────┼─────────────┤ │ 10,000 │ 2.80 ms │ 1.56 ms │ 1.8x (-44%) │ 6.4 Melem/s │ └────────┴─────────┴─────────┴─────────────┴─────────────┘
f962d42 to
c64d43c
Compare
hkadayam
reviewed
Mar 5, 2026
| if spec.mvcc_enabled { | ||
| config.merge_policy = MergePolicy::Never; | ||
| } | ||
|
|
Owner
There was a problem hiding this comment.
I wouldn't want to merge this particular change and let it be in local changes as we should get to the bottom of NodeNotFound errors, the perf number wouldn't be representable with this issue
hkadayam
reviewed
Mar 5, 2026
| } else { | ||
| (handle.into_results(), None) | ||
| }; | ||
| results.reverse(); |
Owner
There was a problem hiding this comment.
I am not able to follow this change as well.
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.
Performance improvements for MvccIterator
Range Scan Benchmark Results