@@ -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.
525527func (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