cache
Cache
Cache is fast on-chip memory between the CPU and main memory, holding recently used data. Caches exploit temporal locality (reuse) and spatial locality (adjacent access), organized in hierarchy: L1 (~1KB, ~1ns), L2 (~256KB, ~7ns), L3 (~20MB, ~100ns), memory (~100ns+). Cache lines (64 bytes) are the unit of transfer.
Multicore coherence adds complexity; False sharing occurs when unrelated variables share a line.
Example
Cache hierarchy on typical x86-64:
L1: 32 KB per core ~1 ns 8-way associative L2: 256 KB per core ~7 ns 8-way associative L3: 20 MB shared ~100 ns 20-way associative RAM: — ~100 ns+
cache.md · Last modified: by 127.0.0.1
