High-performance cache policies and supporting data structures.
LFU without aging tends to accumulate “historical winners” that stop being relevant.
Below are common, implementable aging strategies.
Every T seconds (or every N accesses), apply:
freq[key] = max(1, freq[key] / 2)Tradeoffs:
Amortization approaches:
(freq, epoch) and adjusting when touched.Store per-entry:
freq: u32last_epoch: u32
Global:epoch: u32 increments periodicallyOn access:
epoch - last_epoch (e.g., shift right by delta)last_epoch = epochTradeoffs:
For very large keyspaces (web caches), maintain approximate counts over a window:
Tradeoffs: