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 05 · How Computers Work · Talking to the kernel · about 16 min to read

Play it as a journeyTutor comes with a plan

Spinning rust and flash: HDD and SSD internals

The Memory Hierarchy
The Memory Hierarchy · Open board

The layers of storage, each bigger and slower than the one above. This lesson opens the bottom layer: the spinning disk and the flash drive.

Before you start. A file system turns files into numbered blocks and sends those numbers down to a disk (The filing cabinet: how a file system is built). A save lands in the page cache in RAM first, and fsync forces it onto the disk (The drawer that says it saved). Storage is far slower than RAM, and every layer above it hides that gap (The Memory Hierarchy (cache, locality, the memory wall)). The disk sits across a bus (I/O, Interrupts & the Bus).

Lesson 27 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

  • The problem: the same bytes, very different speeds
  • The hard disk: a platter, a head, and the seek
  • The flash drive: no moving part, but a strange rule
  • The FTL: the translator that hides the rule
  • Write amplification: the host writes once, the chips write more
  • TRIM: telling the drive what is really free
  • The hard disk, as a script
  • The cost of collecting one block
  • The toy FTL
  • Other costs and how real drives cope

Terms it explains: seek, page, block, flash translation layer, FTL, write amplification, TRIM, Common mistakes, Garbage collection, cache, cache line, DRAM, hit rate, hit/miss, latency vs bandwidth, LRU/associativity, memory wall, MMU/page table, NUMA, prefetch, spatial locality, SRAM, swap/paging, temporal locality, TLB, 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