jonnyx
jonnyx

Reputation: 347

difference between "clean data cache miss" and "dirty data cache miss"

What is the difference between a dirty data cache miss and a clean data cache miss?

I found counters for both of them in the manual of my CPU and want to know which one is the right measure to say something about the efficiency of the data accesses in the code.

In my current program, clean misses = 102271 while dirty misses = 1323.

Upvotes: 0

Views: 2430

Answers (1)

Eric Postpischil
Eric Postpischil

Reputation: 222362

Per the manual, Data Cache Dirty Misses are described with “cache write-back / eviction was required)”.

This is bad phrasing. I expect the more likely intention is that one of these cache miss events is considered dirty if the line it happened to evict was modified and hence had to be written to memory. The distinction between this and a clean cache miss would be that a clean miss either did not evict a line or evicted a line that was not modified and hence could be evicted simply by discarding it without writing it to memory. If this interpretation is correct, the description would have been clearer had it simply said “cache write-back was required.”

If the comment is taken literally, with “/” meaning “or,” then it means that a cache miss event is considered dirty if it either had to write data to memory or had to evict a line. Then a clean cache miss would be a cache miss that did not have to evict a line. This is an unlikely interpretation because the only time a cache of typical design would not have to evict a line to make room to bring in a new line after the cache had been initialized and the selected cache set had not yet been filled, or if lines had been manually evicted from cache. Usually lines are retained in cache until forcibly evicted, so the normal state of cache is that every cache set is full. In this sense of “clean cache miss,” clean cache misses would be rare, and a counter for them would not often be useful. Additionally, the phrasing would be redundant, as, when there is a cache write-back due to a miss, there is also an eviction, so “cache write-back / eviction was required” would be logically equivalent to “eviction was required.”

Upvotes: 2

Related Questions