Repository navigation
fix(S3FIFO): keep the 64-bit frequency when the main FIFO evicts - #342
Merged
1a1a11a merged 1 commit intoSep 26, 2026
Merged
Conversation
S3FIFO, S3FIFOv0 and Clock2QPlus count an object's reads in an int64_t, and every hit increments it without bound until the main FIFO next passes the object. The main-FIFO eviction loop copies that count into an int before testing freq >= 1. An object read 2^31 times since its last pass narrows to a negative value, so the loop evicts the hottest object in the cache instead of reinserting it. The loops now copy the count into an int64_t. The new test gives the oldest main-FIFO object 2^31 reads and checks that the next eviction reinserts it and evicts the object behind it. Signed-off-by: Windsor Nguyen <win@dedaluslabs.ai>
Owner
|
Thank you! |
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 does this PR do?
S3FIFO, S3FIFOv0 and Clock2QPlus keep an object's read count in an
int64_t(cacheObj.h), and every hit increments it without bound until the main FIFO passes the object again. The main-FIFO eviction loop copies the count into anintbefore testingfreq >= 1:An object read 2^31 times since its last pass narrows to a negative value, so the loop takes the evict branch and removes the hottest object in the cache instead of reinserting it. The fix copies the count into an
int64_tat all three sites. S4FIFO and SFIFO store anint32_t, so they do not narrow.Type of change
How was it tested?
The new
/libCacheSim/cacheAlgo_S3FIFO_main_freq_beyond_int32test fills a 100-object cache, promotes objects 1 to 10, and gives object 11, the oldest in the main FIFO, 2^31 reads. The next miss makes the main FIFO evict from its head. Object 11 must be reinserted and object 12 evicted.develop+ the testRelease build in
ubuntu:24.04with Ninja:ctest --test-dir _build --output-on-failurepasses (10/10)Checklist