Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
This looks like a good question for [community-faq]. – bwDraco Jun 3 '11 at 1:18
Duplicate of… – jcrawfordor Jun 3 '11 at 5:27
@jcrawfordor, this is not a duplicate. This is a more general question than the one you are linking to. – bwDraco Jun 3 '11 at 6:16
up vote 11 down vote accepted

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 ;)

share|improve this answer
i'd also add, physically, l1 caches are physically part of the processor, l2 can be on separate dies - an extreme case was the pentium II which had large, separate ram chips for l2 cache – Journeyman Geek Jun 3 '11 at 1:55
@Journeyman Geek: feel free to edit my answer ;) – akappa Jun 3 '11 at 2:19
Why RAM cannot become cache memory if cache is ways faster? Why industry cannot move to cache memory instead of RAM? Are materials very expensive? – Boris_yo Jun 3 '11 at 8:48
@Boris_yo: due to latencies and memory density (you need a lot of silicon to manufacture few hundreds of MB of memory using the structure employed by caches) – akappa Jun 3 '11 at 12:11
@akappa: Would it be too technical to mention scratchpad memory (present in some embedded processors)? Such provides fast access to a modest amount of memory for which allocation is managed by software (guaranteeing fast access for specific timing-critical memory contents, which cache block or way locking can also provide) without the power, area, and latency overhead of a cache (which locking techniques do not avoid). Also caching can save energy because of smaller size and greater integration and because some energy is used while waiting for a memory access (shorter wait, less energy). – Paul A. Clayton Dec 17 '12 at 15:22

A processor cache is a small amount of memory on or near the processor itself that is used to speed up access to data.

Since accesses to RAM are significantly slower than actual data processing, keeping the most recently and frequently used data near or on the processor can significantly increase performance.

While main memory (RAM) can be very large (several gigabytes), the CPU must wait several clock cycles before it can access data from main memory. The CPU cache can be accessed very quickly and is generally used to store the most frequently or recently used data. The larger the cache, the less often the processor will need to access the slower RAM. However, too large a cache may slow access as the processor will need more time to find the data.

For more information, see the Wikipedia article on CPU cache. Feel free to add more details as well as technical information to this answer.

share|improve this answer
You cannot really answer to such a question in a "comprehensive manner", because this topic is TRULY HUGE. – akappa Jun 3 '11 at 1:29
@akappa I agree, but I think we can draw the line somewhere between this answer, as it exists now, and READ THIS. The question seems to ask for a basic overview, rather than a literature review. So, I fully agree with @DragonLord that community wiki is appropriate here. – sblair Jun 3 '11 at 2:21
This is a big, big bait... Let's bite it when we have more time... – bubu Jun 3 '11 at 8:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .