Repository navigation
A write finds the cached read ranges it can touch from an index ordered by end - #634
Merged
matrixarkai merged 1 commit intoNov 14, 2026
Conversation
…ed by end Every write to a page ran `invalidate_chunk_cache`, which walked every read range cached for that page to find the ones the write intersects. The ranges a page has cached grow with the reads of it -- an entry stays in the index until it is evicted, and after an append it is stale but still there -- so the walk grew with the page's read history, on every write. The per-page index is now ordered by the END of each cached range. The ranges a write can touch are the ones that end past its start, so the walk begins there instead of at the first range there is. An append starts at the end of the page, every cached range ends at or before it, and the walk finds nothing without visiting anything. The ranges returned are exactly those the intersection test accepts; a randomized comparison against that definition, written out separately, aims its writes at the places the boundary is. Tests: a write against random sets of cached ranges leaves cached exactly the ranges it does not intersect (starting where one ends, ending where one starts, past the page, empty, one byte inside); and 40 appends leave every cached range of the page in the index. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
What
Every write to a page ran
invalidate_chunk_cache, which walked every read range cached for that page to find the ones the write intersects. The ranges a page has cached grow with the reads of it: an entry stays in the index until it is evicted, and after an append it is stale (a hit also needs the page's sequence and checksum to be the ones it was filled under) but still there. So the walk grew with the page's read history, on every write.The per-page index is now ordered by the end of each cached range. The ranges a write can touch are the ones that end past its start, so the walk begins there instead of at the first range there is. An append starts at the end of the page, every cached range ends at or before it, and the walk finds nothing without visiting anything. The ranges returned are exactly those the intersection test accepts.
Measured
Door under callgrind (journal mode, the shared-store harness driving it), instructions per write at 300 and 1,200 writes:
Alone this change is small: about 32K instructions per write at 1,200 writes, which is what the profile attributed to the walk. It is the other half of the growth #633 left. With both, the cost per write is nearly flat across a four times larger run, and the run executes 37.9% fewer instructions.
Tests
Planted defects, each caught by the comparison on the boundary it names: widening the lower bound by one (a range that only touches the write is invalidated), and making the upper bound inclusive.
Checks run locally
The four named guards pass,
cargo build --all-targets --lockedpasses with-D warnings(default and--all-features), and the six tests above pass on the tree rebased onto #633. The library suite is 691 passed, 1 failed:the_published_mutation_copy_figures_are_the_ones_this_tree_produces, which fails with identical numbers on unmodified main and which CI does not run. The network consensus jobs are left to CI.🤖 Generated with Claude Code