Repository navigation
perf(btree): keep the built page lookup in the cached index state - #116
Merged
Merged
Conversation
A cache hit on BTreeIndexState rebuilt BTreeLookup from the lookup batch, walking every page to find null pages, on every index open. That made each open cost grow with the index size: on a 446-fragment table it was ~0.5 ms per open, paid by every scalar-index query and every index_statistics call. The cached state now holds the built Arc<BTreeLookup>, so it is built once when the state is loaded or deserialized and shared by every reconstruct. The serialized form is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
zehiko
marked this pull request as ready for review
November 17, 2026 08:36
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ilya-zlobintsev
approved these changes
Nov 17, 2026
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.
Why
Every cache hit on a btree index's
BTreeIndexStaterebuiltBTreeLookupfrom the lookup batch, walking every page to find null pages.So each index open cost grew with the index: on a Metastore chunks table with 446 fragments, ~0.5 ms per open, paid by every scalar-index query and every
index_statisticscall.Upstream main still does this.
What
BTreeIndexStateholds the builtArc<BTreeLookup>instead of the lookup batch; it is built once when the state is loaded or deserialized, andreconstructreuses it.The serialized form is unchanged.
Testing
cargo test -p lance-index --lib scalar::btree: 50 passed.reconstruct564 → 5 µs per T2 request on the 446-fragment table.BTreeLookupis immutable,reconstructpassesBTreeIndex::newthe same arguments as before, and the cache codec is never persisted by Lance's shipped backends.Agent
This PR was written by Claude Code (an LLM), at the request of the author.
🤖 Generated with Claude Code