storage: avoid B-tree cache rescans - #520
Open
Jordan Olshevski (jveski) wants to merge 1 commit into
Open
Conversation
Jordan Olshevski (jveski)
marked this pull request as ready for review
July 22, 2026 16:13
Jordan Olshevski (jveski)
enabled auto-merge
July 22, 2026 16:13
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves unbounded-storage B+tree commit performance by updating the in-memory internal-node cache incrementally after path-copy commits, rather than rescanning and re-reading internal nodes from the block device. It also shifts some mutator bookkeeping lookups to use the committed in-memory mirror to avoid extra device reads and reduce fault-injection sensitivity.
Changes:
- Update internal-node cache by reusing cached internal nodes and inserting newly encoded internal nodes, avoiding full cache rebuild rescans.
- Switch mutator prior/current entry probes to use
lookup_committed_mirror(no device reads) and add targeted assertions that no reads occur in those paths. - Add/adjust tests and invariants documentation to reflect the new corruption/eviction accounting and I/O behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/unbounded-storage/tests/storage/tests.rs | Updates invariant rationale/message to reflect that prior-LBA probes now use the committed mirror rather than disk reads. |
| cmd/unbounded-storage/src/storage/engine.rs | Uses lookup_committed_mirror for mutator bookkeeping and adds a test asserting an eviction probe causes zero device reads. |
| cmd/unbounded-storage/src/storage/btree/tests.rs | Adds a test asserting commits update the internal cache without rescanning, using MockDevice read-count deltas. |
| cmd/unbounded-storage/src/storage/btree/mod.rs | Introduces incremental internal-cache update usage in apply_batch and refines lookup_committed_mirror/cache-bytes documentation. |
| cmd/unbounded-storage/src/storage/btree/cow.rs | Stores internal cache nodes as Arc and adds update_internal_cache fed by internal nodes produced during path-copy encoding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+592
to
+593
| /// Estimated decoded-node payload of the immutable lookup cache owned | ||
| /// by the current snapshot. Map and shared-reference overhead is excluded. |
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.
Carefully mutate cached branches of the btree instead of re-reading everything from disk. Reduces small random reads significantly.
After this change, the btree store operates within ~3% of line rate for typical nvme devices.