Sub topic 13
Compulsory, Capacity and Conflict Misses
Assume you know binary addresses, cache blocks, cache lines, and the difference between direct-mapped and set-associative caches. This chapter classifies why a cache access misses. The classification helps you choose a cache design or interpret a GATE CS reference string.
The three miss types
A cache miss occurs when the requested block is not currently available in the required cache location. The usual classification is called the 3C model:
| Miss type | Main cause | Can more associativity help? |
|---|---|---|
| Compulsory | The block is accessed for the first time | No |
| Capacity | The cache cannot hold all needed blocks | Usually no |
| Conflict | Blocks compete for the same line or set | Yes |
Compulsory misses
A compulsory miss, also called a cold-start miss, occurs on the first access to a memory block. The block has never been loaded into the cache, so the cache must fetch it from the next memory level.
For example, the first access to blocks A, B, and C causes at least three compulsory misses. Repeating the same accesses can cause other miss types, but the first access to each distinct block remains compulsory.
A larger cache or higher associativity cannot remove the first access miss. Prefetching can fetch a block before the processor explicitly requests it, but that changes the system behavior rather than removing the cold-start nature of the reference.
Capacity misses
A capacity miss occurs because the cache cannot hold all blocks needed by the program during a particular reuse interval.
Suppose a fully associative cache has two lines and the reference string is:
A, B, C, A, B, C
The cache can hold only two blocks. After loading A and B, loading C evicts one of them. The repeated accesses continue to evict blocks, so the later references miss. This is a capacity problem because even an ideal placement policy cannot keep all three blocks in two lines.
Conflict misses
A conflict miss occurs when multiple blocks map to the same cache line or set, even though the cache has enough total space for them.
Consider a direct-mapped cache with two lines. Let A and C map to line 0:
A, C, A, C
Each access replaces the previous block. Therefore, all four accesses miss after the first fetch operations. If the cache were fully associative with two lines, A and C could remain together, and the last two accesses would hit. The extra misses are conflict misses.
In a set-associative cache, conflict is limited to blocks that map to the same set. Increasing associativity gives each set more possible locations.
Solving reference-string questions
Use this procedure for GATE-style problems:
- Convert byte addresses to block numbers by dividing by the block size.
- Remove repeated byte references within the same block when appropriate.
- Record the first access to every distinct block as compulsory.
- Determine the line or set for each block.
- Apply the stated replacement policy, such as LRU or FIFO.
- Compare the observed misses with an ideal fully associative cache of the same capacity to identify capacity and conflict effects.
A useful test is to compare two caches with the same number of total lines. If a miss disappears when associativity increases, it was caused by a mapping conflict. If it remains in the fully associative cache, it is capacity-related after compulsory misses are excluded.
Exercise
A two-line direct-mapped cache receives the block sequence A, C, A, C, where A and C map to the same line. Classify the misses and state what happens in a two-line fully associative cache.
Show answer
The direct-mapped cache has four misses: the first A and C are compulsory, and the repeated A and C are conflict misses. In the fully associative cache, the first A and C are compulsory, and the repeated accesses hit.