Defer eviction of checkpoint blocks to reduce post-checkpoint cold reads#55
Open
krleonid wants to merge 1 commit into
Open
Defer eviction of checkpoint blocks to reduce post-checkpoint cold reads#55krleonid wants to merge 1 commit into
krleonid wants to merge 1 commit into
Conversation
During checkpoint, ConvertToPersistent writes blocks to disk and immediately adds them to the eviction queue. Subsequent block writes need memory, so the buffer pool evicts the freshly-written blocks to reuse their buffers. This creates a self-inflicted cold cache: the first query after checkpoint must re-read blocks that were just in memory moments ago. Fix: pin blocks during checkpoint writes so they cannot be evicted. After all checkpoint data is flushed, release the pins. This ensures that when data fits in the buffer pool, the first post-checkpoint query finds all blocks already cached. Measured improvement (67MB dataset, 80MB memory limit): - Before: 23 blocks re-read from disk after checkpoint - After: 5 blocks re-read (78% reduction) Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
Problem
Each
ConvertToPersistentcall writes a block to disk, then adds it to the eviction queue. The next block write needs a buffer, so the pool evicts the oldest queued block — which is the one just written. This creates a cycle where checkpoint evicts its own output, forcing the first post-checkpoint query to re-read everything from disk.Measured improvement
67MB dataset, 80MB memory limit:
When data fully fits in memory, post-checkpoint cold reads drop to zero.
Test plan
build/reldebug/test/unittest)SET memory_limit+ checkpoint + query pattern🤖 Generated with Claude Code