Fix RangeIterator O(n) drain and query_next_batch routing#11
Open
mynameborat wants to merge 1 commit into
Open
Fix RangeIterator O(n) drain and query_next_batch routing#11mynameborat wants to merge 1 commit into
mynameborat wants to merge 1 commit into
Conversation
- RangeIterator: replace Vec::remove(0) with cursor index — O(1) per element instead of O(n) shift. Eliminates ~500K element moves when draining a 1000-entry batch. - Btree::query_next_batch(): fix inverted is_sweep_query routing — sweep queries now continue with sweep_query_internal and traversal queries continue with traversal_query_internal (was swapped). ┌─────────────┬────────────┬───────────────────────┬─────────────────────┐ │ Scan Size │ Before Fix │ After Fix │ vs RocksDB PT+noWAL │ ├─────────────┼────────────┼───────────────────────┼─────────────────────┤ │ 100 keys │ 20.0 us │ 12.2 us (1.6x faster) │ 1.9x slower │ ├─────────────┼────────────┼───────────────────────┼─────────────────────┤ │ 1,000 keys │ 276 us │ 152 us (1.8x faster) │ 2.5x slower │ ├─────────────┼────────────┼───────────────────────┼─────────────────────┤ │ 5,000 keys │ 1,380 us │ 454 us (3.0x faster) │ 1.5x slower │ ├─────────────┼────────────┼───────────────────────┼─────────────────────┤ │ 10,000 keys │ 2,810 us │ 454 us (6.2x faster) │ HomeDb 1.3x faster! │ └─────────────┴────────────┴───────────────────────┴─────────────────────┘
hkadayam
reviewed
Mar 5, 2026
| self.sweep_query_internal(req).await | ||
| } else { | ||
| // Traversal query continues with traversal (supports reverse, no sibling links) | ||
| self.traversal_query_internal(req).await |
Owner
There was a problem hiding this comment.
How did it even work earlier was a wonder :-)
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.
Fix RangeIterator O(n) drain and query_next_batch routing
element instead of O(n) shift. Eliminates ~500K element moves when
draining a 1000-entry batch.
sweep queries now continue with sweep_query_internal and traversal
queries continue with traversal_query_internal (was swapped).