Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between conflict miss and capacity miss

Capacity miss occurs because blocks are being discarded from cache because cache cannot contain all blocks needed for program execution (program working set is much larger than cache capacity).

Conflict miss occurs in the case of set associative or direct mapped block placement strategies, conflict misses occur when several blocks are mapped to the same set or block frame; also called collision misses or interference misses.

Are they actually very closely related?

For example, if all the cache lines are filled and we have a read request for memory B, for which we have to evict memory A.

So should it be considered as a capacity miss since we don't have enough space? And later if we want to access memory A, and since it's evicted before, it's considered as a conflict miss.

Am I understanding this correctly? Thanks

like image 264
xiaodong Avatar asked Oct 24 '15 03:10

xiaodong


People also ask

What is a conflict miss?

Conflict Miss – It is also known as collision misses or interference misses. These misses occur when several blocks are mapped to the same set or block frame. These misses occur in the set associative or direct mapped block placement strategies.

What is conflict capacity?

What is conflict capacity? Conflict capacity is the ability to stay with difficult situations without resorting to the three coping mechanisms: Fight, flight or freeze, all normal tendencies during stress.

What causes a conflict 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.

What is the difference between a cache miss and conflict miss?

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.

What is the difference between conflict miss and compulsory miss?

Consider a 2−way set associative cache with 256 blocks and uses LRU replacement. Initially, the cache is empty. Conflict misses are those misses which occur due to the contention of multiple blocks for the same cache set. Compulsory misses occur due to first time access to the block.

What is the difference between compulsory and capacity misses?

The first request to a cache block is called a compulsory miss, because the block must be read from memory regardless of the cache design. Capacity misses occur when the cache is too small to hold all concurrently used data. Conflict misses are caused when several addresses map to the same set and evict blocks that are still needed.

What is capacity miss in C++?

Capacity miss occurs because blocks are being discarded from cache because cache cannot contain all blocks needed for program execution (program working set is much larger than cache capacity).


Video Answer


3 Answers

The important distinction here is between cache misses caused by the size of your data set, and cache misses caused by the way your cache and data alignment are organized.

Lets assume you have a 32k direct mapped cache, and consider the following 2 cases:

  1. You repeatedly iterate over a 128k array. There's no way the data can fit in that cache, therefore all the misses are capacity ones (except the first access of each line which is a compulsory miss, and would remain even if you could increase your cache infinitely).

  2. You have 2 small 8k arrays, but unfortunately they are both aligned and map to the same sets. This means that while they could theoretically fit in the cache (if you fix your alignment), they will not utilize the full cache size and instead compete for the same group of sets and thrash each other. These are conflict misses, since the data could fit, but still collides due to organization. The same problem can occur with set associative caches, although less often (let's say the cache is 2-way, but you have 4 aligned data sets...).

The 2 types are indeed related, you could say that given high levels of associativity, set skewing, proper data alignments and other techniques, you could reduce the conflicts, until you're mostly left with true capacity misses that are unavoidable.

like image 106
Leeor Avatar answered Oct 17 '22 02:10

Leeor


My favorite definition for conflict misses from Reducing Compulsory and Capacity misses by Norman P. Jouppi:

Conflict misses are misses that would not occur if the cache were fully associative with LRU replacement.

Let's look at an example. We have a direct-mapped cache of size of 4. The access sequences are

0(compulsory miss), 1(compulsory miss), 2(compulsory miss), 3(compulsory miss), 4(compulsory miss), 1(hit), 2(hit), 3(hit), 0(capacity miss), 4(capacity miss), 0(conflict miss)

The second to last 0 is a capacity miss because even if the cache were fully associative with LRU cache, it would still cause a miss because 4,1,2,3 are accessed before last 0. However the last 0 is a conflict miss because in a fully associative cache the last 4 would have replace 1 in the cache instead of 0.

like image 32
tartaruga_casco_mole Avatar answered Oct 17 '22 02:10

tartaruga_casco_mole


Compulsory miss: when a block of main memory is trying to occupy fresh empty line of cache and the very first access to a memory Block that must be brought into cache is called compulsory miss.

Conflict miss: when still there are empty lines in the cache, block of main memory is conflicting with the already filled line of cache, ie., even when empty place is available, block is trying to occupy already filled line. its called conflict miss.

Capacity miss: miss occured when all lines of cache are filled.

conflict miss occurs only in direct mapped cache and set-associative cache. Because in associative mapping, no block of main memory tries to occupy already filled line.

like image 36
Pooja Gupta Avatar answered Oct 17 '22 00:10

Pooja Gupta