Skip to content

storage: avoid B-tree cache rescans - #520

Open
Jordan Olshevski (jveski) wants to merge 1 commit into
mainfrom
feature/improve-unbounded-st-63f
Open

storage: avoid B-tree cache rescans#520
Jordan Olshevski (jveski) wants to merge 1 commit into
mainfrom
feature/improve-unbounded-st-63f

Conversation

@jveski

@jveski Jordan Olshevski (jveski) commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants