Skip to content

fix(S3FIFO): keep an object's expiry when it moves between queues - #356

Merged
1a1a11a merged 1 commit into
1a1a11a:developfrom
kingofsword248:fix/s3fifo-keep-expiry
Nov 2, 2026
Merged

1a1a11a merged 1 commit into
1a1a11a:developfrom
kingofsword248:fix/s3fifo-keep-expiry

Conversation

@kingofsword248

Copy link
Copy Markdown
Contributor

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 through params->req_local. copy_cache_obj_to_request does not copy a TTL, so insert() gives the moved object default_ttl counted from time 0, or no expiry when default_ttl is 0, and the object can be served as a hit after its TTL has passed.

This PR saves the object's exp_time and 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

  • Bug fix
  • New eviction / admission / prefetch algorithm
  • New trace reader or trace format
  • Performance improvement
  • Documentation
  • Build / CI
  • Other:

How was it tested?

The new test /libCacheSim/cacheAlgo_S3FIFO_keeps_expiry_across_moves (built only with SUPPORT_TTL) follows the layout of cacheAlgo_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 keep exp_time == 1000. It reads exp_time with find(..., false) before the expiry, so it does not depend on #349. On develop the 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_TTL OFF and ON:

Checklist

  • Formatted with clang-format (or the pre-commit hook from scripts/setup_hooks.sh)
  • Added or updated tests
  • Added or updated documentation
  • New algorithms are registered in the CLI and listed in the README

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>
@1a1a11a
1a1a11a merged commit 211ab8c into 1a1a11a:develop Nov 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3FIFO drops an object's expiry when it moves small → main or is reinserted in main (SUPPORT_TTL)

2 participants