Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm trying to understand why certain CPU cache memories are faster than others. When comparing cache memory to something like main memory, there are differences in memory type (SRAM vs DRAM), and locality issues (on-chip vs having to traverse a memory bus) that can affect access speeds. But L1 and L2 are generally on the same chip, or at least on the same die, and I think they are the same type of memory. So why is L1 faster?

share|improve this question
6  
Because it's built that way. –  Ignacio Vazquez-Abrams Mar 31 at 1:54
8  
Super helpful, thanks for that. –  ConditionRacer Mar 31 at 1:56
    
There are multiple ways of building the same type of RAM. Some ways result in RAM that is faster than RAM built in other ways. –  Ignacio Vazquez-Abrams Mar 31 at 2:53
    
The same reason why your DDR RAM faster than your HDD... –  hassan789 Mar 31 at 2:56

3 Answers 3

up vote 9 down vote accepted

No, they're not the same type of RAM, even though they're on the same chip that uses the same manufacturing process.

Of all the caches, the L1 cache needs to have the fastest possible access time (lowest latency), versus how much capacity it needs to have in order to provide an adequate "hit" rate. Therefore, it is built using larger transistors and wider metal tracks, trading off space and power for speed. The higher-level caches need to have higher capacities, but can afford to be slower, so they use smaller transistors that are packed more tightly.

share|improve this answer
    
This is what I'm looking for, thanks. Do you know any good sources where I can read further about the differences? –  ConditionRacer Mar 31 at 3:59
    
No, not offhand. The details of these space/power/time tradeoffs, as well as choices regarding cache capacity and architecture, are tied very closely to the proprietary details of the manufacturer's processes, so very little (if anything) is published about it. I can only speak in general terms. –  Dave Tweed Mar 31 at 4:16
4  
L1 is also smaller, meaning signal propagation across it takes fewer clock cycles : often the size of L1 is decided as the largest memory accessible in 1 (or 2) clocks. –  Brian Drummond Mar 31 at 10:22
1  
In addition to Brian Drummond's point, L1 also typically uses data-tag parallel access. L2 typically accesses tags first (determining which way if any hit) then data, increasing latency but saving energy (significant given larger size, higher associativity, and higher miss rate). (L2 access also typically begins after an L1 miss is confirmed which increases it effective latency.) –  Paul A. Clayton Mar 31 at 12:09

L1 is usually used as a storage for decoded instructions, while L2 is a general cache for a single core. The lower the cache the smaller size it is and faster it usually is. As a rough rule of thumb for PC processors:

L1 Cache: 2-3 clock cycle access

L2 Cache: ~10 clock cycle access

L3 Cache: ~20-30 clock cycle access

The design of the L1 cache should be to maximize the hit rate (the probability of the desired instruction address or data address being in the cache) while keeping the cache latency as low as possible. Intel uses an L1 cache with a latency of 3 cycles. The L2 cache is shared between one or more L1 caches and is often much, much larger. Whereas the L1 cache is designed to maximize the hit rate, the L2 cache is designed to minimize the miss penalty (the delay incurred when an L1 miss happens). For chips that have L3 caches, the purpose is specific to the design of the chip. For Intel, L3 caches first made their appearance in 4 way multi-processor systems (Pentium 4 Xeon MP processors) in 2002. L3 caches in this sense greatly reduced delays in multi-threaded environments and took a load off the FSB. At the time, L3 caches were still dedicated to each single core processor until Intel Dual-Core Xeon processors became available in 2006. In 2009, L3 caches became a mainstay of the Nehalem microprocessors on desktop and multi-socket server systems.

Quote sourced here from "Pinhedd's" response.

share|improve this answer
1  
L1 is used for data as well generally but it's true that often L1 data and L1 instruction are separate while L2 is shared: programmers.stackexchange.com/questions/44731/… (one reason why it can be shared is that it has more ways). –  Guy Sirton Mar 31 at 22:01

Apart from inherent performance characteristics, locality also has a role (L1 is closer to the CPU). According to What every programmer should know about memory:

It is interesting to note that for the on-die L2 cache a large part (probably even the majority) of the access time is caused by wire delays. This is a physical limitation which can only get worse with increasing cache sizes. Only process shrinking (for instance, going from 60nm for Merom to 45nm for Penryn in Intel’s lineup) can improve those numbers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.