L1 vs L2 vs L3 Cache: Key Differences Explained
L1, L2 and L3 caches form a multi-level hierarchy ordered by distance from the CPU core: the closer a level is, the smaller and faster it is, and the farther it is, the larger and slower. In typical PC and server CPUs, representative ranges are tens of KB and a few cycles for L1, hundreds of KB to a few MB and a dozen or so cycles for L2, and a few MB to tens of MB and tens of cycles for L3. L1 and L2 are usually private to each core, while L3 is shared by several cores. An access to main-memory DRAM takes hundreds of cycles, so this hierarchy absorbs as many accesses as possible.
| Aspect | L1 cache | L2 cache | L3 cache |
|---|---|---|---|
| Relationship to cores | Private to each core | Usually private to each core. Some designs share it among a few cores | Shared by multiple cores (the whole chip or a cluster of cores) |
| Capacity (representative range for PC and server CPUs) | About 32 to 64 KB each for instructions and data | About 256 KB to a few MB per core | A few MB to tens of MB for the whole chip |
| Latency (representative range) | About 3 to 5 cycles | About 10 to 20 cycles | About 30 to 70 cycles. Longer for parts farther from the core |
| Instructions and data | Split (I-cache and D-cache) | Shared (unified cache) | Shared (unified cache) |
| Design priority | Short hit time. Used every cycle within the pipeline | Absorbing L1 misses and reducing the miss penalty | Reducing main-memory accesses and sharing data among cores |
| Where a miss goes | L2 | L3 | Main memory (DRAM) |
| Addressing | Often virtually indexed, physically tagged (VIPT) | Physical addresses | Physical addresses |
| Inclusion | Topmost level. Whether it is contained in the lower levels depends on their policy | Depends on the design, such as inclusive or non-inclusive | Making it inclusive makes it easier to narrow down coherence checks. Exclusive designs that eliminate duplication and non-inclusive designs also exist |
| Physical placement | Inside the core, right next to the execution units | Just outside the core, placed as part of the core | Often divided into per-core slices connected by a ring or mesh network |
| Line size | 64 bytes is common | 64 bytes is common | 64 bytes is common |
Figures are typical orders of magnitude and vary by process generation and product.