Topic 0 › Memory
Table of Contents
CPU land: no GPU in sight. By the end of this topic you can explain why a memory access costs what it costs, predict the cache behavior of simple code, and napkin-math the runtime of a loop before running it. Every later topic is a callback to what happens here.
- 0.0IntroductionWhy memory first: the three ideas that carry the whole curriculum.
- 0.1Bytes and addressesMemory is one giant byte array; a pointer is just an index into it.
- 0.2The physics of storageSRAM vs DRAM: why fast memory can't be big and big memory can't be fast.
- 0.3Latency vs bandwidthA pipe has a length and a width. They are different numbers with different costs.
- 0.4The memory wallCPUs got ~100× faster; DRAM latency barely moved. The hierarchy is the only way out.
- 0.5CachesLines, hits, misses, eviction, and why a miss always costs a full 64-byte line.
- 0.6LocalityThe same loop, two traversal orders, 25× apart. Spatial and temporal locality explain why.
- 0.7Data layoutAoS vs SoA, alignment, padding: layout is a locality decision you make at declaration time.
- 0.8Virtual memoryPages, page tables, TLBs: every address you've ever used was a fiction.
- 0.9How CPUs fight latencyPipelines, out-of-order, prefetching: the machinery that hides memory latency, until a dependency chain blocks it.
- 0.XCapstone: napkin mathLatency numbers everyone should know: predict memcpy and matrix-sum times, then measure.