What is CPU Cache? Understanding CPU caching and performance !
When you think of memory in a computer, you might think of things like DDR modules, VRAM on your graphics card or most likely just hard drives and SSDs. But there’s actually another type of memory that’s incredibly fast and essential to the speed that we’ve gotten accustomed to with modern computers. I am talking about your CPU cache.
It’s a specialized type of memory that’s built into your CPU. But why the heck would your processor need its own memory? Aren’t tat 16gigs of RAM or whatever the heck already have in your computer good enough? Well not, those RAM modules are a heck of a lot faster tha say a hard in terms of data transfer like a lot faster. But your CPU wants data much faster than your RAM can even provide. And on top of that as CPU have gotten faster over the years, they continue to outstrip tipical RAM modules by wider and wider margins meaning that without faster memory your CPU is going to be sitting around doing nothing like kind of unproductive employee as it waits for RAM and you will run into bottlenecks as a result. This is where CACHE comes in. Unlike system memory which consists of Dynamic RAM or DRAM, your CPU cache is Static RAM or SRAM which is more expensive and takes up more space but is much faster than DRAM because it doesn’t have to be constantly refreshed in order to hold data the way that DRAM has to be.
An average CPU will only have a few megabytes of cache but it makes a tremendous use of this small amount of memory. When a CPU accesses something from your main system RAM, it generally stores it in its cache then uses complex algorithms to guess as to what other instructions or data it might need next. It fetches those from your system RAM as well. Since these guesses aren’t perfect, CPU suffer from things called Cache misses where it searches it’s own cache can’t find what it needs and has to access your system memory directly instead which shows thing down.
Fortunately however modern processors have gotten pretty good at deciding what to put inside their caches as they will tipically have a cache hit rate of better that 80%. Meaning that most of the time your CPU is only processing what it finds in cache and doesn’t have to brother talking to your slower system memory at all. As you may have guessed more cache is advantageous so when you are shopping for a processor, the product page will indicate how much level3 or L3 cache is built-in with higher-end modules having a few extra megabytes and if you are wondering what the heck happened to level 1 & 2, these are smaller even faster parts of the cache that your CPU will try and hit before looking for data in your level 3 cache.