Lesson 11 of 13
Why a computer feels fast or slow
Explain the memory hierarchy — registers, cache, RAM, disk — and why 'more gigahertz' or 'more memory' sometimes helps a lot and sometimes does nothing.
01 · Learn · the idea
Two laptops sit side by side in a shop. Same brand, same “3.2 GHz” printed on the box. One feels instant; the other stutters when you open a few tabs. Or it’s one laptop, yours — quick at breakfast, crawling by lunch with the same apps open. The clock speed didn’t change. So what did?
The honest answer surprises most people. A computer’s speed is mostly not about how fast the processor thinks. It’s about how far the data has to travel to reach it. The processor (item 7) spends a shocking amount of its life simply waiting for the next number to arrive.
The processor’s problem: it’s fast and far from its data
The processor fetches, decodes, executes — over and over, billions of times a second. Each cycle it needs data: the number to add, the next instruction. The trouble is that the data lives in memory, and memory is some distance away from the processor on the chip. Distance, here, means time. Even at the speed of electricity, fetching from far-off memory takes many cycles — and the processor can do nothing but idle until it arrives.
So engineers do what you’d do if your tools were scattered around a workshop: keep what you use most within arm’s reach, and the rest further out. That arrangement is the memory hierarchy — and it explains nearly everything about why a machine feels fast or slow.
The four tiers, nearest to farthest
There are four main places data can live, and one iron trade-off runs through all of them: fast memory is tiny and dear; big memory is cheap and slow. You cannot have all three of fast, big, and cheap at once.
- Registers — a handful of slots right inside the processor. Instant. The accumulator from item 7 is one of these. There are only a few dozen.
- Cache — a small store on the chip itself that holds recently-used data. Very fast, measured in a few cycles. A few megabytes at most.
- RAM (main memory) — the gigabytes of fast memory made of latches (item 6). Quick by human standards, but a long trip compared to cache.
- Disk (an SSD or hard drive) — huge, cheap, and permanent, but vastly slower than RAM.
Each step down is roughly ten to a thousand times slower than the one above, and each step is far bigger and cheaper per byte. The whole craft of making computers feel fast is hiding that gulf — keeping the data the processor wants next as near the top as possible.
How big is the gulf, really?
The raw numbers are too small to feel: a register or cache hit takes about 1 nanosecond (a billionth of a second), RAM about 100 nanoseconds, an SSD about 100,000 nanoseconds — a tenth of a millisecond. A spinning hard disk is slower still.
So scale them up by a billion, to human time. If reaching a register took 1 second, then:
- Cache is also about 1 second — right there.
- RAM is about 2 minutes away. You’d put your work down and wait.
- An SSD is about a day or more. The processor, in its own terms, sits idle for an eternity to fetch one number off disk.
That is the picture to hold. To a processor, going to disk isn’t slow — it’s a geological age.
A worked example: one number, two places
Say the processor needs a single number to do its next sum. Same processor, same clock speed, two cases.
Case one: the number is in cache. The processor asks, and ~1 nanosecond later it has it. It computes immediately and moves on. No waiting.
Case two: the same number is only on disk. The processor asks, and now it waits ~100,000 nanoseconds — a hundred-thousand-fold longer — staring at nothing the whole time. One number. A hundred thousand times the delay.
Nothing about the processor changed between those cases. Not the GHz, not the design. The location of the data decided everything. That is the heart of it: where the data sits matters far more than how fast the chip runs.
Why more RAM helps — until it doesn’t
Now the two payoffs you can actually use. First, RAM.
Your programs need a working set of data in RAM to run smoothly. If it all fits, the processor stays in the fast tiers. But if you open too much and the working set won’t fit, the operating system (item 10) starts shoving the overflow out to the slow disk — a move called swapping — and pulling it back when needed. Suddenly the processor is making those day-long disk trips constantly. Everything crawls. That’s the lunchtime slowdown with twenty tabs open.
Adding RAM fixes exactly this: enough to hold what you’re using keeps you off the disk. But once you have enough, more RAM does almost nothing — the processor was never waiting on memory it already had. More headroom you don’t use is just empty room.
Why more gigahertz sometimes does nothing
Second, the clock. A faster clock (item 7) only helps if the processor has data to chew on. If a job is memory-bound — constantly waiting on data to arrive — then doubling the GHz just means the processor waits faster. The bottleneck is the trip to memory, and the clock has no say over that. You can rev the engine all you like; if it’s stuck at a red light, it goes nowhere quicker.
So “more gigahertz” helps a job that’s busy computing, and barely touches a job that’s busy waiting. Which kind a job is decides whether the number on the box matters at all.
”Fast” is a system, not a number
Here is the whole of it. “Fast” isn’t one figure on a box. It’s a system where the slowest necessary trip sets the pace, and every clever part — the cache, the instinct to keep hot data near — exists to hide distance from a processor that hates to wait.
You sit inside this too. The lag you feel is rarely the chip thinking hard; it’s the chip waiting on a number that wandered too far away. The useful question was never “how many gigahertz?” It’s “what is it waiting on?” Next, you’ll read a real spec sheet with exactly that question in hand.
02 · Try · the lab
03 · Check · quick quiz
1. Put the four places data can live in order, from the fastest (nearest the processor) to the slowest (farthest).
- Disk, RAM, cache, registers
- Registers, cache, RAM, disk
- RAM, registers, disk, cache
- Cache, registers, disk, RAM
Answer
Registers, cache, RAM, disk — Registers sit inside the processor and are instant; cache is on the chip and very fast; RAM is bigger but a longer trip; disk is huge, cheap, and vastly slower. Each step down trades speed for size.
2. A program keeps crawling. You add a lot more RAM and it speeds up hugely. A friend adds the same RAM to a different program and sees no change. What best explains both results?
- More RAM always speeds a computer up; the friend's machine must be broken
- The first program's data didn't fit in RAM and was spilling to the slow disk; the friend's already fit, so the extra RAM sat unused
- RAM only helps programs that do a lot of arithmetic
- The friend needed more gigahertz instead, which is the same thing as RAM
Answer
The first program's data didn't fit in RAM and was spilling to the slow disk; the friend's already fit, so the extra RAM sat unused — RAM helps by keeping your working data off the slow disk. If it was overflowing to disk (swapping), more RAM is a big win. Once everything already fits, extra RAM does nothing — there was nothing left waiting on the disk.
3. Two computers have identical clock speeds. The same job runs much faster on one of them. Which explanation fits what this lesson taught?
- The faster one has more gigahertz hidden somewhere
- Clock speed is the only thing that sets how fast a job runs, so this can't happen
- On the faster machine the data the job needed was nearer the processor, so the CPU waited less for it to arrive
- The slower machine was simply older
Answer
On the faster machine the data the job needed was nearer the processor, so the CPU waited less for it to arrive — Where the data sits often matters more than the clock. If one machine kept the needed data in fast, near memory and the other had to make long trips to fetch it, the first finishes far sooner — same GHz, different waiting.
4. A job spends almost all its time waiting for data to arrive from memory, not computing. You double the processor's gigahertz. What happens?
- It runs about twice as fast, because GHz always doubles speed
- Barely any change — the job was waiting on memory, and a faster clock just makes it wait faster
- It runs slower, because higher GHz overheats the memory
- The job now fits in cache automatically
Answer
Barely any change — the job was waiting on memory, and a faster clock just makes it wait faster — A faster clock only helps when the processor has data to chew on. A memory-bound job is stuck waiting for the trip to memory, which the clock can't speed up — so doubling GHz mostly just makes it wait faster.