Memory

Replacement Policy

The rule a cache uses to decide which existing line to evict when a new line must be inserted into a full set.

Detailed Explanation

In a direct-mapped cache there is no choice about replacement, but once a cache has multiple ways per set, a miss must choose a victim line. That decision is made by the replacement policy. Common strategies include random replacement, least recently used (LRU), pseudo-LRU, and first-in-first-out (FIFO). Each balances hardware cost against how closely it approximates the ideal victim choice.

A perfect replacement policy would know the future and evict the line that will be used farthest in the future, but real hardware cannot do that. Instead, designers use simple heuristics that capture locality well enough without too much state or combinational logic. Replacement behavior matters most in associative caches under pressure, where bad victim choices can noticeably reduce hit rate.

Industry Context

Many practical caches use pseudo-LRU instead of true LRU because true LRU becomes expensive as associativity grows. The “best” replacement policy is often the cheapest policy that preserves most of the hit-rate benefit.