Systems study
Offline — showing the cached copy.
Home / OS Theory / 9. Cache eviction algorithms

9. Cache eviction algorithms

One-liner. Every cache is an eviction policy plus a data structure — and scans are the enemy.

Memorize

  • LRU: exact recency, needs a hash map + doubly linked list; expensive under high concurrency.
  • CLOCK / sampled LRU: approximate recency with bits — what most systems actually ship.
  • LFU / TinyLFU: frequency sketch (count-min) + doorkeeper; W-TinyLFU adds a small LRU window to admit new items.
  • ARC: adapts between recency and frequency automatically; patented history complicated adoption.
  • 2Q: probation + protected queues, scan-resistant.
  • S3-FIFO (2023): small/main/ghost FIFO queues, strong hit ratios with low overhead.
  • Scan resistance is why pure LRU loses to W-TinyLFU on analytics workloads.
W-TINYLFU WINDOW LRU admits new entr… MAIN SLRU probation + pro… FREQUENCY SKETCH count-min + doo… ADMISSION compare candida…
W-TinyLFU

Trap. Using LRU for a workload with periodic full scans — the scan evicts everything useful. Do this. Choose scan-resistant policies (W-TinyLFU, 2Q, S3-FIFO) for mixed workloads.

Check

Why does a full table scan hurt an LRU cache so much?