Cache or Registers - which is faster?

user1255454 picture user1255454 · Jan 24, 2013 · Viewed 29.5k times · Source

I'm sorry if this is the wrong place to ask this but I've searched and always found different answer. My question is:

Which is faster? Cache or CPU Registers?

According to me, the registers are what directly load data to execute it while the cache is just a storage place close or internally in the CPU.

Here are the sources I found that confuses me:

2 for cache | 1 for registers

http://in.answers.yahoo.com/question/index?qid=20110503030537AAzmDGp

Cache is faster.

http://wiki.answers.com/Q/Is_cache_memory_faster_than_CPU_registers

So which really is it?

Answer

Hans Passant picture Hans Passant · Jan 24, 2013

CPU register is always faster than the L1 cache. It is the closest. The difference is roughly a factor of 3.

Trying to make this as intuitive as possible without getting lost in the physics underlying the question: there is a simple correlation between speed and distance in electronics. The further you make a signal travel, the harder it gets to get that signal to the other end of the wire without the signal getting corrupted. It is the "there is no free lunch" principle of electronic design.

The corollary is that bigger is slower. Because if you make something bigger then inevitably the distances are going to get larger. Something that was automatic for a while, shrinking the feature size on the chip automatically produced a faster processor.

The register file in a processor is small and sits physically close to the execution engine. The furthest removed from the processor is the RAM. You can pop the case and actually see the wires between the two. In between sit the caches, designed to bridge the dramatic gap between the speed of those two opposites. Every processor has an L1 cache, relatively small (32 KB typically) and located closest to the core. Further down is the L2 cache, relatively big (4 MB typically) and located further from the core. More expensive processors also have an L3 cache, bigger and further away.