Repository navigation
fix: register inherited CacheStore entries on first hit - #4687
Open
1915rising wants to merge 1 commit into
Open
1915rising wants to merge 1 commit into
1915rising wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Part of #4282. A
CacheStoreopened over a cache store that already holds entries starts with empty tracking, and a hit on one of those entries did not register it:_update_access_orderno-ops for untracked keys, so the entry never counted towardmax_sizeand could never be evicted.On a full-key hit, an untracked entry is now registered with
_track_entry, using the buffer already in hand. No listing and no extra IO in the store lifecycle. Entries that are never read stay untracked, so this does not close out #4282 on its own. The broader question of how a new instance should account for pre-existing entries, including the public cache state direction raised in the issue, is still open.Repro: two instances over one
LocalStore,max_size=40960, five 8192-byte values written by the first. Before, the second instance reportedcurrent_size=0after a hit on an inherited key, and on-disk grew from 40960 to 81920 with 0 evictions. After, the hit registers the entry (current_size=8192) and later writes evict it, holdingcurrent_sizeat the bound.Tests:
tests/test_experimental/test_cache_store.py, 47 passed before and 48 after. The new test covers registration on hit and eviction of a registered inherited entry, and fails without the fix. Ruff check and format clean.For reviewers
The change is in
_get_try_cache, full-key hits only. Byte-range entries live in the in-memory range cache and cannot be inherited, so that path is untouched. I am confident in the size accounting since it reuses_track_entry. A second look at themax_age_secondsinteraction would be valued: untracked entries are treated as stale bygetthere and already refresh through_get_no_cache, so registration on hit only fires when the entry counts as fresh.Author attestation
TODO
docs/user-guide/*.mdchanges/