A processor cache

cpucpu-cache

I recently downloaded CPU-Z just to check things out, and saw a tab marked Cache on it. It shows what appears to be different memory sizes, and I have seen processors being advertised with an X sized cache. What is the function of this, and how big should it be to work well?

Cache size

Best Answer

In a computer you have a bunch of different layers of memory, which you can imagine "nearer" or "farther" from processor.

Memories near the processor are fast but small, and memories far from the processor are big but slow.

The faster memory is composed by processor's registries, which can be immediately accessed by the processor. Then you have L1 data cache, which is typically 32K and can be accessed in just one clock cycle, then L2/L3 cache, which are few MB (from 2M to 12M) big and can be accessed in tens of clock cycles. Then comes the main memory, which is far larger (some gigabytes) but are very slow (hundreds of clock cycles to be accessed). Then comes disks, which are hundred of gigabytes big but soooo slow ;)

This is commonly known as memory hierarchy.

What do you want, ideally, are memories as big as disks, but as fast as registers. To come as close as possible to this, data is continually moved from RAM to registers and viceversa.

Who does all of this? Well, the hierarchy is managed in an automatic way from L1 up to main memory by the processor, while main memory and disk is managed by the operating system in cooperation with the processor.

The full story is far more technical and complicated, but I hope this will give you some insights ;)