Caching & eviction
Hit-Rate Wind Tunnel
Race LRU, LFU, and ARC on one request stream and drag the workload skew to flip the winner.
How to read this lab
Three real cache-eviction policies — LRU, LFU, and ARC — run against the exact same stream of requests at once. Inject a one-time flood of never-repeated keys (a "scan") and watch LRU's hit rate get wiped out while ARC barely notices.
Controls
- Zipf skew
- How concentrated the traffic is on a few hot keys. Higher skew means a small number of keys get most of the requests.
- Inject scan burst
- Splices a burst of unique, never-repeated keys into the stream — simulating a one-off large scan through cold data.
What to watch for
- Before the scan, all three policies should hold a comfortably high hit rate on a skewed workload.
- Click Inject scan burst — LRU hit rate craters toward 0% right after, since the scan evicted its entire hot set.
- ARC hit rate recovers much faster (often barely dips) — its ghost lists protect previously-frequent keys from being evicted by a one-time flood.
- Watch ARC p (the adaptive boundary between its recency and frequency lists) shift as the workload changes.
Why it happens
LRU evicts whatever was used least recently — a big one-time scan of brand-new keys looks "most recent" to LRU and evicts your entire actual hot set to make room, even though none of those scanned keys will ever be requested again. ARC keeps a memory of recently-evicted keys (ghost lists) and uses hits against that memory to shift its balance between recency and frequency — a scan of never-seen keys generates no ghost hits, so ARC's frequency-favoring side stays protected. This is the textbook "scan resistance" property that makes ARC and its descendants the default eviction policy in real systems like PostgreSQL and ZFS.
Try this first — Watch all three hit rates settle, then click Inject scan burst and compare how far LRU falls versus ARC.
Warming up…
The cache lanes just (re)started — give them a moment to fill before the hit-rate lines mean anything.
- Cache hit (slot flashes)
- Cache miss (slot recolors)
- LRU hit-rate line
- LFU hit-rate line
- ARC hit-rate line
- ARC's p — T1/T2 boundary marker
Workload
Higher skew concentrates accesses on fewer hot keys; lower skew spreads them out.
Splices 80unique, never-repeated keys into the stream right now — watch LRU's hit rate crater while ARC holds up better via its ghost lists.
LRU hit rate
0%
LFU hit rate
0%
ARC hit rate
0%
ARC p
0.0/ 12
Adaptive T1 target size