GT Explains: What are CPU Caches and are They Really Necessary

We’ve already spoken a bit about browser cache here on Guiding Tech, so most of you must be familiar with it already. But there is another kind of cache that perhaps not all of you may know. And that’s the one associated with the CPU. If you’ve gone PC building yourself, one of the specs always mentioned on a CPU is the cache.

computer-motherboard-pc-wires

But, why does it need this? What does it actually do?

A Little Background

For those of you who’ve seen the evolution of personal computing right from the early days, will remember the specs of computers of yore. Memory chips used to be in the KBs and so did the processor speeds. As time passed, we moved into the MHz territory, with memory chips running at 4 MHz and CPU at 2 MHz.

CPU-Cache-explained

So, if the CPU would make a request on such a system, the memory would talk-back rapidly without any delay. Their matched clock-speeds helped make the processor run quickly. But, fast-forward a decade or two and now you can get CPUs that can run in GHz speed, but, unfortunately, memory chips could not keep up.

Big Problem: One Solution

The rapidly increasing CPU speeds meant that the CPU would actually need to wait for the memory chip to understand the fast succession of requests it was sending out. This was a problem. You can technically build memory which has the same speed of the CPU, but it takes more space on the Silicon to store each bit of information. These would cost a whole lot more than the DIMMs that we use today.

high_res_automata_dimm
A regular DIMM you’d find in the market

The workaround? Split the memory up in two. The main memory which we build out of Dynamic RAM as well as a second type of memory which we build into the CPU. It is much smaller, but also is a much faster type of memory compared to DRAM. And this is what we refer to as Cache.

What Does it Do?

Cache may be an old-fashioned English word, but that’s exactly what the CPU cache does – it stores things. Think of it like a Pirate’s treasure chest. Ok, maybe not. Since we’re all geeks and I already spoke about cache from a web browser, the functionality of this cache is also the same.

CPU-Cache-explained2

So rather than a computer making a request to a web server thousands of miles away and then downloading the images and content every time, cache will retain most of it in memory, for any browser. This saves time and web pages open up a lot faster thanks to cache in browsers.

Clear-Cache-Only

A CPU has got the same problem, it can talk to its own memory a whole lot faster than what it can to the main memory. So, every time the CPU requests a bit of data, it ‘caches’ a copy to its local memory. This allows it to fetch it much faster in the near future when need be.

Added Tricks

But that’s not all. Local memory on a CPU allows it to not only store and read data by the byte but also the next line. If the CPU executes one instruction at a time, there is a good chance that it will then be followed by a known number of instructions following the main action.

modern-cpus-and-caches
How it all works

So rather than just getting one word from memory at a time, the CPU can access the next 128 bytes of memory and it will read, what is called, the cache line – one single line out of 128 from the CPU, in one go. The idea is always to reduce time and make the whole process much faster.

Buying a PC? Then here’s how you can compare CPU, RAM and other specs before finalizing your purchase.

Bigger is Always Better?

Well, not always, but in the case of memory cache – it certainly is. Let us know your doubts in our forum, if you still have any.

Show Comments Hide Comments