Code of the Day

Computer Architecture

How a CPU actually executes your code — the fetch-decode-execute cycle, the memory hierarchy, pipelining, branch prediction, and cache locality.

Computer Architecture2 min read

When you write a loop, you probably think of it as "doing work some number of times." The CPU sees something very different: a stream of individual instructions, each manipulating a handful of bytes inside a tiny set of storage cells called registers. Everything about performance flows from understanding how that stream moves through the hardware.

This track covers three lessons:

  • The CPU and memory hierarchy — the fetch-decode-execute cycle and the speed/capacity trade-offs across registers, cache, RAM, and disk
  • Pipelining and branch prediction — how CPUs overlap instruction stages, and the cost when a branch guess is wrong
  • Cache locality in practice — temporal and spatial locality, the matrix traversal example, and struct layout choices
Finished reading? Mark it complete to track your progress.