The Memory Hierarchy & Caches

the three C's of misses

If your study keeps stalling because the right book is never on your desk, it helps to diagnose WHY. Is it the first time you have ever needed this book (you simply had to fetch it once)? Or is your desk just too small to hold everything you are juggling? Or is your filing rule clumsy, so two books fight over one spot even though the desk has room elsewhere? The three C's are exactly this diagnosis for cache misses, sorting every miss into one of three root causes so you know which fix will actually help.

Compulsory misses (also called cold-start) are the first-ever reference to a block: the data has never been in the cache, so the first touch must miss, no matter how the cache is built. Capacity misses happen because the cache simply cannot hold the program's working set — useful data was evicted to make room and is now needed again; you would see these even in a fully associative cache of the same size. Conflict misses (also called collision) are the extra misses caused by limited associativity: blocks that map to the same set keep evicting each other even though the cache as a whole is not full — these would vanish in a fully associative cache. Compulsory + capacity + conflict together account for every miss.

The value of this taxonomy is that each C points to a different cure, and they trade off against each other. Compulsory misses shrink with larger cache lines (one fetch warms more data) or with prefetching (fetch before first use). Capacity misses shrink with a bigger cache or, far more cheaply, with better locality in your code so the working set fits. Conflict misses shrink with more associativity (or a smarter index mapping). The honest catch is that these cures interact and can backfire: bigger lines cut compulsory misses but can raise conflict misses and waste bandwidth; more associativity cuts conflict misses but can raise hit time. The three C's let you reason about which knob to turn instead of blindly enlarging the cache.

Tiling a matrix multiply attacks capacity misses: by processing small sub-blocks that fit in cache, you reuse loaded data before it is evicted. Switching from direct-mapped to 4-way attacks conflict misses. Prefetching the next line attacks compulsory misses. Different C, different fix.

Every miss is compulsory, capacity, or conflict — and each root cause needs a different cure.

The cures trade off, so 'just make the cache bigger' is not always right: larger lines cut compulsory misses but can add conflict misses; more associativity cuts conflict misses but can raise hit time. The taxonomy tells you which knob is even relevant before you turn it.

Also called
3 Cscompulsory/capacity/conflict misses三C未命中