Skip to content

Add S4-FIFO eviction algorithm and remove S3FIFOd - #336

Closed
1a1a11a wants to merge 1 commit into
developfrom
claude/friendly-fermi-3r878q
Closed

1a1a11a wants to merge 1 commit into
developfrom
claude/friendly-fermi-3r878q

Conversation

@1a1a11a

@1a1a11a 1a1a11a commented Sep 19, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

This PR implements the S4-FIFO cache eviction algorithm from "Learning-Augmented Heuristics: Simple, yet Smart, Robust and Interpretable Cache Eviction" and removes the S3FIFOd algorithm.

S4-FIFO extends S3-FIFO by making its hard-coded constants into configurable parameters:

  • small-size-ratio: fraction of cache held by small queue (default 0.10)
  • ghost-size-ratio: ghost queue size relative to cache size (default 0.90)
  • skip-ratio: head fraction of small queue where hits don't count (default 0.00)
  • move-to-main-threshold: hits needed to promote from small to main (default 2)
  • ghost-to-main-threshold: ghost hits needed to skip probation (default 0)

The skip ratio implements a virtual "fourth region" (probationary period) without requiring a fourth physical queue, preventing correlated reference bursts from triggering premature promotion. The ghost threshold handles cyclic scans by allowing multi-hit promotion logic.

At default parameters, S4-FIFO reduces exactly to S3-FIFO.

Type of change

  • New eviction / admission / prefetch algorithm
  • Documentation

How was it tested?

  • ctest --test-dir _build --output-on-failure passes
  • Build is warning-free
  • Added test data and validation in test_evictionAlgo.c
  • Updated CLI tests in test_cli.sh with S4-FIFO parameter validation

Checklist

  • Formatted with clang-format
  • Added tests for S4-FIFO algorithm
  • Updated documentation (README.md, quickstart guide)
  • Registered algorithm in CLI (cacheAlgoRegistry.c)
  • Removed deprecated S3FIFOd algorithm

https://claude.ai/code/session_01JxxSd3ipti1DZc58v543JW

S3-FIFOd was an unpublished adaptive variant of S3-FIFO that hill-climbed
the small/main split from hit counts on two extra "recently evicted" FIFOs.
S4-FIFO supersedes it: same goal of adapting S3-FIFO to the workload, but
through named parameters rather than an online feedback loop.

S4-FIFO keeps S3-FIFO's three physical queues and turns the constants
S3-FIFO hard-codes into five knobs:

  small-size-ratio        rho_S  0.10
  ghost-size-ratio        rho_G  0.90
  skip-ratio              kappa  0.00
  move-to-main-threshold  tau_S  2
  ghost-to-main-threshold tau_G  0

Two of these are new machinery rather than exposed constants:

- The skip ratio is what makes this "S4". Hits on an object still within
  the newest kappa fraction of the small queue do not increment its
  frequency counter, so a burst of correlated references right after
  insertion cannot buy a promotion to main. That carves a virtual
  probationary region out of the head of the small queue without a fourth
  physical queue. Distance from the head is measured in bytes inserted
  after the object, so the region stays a true fraction of the queue when
  objects differ in size.

- The ghost threshold handles cyclic scans. At tau_G = 0 a ghost hit
  promotes straight to main, as in S3-FIFO. At tau_G = 1 the first ghost
  hit only sends the object back through probation; the ghost hit count
  rides along with the object and is restored into the ghost entry if it
  is demoted again, so a second ghost hit is what finally promotes it.

At the default parameters S4-FIFO reduces exactly to S3-FIFO, which the
CLI tests assert by replaying a trace through both and comparing the miss
ratios at three sizes; they also assert that each of the five knobs moves
the result, so a knob that stops being wired up fails loudly. The unit
test pins a non-default configuration (skip-ratio=0.25,
ghost-to-main-threshold=1) so the new code paths are covered rather than
S3-FIFO's numbers being re-checked under a new name.

The paper pairs this heuristic with an offline-trained gradient-boosted
tree that picks a configuration per workload from measured features. That
model is not included here -- only the heuristic it steers, configured
through -e.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JxxSd3ipti1DZc58v543JW
Copilot AI lite review requested due to automatic review settings September 19, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-19T20:55:21.565561Z 06961b4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@1a1a11a 1a1a11a closed this Sep 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06961b4ebc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

cache->get_occupied_byte = S4FIFO_get_occupied_byte;
cache->can_insert = S4FIFO_can_insert;

cache->obj_md_size = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Charge S4-FIFO metadata when requested

When --consider-obj-metadata=true is used, this unconditional zero means the capacity calculations ignore the newly added per-object small_insert_byte, freq, and ghost_hits fields. Consequently S4-FIFO reports the same effective capacity as metadata-free mode and produces overly optimistic miss ratios for metadata-aware experiments; its resident sub-caches need to account for this policy metadata.

Useful? React with 👍 / 👎.

Comment on lines +451 to +453
// remove from small fifo, but do not update stat
bool removed = small_fifo->remove(small_fifo, params->req_local->obj_id);
DEBUG_ASSERT(removed);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record S4-FIFO's actual evictions

In builds with TRACK_EVICTION_V_AGE enabled, the branch that drops an object into the ghost queue removes it without calling record_eviction_age; the analogous terminal branch in S4FIFO_evict_main does the same. Since every real S4-FIFO eviction follows one of these paths, the parent cache's eviction-age histogram remains empty, corrupting eviction-age experiments for this algorithm.

Useful? React with 👍 / 👎.

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.

3 participants