Repository navigation
Add options that tune s3fifo to a workload - #3
Merged
Merged
Conversation
WithSmallRatio, WithGhostRatio, WithPromotionReads and WithGhostReturns change the numbers that the S3-FIFO paper recommends: the share of the small queue, the number of ghosts, the reads that it takes to move up from the small queue, and the times a ghost has to come back before its key goes straight to the main queue. A cache that is given none of them does exactly what it did before. For the last of them a set of ghosts can count how often each one was asked for (ghost.InitCounting, ghost.Recall), at a byte per ghost. A set that does not count is as it was. bench/cmd/tune replays the traces, or a recording of one's own, with 84 settings and reports what each is worth; `make bench-tuning` writes bench/results/tuning.md. On the eleven traces the standard setting answers 44.77% of the requests on average, the best single setting 46.55%, and the best setting for each trace 47.75%. Co-Authored-By: Claude <noreply@anthropic.com>
With WithGhostReturns(2) or more, a key that comes back for the first time has an entry and a ghost at once. Neither Delete nor the entry's moving up to the main queue removed that ghost, so a deleted key was not forgotten, and a key that had made it once got back into the main queue more easily than with a single return. Both now remove it, and the model in the tests does the same. A set of ghosts counts in a byte: Recall takes a number above 256 for 256 rather than never taking the hash out. The tests of the options look at every shard, and pin share's rounding from above. The tune command rejects arguments it has no use for and -datasets with -trace. Its tests check the report itself: averages, ties, the one setting for all, and that every part of a setting reaches the cache. The report and the package doc say that a setting picked on the requests it is measured with gains at most what they show. The tuning report is replayed again with the fix; only the column of the best setting for each capacity moves (mean 48.18 to 48.23). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Four options for
s3fifo.Newthat change the numbers the S3-FIFO paper recommends:WithSmallRatioWithGhostRatioWithPromotionReadsWithGhostReturnsA cache that is given none of them does exactly what it did before: the model test and the fuzz target replay the old behaviour and ten other settings against a reference model, hit for hit.
These are four of the five knobs of S4-FIFO (OSDI '26). The fifth, the region of the main queue that eviction skips, is not here, and neither is the model that picks the settings: a cache does as it is told.
What it is worth
bench/cmd/tunereplays the traces of the benchmarks, or a recording of one's own, with 84 settings (make bench-tuning). On the eleven traces, the hit ratio averaged over traces and capacities:Four traces gain next to nothing from the best setting, two gain 8 and 16 points, and the one setting that is best for all does worse than the standard one on six of the eleven. So the defaults stay, and the options are for a workload that has been recorded and replayed. The report is
bench/results/tuning.md. The best settings are picked on the same requests they are scored on, so their gains are upper bounds; the report and the package doc say so.How
internal/ghost: a set can count how often each ghost was asked for (InitCounting,Recall), a byte per ghost. A set that does not count is as it was.s3fifo: the options, their clamping, andshare, which keeps the sizes of the default setting what integer arithmetic made them (checked for every capacity below 2^21).bench/cmd/tune: the replay and the report, also for a recording given with-trace.Checked
make lint,make test(race detector),go vetand test compilation for linux/386.WithGhostReturns(2)neitherDeletenor moving up to the main queue removed a ghost that a key still had on its first return; the second commit fixes it (and the model that shared the mistake), and the tuning report was replayed again with the fix. It also found the tune command's tests too weak: all 12 of its mutants of the report logic and option wiring are killed now.🤖 Generated with Claude Code