Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 02 · How Computers Work · The machine runs a program · about 16 min to read

Play it as a journeyTutor comes with a plan

The Memory Hierarchy (cache, locality, the memory wall)

The Memory Hierarchy
The Memory Hierarchy · Open board

The small, fast copies of memory a CPU keeps close, stacked in front of the huge, slow warehouse everyone calls RAM. Follows The CPU (fetch-decode-execute, the ISA, assembly), which left open how far the fetch step reaches for its data. This lesson is that gap, and the one thing you control about it.

Before you start. The CPU (fetch-decode-execute, the ISA, assembly) gave you the loop: fetch, decode, execute, using registers built into the chip. Almost every step eventually needs data from outside the chip, and how far away that data lives is the whole subject here. If a linked list is new, Linked Lists, Stacks & Queues in DSA shows it in one read.

Lesson 6 of 41 in How Computers Work

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1965: Cambridge, and a processor waiting on memory
  • 1968: IBM builds one, and gives it a shorter name
  • The gap a cache hides
  • The cache line: nothing moves one crumb at a time
  • Hit or miss: the roll that prices a read
  • Locality: the one lever you actually control
  • One layer still hidden

Terms it explains: cache, cache line, hit, miss, locality, pointer chase, TLB, DRAM, hit rate, hit/miss, latency vs bandwidth, LRU/associativity, memory wall, MMU/page table, NUMA, prefetch, spatial locality, SRAM, swap/paging, temporal locality, virtual memory, working set.

Lab

Same data, same O(n), four access patterns. Why is one of them 31 times slower?

Pick Following a chain of pointers, drag Memory the loop walks from end to end, and watch The bill jump.

Open The memory hierarchy

Related paper

Review How Computers Work