Cache Replacement Simulator illustration

Cache Replacement Simulator

Feeds an access sequence through a fixed-size cache and animates every hit and eviction — including WHY each victim was chosen — for the classic replacement policies: FIFO, LRU, LFU, MRU, Random, CLOCK (second chance), ARC and Bélády's optimal OPT as the theoretical upper bound. Generate sequential, random, zipfian, looping or hot-set-plus-scan workloads — or paste your own keys — and watch the running hit rate evolve. A comparison mode runs every policy on the same sequence and charts their hit rates side by side, and a capacity sweep replays the sequence at every cache size from 1 to 12 to chart hit rate against capacity. An optional warmup period excludes the unavoidable cold-start misses from the score. Presets demonstrate Bélády's anomaly (FIFO getting worse with MORE memory), the looping workload that makes LRU degrade to a 0% hit rate, and the hot-set-plus-scan trace where LRU and LFU diverge sharply.

Runs 100% in your browser — nothing you paste leaves your device.

Notes

  • Bélády's anomaly: with the preset sequence, FIFO misses 9 times with 3 slots but 10 times with 4 — adding memory made it worse. LRU can never do this.
  • A loop over N+1 distinct keys with an N-slot LRU cache evicts every key just before it is needed again — the worst case that MRU handles surprisingly well.
  • OPT evicts the key whose next use is farthest in the future. It needs to see the future, so it is not implementable — it exists to show how close a real policy gets.
  • CLOCK approximates LRU with one reference bit per slot and a sweeping hand — that is essentially what your OS's page replacement does.
  • Runs 100% in your browser — nothing you paste leaves your device.