How much do L1 and L2 cache affect real performance?

By TechCompare · Updated · How we check

L1 cache access at about 1 ns is roughly 3 to 4 times faster than an L2 access at 3 to 4 ns. Keeping frequently used data in cache helps, and an L2 hit still costs 10-15 cycles against 200+ for a trip to RAM.

Calculator

Memory & Storage Throughput Visualizer

Data to transfer: 1.0 TB

L1 Cache2,000,000 MB/s
L3 Cache500,000 MB/s
DDR5 RAM (1 channel)48,000 MB/s
DDR4 RAM (1 channel)25,600 MB/s
NVMe Gen 514,000 MB/s
NVMe Gen 47,000 MB/s
NVMe Gen 33,500 MB/s
SATA SSD550 MB/s
HDD160 MB/s

L1 cache is the fastest memory in a computer, typically 1 ns latency (3-5 CPU cycles) and 32-64 KB per core. L2 cache is slightly slower (3-4 ns, 10-15 cycles) but larger (256 KB to 1 MB per core). A program whose hot data fits in L1 runs faster than one that spills into L2, and an L2 hit still beats going to RAM.

Hardware tier
CPU Cache
On-die processor cache levels
Topic focus
L1 vs L2 cache
l1-vs-l2

How this is calculated

Modern CPUs use a multi-level cache hierarchy because faster memory is more expensive per byte and takes more die area. L1 is split into L1i (instructions) and L1d (data), each per-core and private. L2 is also per-core but unified (instructions and data together). L3 is shared across all cores on a chiplet or die.

A miss in L1 that hits in L2 costs an extra 10-12 cycles. A miss that goes all the way to RAM costs 200+ cycles. This is why optimizing for cache locality (keeping data structures compact, accessing memory sequentially) can speed up a program by 10x or more.

Verdict

Keep hot data compact and read it sequentially, so the working set stays in L1 and L2. Compared with an L1 miss that hits L2, a miss that walks to RAM costs 200-plus. That gap is why cache-friendly code can run 10x faster.

More Latency scenarios

Frequently asked questions

What is the difference between L1 and L2 cache?
Speed versus size. L1 runs about 1 ns per access (3-5 CPU cycles) but holds only 32-64 KB per core, split into separate instruction and data halves. L2 is slower at 3-4 ns (10-15 cycles) but larger, at 256 KB to 1 MB per core, and unified. L1 is private and per-core. So is L2, while L3 is shared across cores.
How much slower is an L1 cache miss that hits L2?
About 10-12 extra cycles, so roughly 3-4x the L1 latency. That's survivable. The cliff comes when L2 misses too and the request walks to RAM, which costs 200+ cycles. The hierarchy exists precisely to keep most accesses in the tiers where a miss only costs a few cycles.
How do I write code that stays in L1 cache?
Keep hot data structures small and access them sequentially. Struct-of-arrays layouts and cache-line-sized chunks (64 bytes) let the prefetcher anticipate your next read. Linked lists and pointer-heavy structures scatter access across memory and miss constantly. Compilers can't fix layout for you, which is why data structure choice is a major lever in CPU-bound code.