Hardware

CPU Cache Explained: L1, L2 and L3 in Plain Words

CPU cache explained: what L1, L2 and L3 cache do, sizes and speeds, cache lines and misses, a worked access-time example, and when more cache helps.

By OmniAI Editorial · Nov 23, 2026 · 10 min read

CPU cache is a small amount of very fast memory built into the processor that keeps copies of the data and instructions the CPU is most likely to need next. Main memory (RAM) is large but slow compared with the processor: fetching something from RAM can take hundreds of clock cycles, during which a core could have done useful work. Cache hides most of that delay by serving the majority of requests from memory sitting right next to the cores.

Modern CPUs use several levels: a tiny, extremely fast L1 per core, a larger L2 per core, and a big L3 shared by many cores. With CPU cache explained level by level, this guide covers what it is, how the levels work, typical sizes and speeds, what cache lines and misses are, a worked example of how much cache saves, how code can use it well, and when buying a CPU with more cache actually helps.

CPU Cache at a Glance

LevelTypical size (modern desktop)Approximate speedShared?Role
L1Tens of KB per core, split into instruction and data cachesA few cyclesPer coreHolds the data being worked on right now
L2Around 1–3 MB per coreRoughly 10–20 cyclesPer core (some designs share between core pairs)Catches what L1 misses
L3Tens of MB, sometimes over 100 MBTens of cyclesShared by many or all coresLast stop before RAM; shares data between cores
RAMGBsRoughly 60–100+ nanoseconds (hundreds of cycles)Whole systemMain working memory

Exact figures vary by processor generation and design. AMD's Ryzen 7 7800X3D, for example, lists 512 KB of L1, 8 MB of L2 and 96 MB of L3 cache across its 8 cores.

What Is CPU Cache?

What is CPU cache, physically? It's SRAM (static RAM) built on the processor die itself. SRAM is much faster than the DRAM used for main memory, but each bit takes far more space and power, so caches stay small. Our comparison of SRAM vs DRAM covers the trade-off.

Why is CPU cache important? Because the gap between processor speed and memory speed is so large that without it, cores would spend most of their time waiting. Cache works because programs are predictable in two ways:

  • Temporal locality: data used recently is likely to be used again soon, like a loop counter or a frequently called function.
  • Spatial locality: data near something just used is likely to be used next, like the next element in an array.

The cache keeps recently used data (temporal) and fetches whole neighbouring chunks at once (spatial). When the CPU needs a value, it checks L1 first, then L2, then L3, and only then goes to RAM. Finding it in cache is a hit; not finding it is a miss.

L1, L2, L3 Cache Explained

Four core boxes, each with a small block and a larger block, the first small block orange, connected to a shared bar above memory modules
Each core has its own small, fast L1 and L2; all cores share a larger L3 before RAM.

Together, the L1 L2 L3 cache hierarchy trades size for speed:

L1 cache

The smallest and fastest, inside each core. It's usually split in two: an instruction cache for the program's code and a data cache for the values it works on, so both can be read in the same cycle. Access takes only a few clock cycles.

L2 cache

Larger and somewhat slower, still private to each core in most current designs. It holds data that has recently been pushed out of L1 or is likely to be needed soon.

L3 cache

The largest and slowest level, shared by many or all cores on the chip. Besides catching misses from L2, it lets cores share data without going to RAM. Some processors stack extra L3 on top of the die; AMD's "3D V-Cache" chips, such as the 7800X3D, use this to reach 96 MB of L3.

A library analogy

L1 is the book open on your desk. L2 is the shelf beside you. L3 is the library on your floor that colleagues share. RAM is the warehouse across town. Most of the time, what you need is on the desk or the shelf.

Cache in Multi-Core and Chiplet Processors

With many cores sharing one chip, cache design shapes how cores cooperate:

  • Shared L3 lets one core find data another core recently used without a trip to RAM, which speeds up multi-threaded programs that share data.
  • Chiplet designs, where a processor is built from several smaller dies, often give each chiplet its own L3. A core reaches its own chiplet's L3 quickly, but data held in another chiplet's cache takes longer to fetch. Operating systems and games can be sensitive to which cores a program's threads run on.
  • Hybrid processors with performance and efficiency cores may give each type different cache arrangements, such as small clusters of efficiency cores sharing an L2.

For everyday use, none of this needs tuning. For performance-critical servers and games, pinning related threads to cores that share a cache can help.

Cache Lines, Hits and Misses

Caches don't move single bytes. They move fixed-size blocks called cache lines, 64 bytes on mainstream x86 processors. Reading one byte brings its whole 64-byte neighbourhood into cache, which is why reading an array in order is so fast: one miss loads the next several elements too.

Misses come in three kinds:

Miss typeCauseExample
CompulsoryFirst time the data is touchedReading a file buffer for the first time
CapacityThe working set is bigger than the cacheScanning a 200 MB table repeatedly
ConflictSeveral addresses compete for the same cache slotsStrided access hitting the same set over and over

Other mechanisms help or hurt:

  • Prefetchers in the CPU spot regular access patterns and load lines before they're requested.
  • Associativity sets how many places a given line can live in the cache; more flexibility means fewer conflict misses.
  • Coherence protocols keep each core's cached copies consistent when one core writes shared data.
  • False sharing happens when two cores write different variables that sit on the same cache line, forcing the line to bounce between cores and slowing both down.

How Much Does Cache Save? A Worked Example

The average memory access time (AMAT) combines hit times and miss rates across the levels. Assume a processor with these illustrative figures:

LevelAccess timeMiss rate (of requests reaching it)
L14 cycles5%
L214 cycles40%
L350 cycles30%
RAM300 cycles—

AMAT = 4 + 0.05 × (14 + 0.40 × (50 + 0.30 × 300)) = 4 + 0.05 × 70 = 7.5 cycles

Without any cache, every access would take about 300 cycles, 40 times longer. And small changes in miss rates matter:

ScenarioAMAT
Baseline7.5 cycles
L1 miss rate doubles to 10%11.0 cycles (+47%)
Bigger L3 halves its miss rate to 15%6.6 cycles (−12%)
Working set outgrows L3; miss rate rises to 60%9.3 cycles (+24%)

That's why code that fits its working data into cache can run several times faster than code that doesn't, on the same processor.

Writing Cache-Friendly Code

Two six-by-six grids: the left with an arrow along an orange top row, the right with an arrow down a grey first column
Walking memory in order reuses each cache line; jumping across rows wastes most of every line loaded.

Programmers can't control the cache directly, but they can arrange data and loops to suit it. The classic example is traversing a two-dimensional array stored row by row (as C does):

// Fast: walks memory in order, using every byte of each cache line
for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
        sum += a[i][j];

// Slow for large N: jumps a whole row each step, touching a new line every time
for (int j = 0; j < N; j++)
    for (int i = 0; i < N; i++)
        sum += a[i][j];

Both loops do the same arithmetic, but on large arrays the second is often several times slower because nearly every access misses.

Other cache-friendly habits:

  • Prefer contiguous arrays to linked lists and pointer-heavy structures.
  • Keep hot data together and cold data elsewhere (for example, structure-of-arrays layouts for data processed field by field).
  • Process data in blocks that fit in cache (tiling), which is how fast matrix libraries work.
  • Avoid false sharing by padding per-thread counters onto separate cache lines.
  • Measure. Tools such as Linux perf stat -e cache-misses show whether misses are the bottleneck.

Is More CPU Cache Better?

Is more CPU cache better? Usually it helps, but only when your workload's working set doesn't already fit and is limited by memory access:

WorkloadBenefit from extra L3
Many games, especially CPU-bound ones at high frame ratesOften noticeable; this is the main pitch for AMD's X3D chips
Large simulations, databases, compilation of big projectsOften helpful
Video encoding and renderingUsually small; these stream data and are compute-bound
Office work and web browsingNegligible
Workloads that already fit in L2 or L3None

Cache size is one factor among core count, clock speed, architecture and memory speed. Compare benchmarks for the software you actually use rather than cache size alone. For memory bandwidth, our guide to dual-channel RAM covers the next level down.

CPU Cache vs Other "Caches"

The word cache appears all over computing, always meaning "a faster copy of something slower":

TermWhat it cachesWhere
CPU cache (L1–L3)Memory contentsOn the processor
GPU cacheData for thousands of GPU threadsOn the graphics chip; see GPU vs CPU
Disk cache / page cacheFile data from storageIn RAM, managed by the operating system
Browser cacheWeb pages, images, scriptsOn your disk
KV cacheAttention keys and values in language modelsIn GPU memory

Common Myths

  • "Clearing CPU cache speeds up my PC." CPU caches manage themselves continuously; there's nothing for users to clear.
  • "More L3 always means faster." Only for workloads that run out of cache.
  • "L1 size is the most important spec." L1 sizes change little between generations; L2 and L3 sizes vary far more and show up in marketing.
  • "Cache and RAM are the same thing." Cache is a small, fast copy on the processor; RAM is the large main memory.

FAQ

What does L1, L2 and L3 mean?

They're levels of CPU cache. L1 is the smallest and fastest, per core; L2 is larger and slower, usually per core; L3 is the largest and slowest, shared between cores.

How much CPU cache do I need?

There's no fixed number. For gaming, chips with large L3 caches often help; for most other everyday tasks, core count and clock speed matter more.

Can CPU cache be upgraded?

No. Cache is built into the processor; getting more means buying a different CPU.

Is cache faster than RAM?

Yes, by a large margin. L1 answers in a few cycles; RAM takes hundreds of cycles.

What happens on a cache miss?

The CPU looks in the next level down, and if all levels miss, it fetches the line from RAM, stalling or switching to other work while it waits.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog