Repository navigation
Conversation
evict_lru deleted the oldest entries only while their running total was at most (total size - limit), so it kept the entry that crosses that point and the cache could stay over the limit. For example, with entries of 300, 300 and 400 bytes and a 600-byte limit, 700 bytes remained. Delete an entry when the entries older than it do not free enough space. Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
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.
Description
evict_lrudeletes the oldest entries while their running total is at mosttotal - limit. It keeps the entry that crosses that point, so the cache can stay over the limit: with entries of 300, 300 and 400 bytes and a 600-byte limit, 700 bytes remain; with two 600-byte entries and a 1000-byte limit, nothing is evicted. The existing test uses equal-size entries that land exactly on the boundary.An entry is now evicted when the entries older than it do not free enough space. One side effect: a single entry larger than the whole limit is evicted right after it is stored.
test_evict_lru_respects_size_limitcovers five cases; three fail before this change.test/test_cache.pypasses (15 tests, CPU only).Checklist