Categorizing Cache Misses
I was wondering if somebody could provide an example illustrating a capacity miss in contrast to a conflict miss for a 2-way cache with arbitrarily small line size and cache data array size. I was having trouble distinguishing them from each other.
My book tells me the following information on each miss type without providing a good example of each:
Capacity misses occur when the amount of data referenced by a program exceeds the capacity of the cache, requiring that some data be evicted to make room for new data. If the evicted data is referenced again by the program, a cache miss occurs, which is termed a capacity miss.
Conflict misses occur when a program references more lines of data that map to the same set in the cache than the associativity of the cache, forcing the cache to evict one of the lines to make room. If the evicted line is referenced again, the miss that results is a conflict miss.
Capacity and conflict misses both occur because data must be evicted from the cache to make room for new data, but the difference between them is that conflict misses can occur even when there is free space elsewhere in the cache. If a program references multiple lines that map to the same set in the cache, it may be necessary to evict some of them to make room for new data, even if every other set in the cache is empty.
Capacity misses can be reduced by increasing the size of the cache so that more of the data referenced by the program fits in the cache simultaneously.
Conflict misses can be reduced by either increasing associativity so that more lines that map to the same set can be stored in the cache, or by increasing capacity, which can cause lines that mapped to the same set to map onto different sets.
Assuming you have a 2-way cache, and you receive 3 address read requests that all correspond to different address pages, but these address pages map to the same cache set, then it seems to me that you would exceed the capacity of your cache after the second read because you have already filled both of the lines for the given set for 2-way associativity...and therefore you need to evict one of them to load the 3rd address into the cache? I don't get it... a capacity miss is the same thing as a conflict miss...
or is it, evicting the 2nd line to make way for the 3rd line is capacity miss, then rereading the first address again after evicting it to make way for the third address is a conflict miss?
My Contrived example:
address1, address2, address3, address4 => all map to same "set" of cache
read sequence for a 2-way cache.
address1
address2
address3 <- capacity miss (evicting address1 and replacing with address3)
address1 <- conflict miss
address3 <- conflict miss
address4 <- capacity miss (evicting address2 and replacing with address4)
address2 <- conflict miss
address3 <- conflict miss
Am I close or just plain wrong? To me, it just doesn't seem worth keeping track of the difference...