Skip to content

Commit 200b808

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
more microtuning
1 parent 736a92c commit 200b808

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

benchmarks/runner.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ var hitrateGoals = map[string]float64{
2727
"meta": 72.0,
2828
"twitter": 84.5,
2929
"wikipedia": 33.042,
30-
"thesiosBlock": 25.358,
30+
"thesiosBlock": 24.785,
3131
"thesiosFile": 93.458,
32-
"ibmDocker": 83.397,
32+
"ibmDocker": 83.33,
3333
"tencentPhoto": 20.891,
3434
}
3535

@@ -57,7 +57,7 @@ var suiteGoals = struct {
5757
minThroughput float64 // minimum average throughput ops/s
5858
maxMemory int // maximum bytes per item
5959
}{
60-
minHitRate: 59.0,
60+
minHitRate: 61.61,
6161
maxLatency: 18.0,
6262
minThroughput: 250e6,
6363
maxMemory: 80,

s3fifo.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ const (
5858
maxPeakFreq = 21
5959

6060
// smallQueueRatio is the small queue size as per-mille of shard capacity.
61-
// 40% tuned via binary search for highest avg hitrate (60.68% vs 59.40% at 90%).
62-
smallQueueRatio = 138 // per-mille - TESTING
61+
// 13.7% tuned via binary search (61.574% vs 59.40% at 90%).
62+
smallQueueRatio = 137 // per-mille
6363

6464
// ghostFPRate is the bloom filter false positive rate for ghost tracking.
6565
ghostFPRate = 0.00001
6666

6767
// ghostCapPerMille is ghost queue capacity as per-mille of cache size.
68-
// 0.75x tuned via binary search (61.30% vs 60.68% at 8x).
69-
ghostCapPerMille = 750 // per-mille
68+
// 1.22x tuned via binary search (61.620% vs 61.574% at 0.75x).
69+
ghostCapPerMille = 1220 // per-mille
7070

7171
// deathRowThresholdPerMille scales the death row admission threshold.
72-
// 1000 = average peakFreq. Tuned: 1000-2000 optimal (61.356%).
72+
// 1000 = average peakFreq. Wide plateau from 10-1500 (all ~61.62%).
7373
deathRowThresholdPerMille = 1000
7474

7575
// minDeathRowSize is the minimum death row slots.
@@ -81,8 +81,8 @@ const (
8181
// See "FIFO queues are all you need for cache eviction" (SOSP'23).
8282
//
8383
// The cache maintains three queues:
84-
// - Small (~90%): new entries
85-
// - Main (~10%): promoted entries
84+
// - Small (~14%): new entries (filter for one-hit wonders)
85+
// - Main (~86%): promoted entries (protected from scans)
8686
// - Ghost: recently evicted keys (bloom filter, no values)
8787
//
8888
// New keys go to Small; keys in Ghost go directly to Main.
@@ -522,12 +522,12 @@ func (c *s3fifo[K, V]) del(key K) {
522522

523523
// addToGhost records an evicted key for future admission decisions.
524524
// Uses cached hash from entry to avoid re-hashing.
525+
// Note: bloom Add is idempotent, so we skip Contains check for speed.
526+
// Entry count may be slightly inflated but rotation timing is approximate anyway.
525527
func (c *s3fifo[K, V]) addToGhost(h uint64, peakFreq uint32) {
526-
if !c.ghostActive.Contains(h) {
527-
c.ghostActive.Add(h)
528-
if peakFreq >= 1 {
529-
c.ghostFreqRng.add(h, peakFreq)
530-
}
528+
c.ghostActive.Add(h)
529+
if peakFreq >= 1 {
530+
c.ghostFreqRng.add(h, peakFreq)
531531
}
532532
if c.ghostActive.entries >= c.ghostCap {
533533
c.ghostAging.Reset()

0 commit comments

Comments
 (0)