cache: exclude staged blocks from the cached block count - #7419
Open
Looka149 wants to merge 3 commits into
Open
Conversation
stats() reported the block count from the key index while used skips staging blocks, so with --writeback the two metrics described different sets: 200 staged blocks reported blockcache_blocks=200 and blockcache_bytes=0, and the same blocks were double-counted alongside staging_blocks. Track the count next to used so both are derived from the same decision. full() still counts staging blocks against cache-items: they occupy inodes.
The row says the metric counts bytes in the staging path but the unit column said 秒 (second), likely copied from the staging_block_delay_seconds row below it. The English table already says byte.
Staged blocks cannot be evicted, so counting them against --cache-items makes cleanupFull chase a target it can never reach and drop read cache blocks instead: with --cache-items 50 and 200 staged blocks, 99 of 100 freshly cached blocks were evicted right away and blockcache_hits stayed at 0. The byte limit already excludes them through used, and their inode usage stays bounded by --free-space-ratio, which isFull() applies to staging as well.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7419 +/- ##
===========================================
- Coverage 61.92% 27.89% -34.04%
===========================================
Files 31 179 +148
Lines 25295 59205 +33910
===========================================
+ Hits 15663 16513 +850
- Misses 7769 40533 +32764
- Partials 1863 2159 +296 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
@jiefenghuang PTAL |
Contributor
Author
|
@CaitinChen @jiefenghuang I updated the issue and the PR description. Thank you in advance for your review. |
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.
Resolves #7418
The cache now keeps its own block count, updated wherever
usedis updated. Neither counts staged blocks.blockcache_blocksreports this count, so it now matchesblockcache_bytes.--cache-itemsuses it too, so the limit now applies to read cache blocks only. Staged blocks still take disk space, and--free-space-ratiostill limits that.Tested on a kind cluster with
--writeback, 200 staged blocks and--cache-items 50: reading 100 files now keeps 50 read cache blocks instead of 1, andstaging_blocksstays 200.