What is reducing cache misses?

1 answer

Answer

1170701

2026-03-22 03:20

+ Follow

Cache memory is fast memory that resides immediately next to the CPU; it is virtually 15 times faster than the next fastest memory: system RAM. The system RAM is organised from "location 0" to "location n" where "n" is the number of bytes your computer has of RAM. The Cache is like yellow stickers on your desk, with the location slot on top. So this memory is accessed according to content not to where it is.So cache memory is very limited-- usually less than 4 MB-- compared to system RAM, which may have many gigabytes.

That being said, the CPU tries to predict which system memory it will need next, and instructs the address control unit to prefetch this data and place it into the cache. If the CPU was correct in "guessing" the memory blocks the CPU can blaze along with its processing at the 2ns speed typically found in cache memory. This is a cache hit.

However, if the CPU incorrect in its educated guess, then it must request the memory content from the RAM memory and wait up to 15 times longer, somewhere in the neighborhood of 60ns. This is referred to a "cache miss.". This "copy" is kept in the cache, and should the CPU modify this, it will modify the cache content only, and leave it to the cache to update the RAM - "write-through".

Cache misses are undesirable, while cache hits are highly desirable; a system that missed 100% of the time would literally run more than 15 times slower than a cache that hit 100% of the time. A cache miss actually increases the processing time above what it would have been without any cache at all because of the extra memory it has to request.

Reduction of cache misses is done by changing the microcode that the CPU uses to "guess" which memory it will need next. These are very sophisticated algorithms that have remained the same for decades. Guessing the next instruction is simple, it is usually the next and for a condition, you can pre-fetch for both results. Data is based on "what you have used lately will be used again". You now have to consider the complexity of the cache memory - this is accessed by content "location"/"address" and return the content. The more you have to search, the slower will the cache be.

The one that write the code can make a huge change. Simply by not use data that is all over the place, but a small set, and reuse this. The other is to minimize "context switches" - execute as much as possible without having to wait for the entire cache to be cleared. Writing code in VBA will be encoded as it is executed, which is a huge overhead compared to defining simple sequences that gets things done. The basics is the same today as those that P.J. Denning and D. Coffman described in "Operating System Theory" in 1978, when they introduced the notion of "Working Set". They describe the reason for why "more" does not always mean "better performance".

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.