Repository navigation
fix(S3FIFO): keep an object's expiry when it moves between queues - #356
Merged
Merged
Conversation
S3FIFO moves objects from the small FIFO to main, and reinserts them at the main tail, through params->req_local. copy_cache_obj_to_request does not copy a TTL, so with SUPPORT_TTL the moved object gets a default expiry counted from time 0, or none, and is served as a hit after its TTL has passed. Keep the object's exp_time across both moves. Adds cacheAlgo_S3FIFO_keeps_expiry_across_moves (SUPPORT_TTL builds). Fixes 1a1a11a#351. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kingofsword248
force-pushed
the
fix/s3fifo-keep-expiry
branch
from
November 2, 2026 02:36
f6aaec4 to
c7b405f
Compare
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?
With
-DSUPPORT_TTL=ON, S3FIFO loses an object's expiry when it moves the object between its queues. Both moves, promotion from the small FIFO to main (S3FIFO_evict_small) and second-chance reinsertion at the main tail (S3FIFO_evict_main), re-insert the object throughparams->req_local.copy_cache_obj_to_requestdoes not copy a TTL, soinsert()gives the moved objectdefault_ttlcounted from time 0, or no expiry whendefault_ttlis 0, and the object can be served as a hit after its TTL has passed.This PR saves the object's
exp_timeand restores it on the re-inserted object in both places, under#ifdef SUPPORT_TTL. Builds without TTL support are unchanged.Fixes #351.
Type of change
How was it tested?
The new test
/libCacheSim/cacheAlgo_S3FIFO_keeps_expiry_across_moves(built only withSUPPORT_TTL) follows the layout ofcacheAlgo_S3FIFO_main_freq_beyond_int32. Object 1 is promoted from the small FIFO and object 11 is reinserted at the main tail, both with a TTL of 1000, and the test checks that both keepexp_time == 1000. It readsexp_timewithfind(..., false)before the expiry, so it does not depend on #349. Ondevelopthe first assertion fails with(0 == 1000). With only the promotion fixed, the second one fails, so each assertion covers one of the two moves.Debug builds on macOS (Apple clang), with
SUPPORT_TTLOFF and ON:SUPPORT_TTL=OFF:ctest11/11 pass.SUPPORT_TTL=ON: 10/11 pass.testSimulatorsegfaults on unmodifieddeveloptoo, because ofSUPPORT_TTL:cache_find_basedereferences NULL after removing an expired object (segfault) #349. WithSUPPORT_TTL:cache_find_basedereferences NULL after removing an expired object (segfault) #349's one-line fix (fix(cache): do not touch an expired object after cache_find_base removes it #353) applied on top, 11/11 pass.git clang-formatreports no changes.ctest --test-dir _build --output-on-failurepasses (see theSUPPORT_TTL=ONnote above)Build is warning-free (CI uses
-Wall -Wextra -Werror)Checklist
clang-format(or the pre-commit hook fromscripts/setup_hooks.sh)