silicon atlasTHE HARDWARE REFERENCE
العربية
Reference/Memory & storage
Memory & storage

Registers, caches & the memory hierarchy

Small fast storage hides the cost of larger, slower storage.

Your CPU can spend more time waiting for data than calculating with it.
Registers

Immediate operand state.

LIVE EXPERIMENT

Make a cache miss

Runs on your device
BYTE ADDRESS0Block 0 → Set 0MISS
SET 0tag 0
SET 1·
SET 2·
SET 3·
SET 4·
SET 5·
SET 6·
SET 7·
Accesses1
Hit rate0%
Bytes fetched64
Select any access above, or step through the trace.

A cache fetches a whole line. Locality reuses it; conflicting mappings can evict useful data even before total capacity is exhausted.

What this model includes

One read-only cache, 64-byte lines, LRU replacement, eight total lines, eight-byte elements, 32 accesses. No prefetching or multilevel effects.

FOLLOW THE MECHANISM

What happens inside

1

Exploit locality

Temporal locality means using a value again soon. Spatial locality means using nearby addresses. Caches keep copies of lines, often 64 bytes on current mainstream CPUs, though the size is architecture-specific. A hit returns data from that level; a miss searches farther down the hierarchy.

2

Balance size and delay

L1 is usually small and near a core; L2 is larger, and the last-level cache may be shared. Register files are not an ordinary addressable cache. Misses consume queues and bandwidth. Hardware prefetchers try to predict future accesses, but irregular pointer chasing gives them little to work with.

PUT IT TO WORK

What this means for your code

Low-level engineer

Measure working-set size, miss latency, and memory-level parallelism. Cache inclusion and sharing policies are microarchitecture-specific.

Software developer

Dense arrays often outperform linked objects for scans. Reduce unused fields and repeated allocations when they inflate the working set.

GO TO THE SOURCE

Read the actual specifications

These references supply the underlying contracts and implementation details. The diagrams here are simplified teaching models.

Cornell · CachesCornell University
Intel · Optimization reference manualsIntel

Keep following the connection

Understood the idea? Keep a note of your progress.