Cache miss types (compulsory, capacity, conflict)
Setup: what is a cache and what is a "miss"?
WHAT we want to measure: for a given program's access sequence, how many misses happen and why.
The 3 C's — precise definitions

Deriving the classification from first principles
HOW do we decide a real miss's type? Simulate the same access trace on all three model caches.
Worked Example 1 — direct-mapped conflict
Cache: direct-mapped, 4 lines (block = 1 word for simplicity, so ).
Access sequence of block numbers: 0, 4, 0, 4, 0, 4.
Index : block 0 → set 0; block 4 → → also set 0.
| Access | Set | State before | Result | Why |
|---|---|---|---|---|
| 0 | 0 | empty | Compulsory miss | first ever touch of 0 |
| 4 | 0 | {0} | Compulsory miss | first ever touch of 4 (evicts 0) |
| 0 | 0 | {4} | Conflict miss | 0 seen before ⇒ not cold; only 2 blocks used ⇒ fits in fully-assoc ⇒ conflict |
| 4 | 0 | {0} | Conflict miss | same reasoning |
| 0 | 0 | {4} | Conflict miss | thrashing continues |
| 4 | 0 | {0} | Conflict miss | thrashing continues |
Result: 2 compulsory + 4 conflict + 0 capacity. Fix: just 2-way associativity makes both blocks live together in set 0 → all later accesses hit. Conflict misses vanish without enlarging the cache.
Worked Example 2 — capacity miss
Cache: fully-associative, 2 lines, LRU. Sequence: 0, 1, 2, 0, 1, 2.
| Access | Cache (LRU→MRU) | Result | Why |
|---|---|---|---|
| 0 | [0] | Compulsory | first touch |
| 1 | [0,1] | Compulsory | first touch |
| 2 | [1,2] | Compulsory (evicts 0) | first touch of 2 |
| 0 | [2,0] | Capacity | 0 seen before, but fully-assoc still missed ⇒ cache too small (3 blocks, 2 slots) |
| 1 | [0,1] | Capacity | same |
| 2 | [1,2] | Capacity | same |
Result: 3 compulsory + 3 capacity + 0 conflict. Why not conflict? The cache is fully-associative, so there is no mapping restriction — nothing to fix with associativity. The only cure is a bigger cache (≥3 lines) or a smaller working set.
Worked Example 3 — all three in one trace
Direct-mapped, 2 lines (, index ). Sequence: 0, 1, 2, 0, 3, 0.
| Access | Index | State | Result | Why this step? |
|---|---|---|---|---|
| 0 | 0 | — | Compulsory | first touch |
| 1 | 1 | {0,1} | Compulsory | first touch |
| 2 | 0 | {2,1} | Compulsory | first touch (evicts 0, both map to set 0) |
| 0 | 0 | {0,1} | Conflict | 0 seen before; only blocks {0,1,2} used, would fit in a 2-line fully-assoc? No — 3 blocks > 2 lines... check carefully |
| 3 | 1 | {0,3} | Compulsory | first touch (evicts 1) |
| 0 | 0 | {0,3} | Hit | 0 still in set 0 |
For access #4 we must test fully-assoc size 2: sequence 0,1,2,0… — a 2-line fully-assoc LRU would have {1,2} when 0 is re-requested ⇒ it also misses. So access #4 is actually a capacity miss, not conflict! This shows the classification requires simulating the reference cache, not eyeballing. (This subtle case is exactly why we define types by comparison, not intuition.)
Common mistakes (Steel-man + fix)
Active recall
Recall Forecast then verify (cover the answers!)
- Which miss type survives in an infinite cache? → Compulsory only.
- Which cure fixes conflict but NOT capacity? → Higher associativity.
- Sequence
0,4,0,4in a direct-mapped 4-line cache (): how many conflict misses? → 2 (after the 2 compulsory ones). - Formula for conflict count? → .
- Does a fully-associative cache ever have conflict misses? → No, by definition.
Recall Feynman: explain to a 12-year-old
Imagine a small bookshelf (the cache) and a huge library (memory).
- Compulsory: the first time you ever need a book, it's never on your shelf — you must walk to the library. Nobody could avoid that.
- Capacity: your shelf holds 3 books but you keep switching between 4. Something always gets pushed off. Only a bigger shelf helps.
- Conflict: you have plenty of shelf space, but a silly rule says "the red book and the blue book must go on the same single spot." They keep kicking each other off even though other spots are empty. Change the rule (allow more spots) and the problem disappears.
80/20 — the essential takeaways
- Classify by comparison to idealized caches (infinite → full-assoc → real).
- Cause ⇒ cure: compulsory→prefetch/bigger blocks; capacity→bigger cache; conflict→more associativity.
- Conflict real misses fully-associative misses; if that's 0, associativity won't help.
Connections
- Cache Associativity & Set Mapping
- LRU and Replacement Policies
- Spatial and Temporal Locality
- Cache Block Size Trade-offs
- Average Memory Access Time (AMAT)
- Working Set & Program Behavior
- Prefetching
The 3 C's model classifies cache misses into which three types?
What is a compulsory miss?
What is a capacity miss?
What is a conflict miss?
Which idealized cache leaves only compulsory misses?
How do you compute the number of conflict misses?
How do you compute capacity misses?
Cure for conflict misses?
Cure for capacity misses?
Cure for compulsory misses?
In a direct-mapped cache with S sets, which set does block B map to?
Does a fully-associative cache ever suffer conflict misses?
Why can larger blocks hurt?
Sequence 0,4,0,4 on a direct-mapped 4-line cache (4 mod 4 = 0): miss breakdown?
Why can't associativity fix a capacity miss?
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, cache ek chhoti fast memory hai jo bade slow RAM ke saamne rehti hai. Jab bhi CPU ko data chahiye aur wo cache mein nahi milta, us ko miss bolte hain. Ab har miss ka reason alag hota hai, aur reason ke hisaab se hi uska ilaaj alag hota hai — isiliye engineers ne 3 C's banaye: Compulsory, Capacity, Conflict.
Compulsory (Cold) matlab data ko pehli baar hi touch kiya ja raha hai — obviously wo cache mein hoga hi nahi, chahe cache kitni bhi badi ho. Isko sirf prefetching ya bade block se thoda kam kar sakte ho. Capacity (Crowded) tab hota hai jab tumhara kaam ka data (working set) cache se bada hai — cheezein baar-baar bahar phenki jaati hain kyunki jagah hi kam hai. Iska ilaaj sirf ek: badi cache. Yahan associativity badhane ka koi faayda nahi.
Conflict (Collision) sabse interesting hai: cache mein jagah khaali padi hai, par mapping rule (index = block mod number-of-sets) do blocks ko same slot pe zabardasti bhej deta hai, to wo ek dusre ko thoda-thoda kick karte rehte hain (thrashing). Iska simple ilaaj: associativity badhao (2-way, 4-way), taaki ek set mein zyada blocks reh sakein — cache ka size badhaaye bina hi problem khatam.
Yaad rakhne ka smart tarika: kisi miss ko classify karne ke liye compare karo — infinite cache (sirf compulsory bachega), phir fully-associative same size (compulsory + capacity), phir real cache (teenon). Subtract karke har type nikal jaata hai. Yeh soch exam aur real design dono mein kaam aati hai kyunki cause pata chalte hi cure clear ho jaata hai.