THIS EXPLANATION
THE ROOM
CDA·270 Computing, Data & AI 6 MIN · 8 STATIONS

Write amplification

A Socratic walk-through of write amplification — reasoned out one step at a time, not lectured.

abcdefgh
a

The question we started with

THE QUESTION #

Why does saving a few kilobytes to a solid-state drive sometimes force it to rewrite far more than that?

You save four kilobytes. The drive's own counters, tracking how much the host asked it to store and how much it actually programmed into flash, disagree — sometimes by a factor of two, sometimes by ten. Nothing was lost or duplicated for safety, and the file is the size you think it is.

So where did the extra writing come from? The tempting answer is overhead — metadata, checksums, alignment. That is wrong in an interesting way, because such overhead is roughly constant while this ratio moves: it depends on how full the drive is and how you write. What mechanism produces a cost that grows with occupancy?

b

Reasoning it through

REASONING #

Start with what flash physically permits, because the whole phenomenon is downstream of one asymmetry. Cells are programmed in units of a page — a few kilobytes, though the figure varies by generation and I am recalling rather than deriving it. But they cannot be individually returned to the blank state: erasing works only on a much larger unit, a block of many pages, typically measured in megabytes.

So what happens when the host overwrites four kilobytes that already exist in flash? The drive cannot clear that page in place, because clearing means erasing everything around it, so it does not try. It writes the new data to a fresh page elsewhere, updates an internal map from logical address to physical location, and marks the old page invalid. Fast, cheap, and nothing amplified yet.

The bill arrives later. Do that enough times and fresh pages run out, while the drive is littered with blocks part live and part invalid. To recover space it must erase a block, and to erase a block it must first move every still-valid page elsewhere. That copying is the extra writing: nobody asked for it, it carries no new information, and it consumes flash exactly as real writes do.

Now put a number on it. Suppose the block chosen for reclamation has a fraction u of its B pages still valid. The drive copies u times B pages out, then erases, yielding B free pages — but u times B are immediately consumed by the copies just made, so the net gain is one minus u, times B. Every page of host data therefore costs one page for itself plus u over one minus u pages of copying: a total of one over one minus u. At u of a half, amplification is two; at three quarters, four; at nine tenths, ten. That is not a slope but a cliff, which is why nearly all the damage happens in the last stretch of a full drive.

Two things set u. The first is spare capacity: every drive keeps some flash the host cannot address, and that reserve is what keeps blocks from being nearly all live at reclamation time. The second is the access pattern. Write a large file sequentially and its pages land in the same blocks and die together, so deleting it invalidates whole blocks at once, u falls near zero, and amplification approaches one. Scatter small writes randomly and every block ends up a mixture, so u stays high. Amplification is not a property of the drive but of a workload meeting an erase granularity.

A third factor concerns deletion, because the drive cannot see your filesystem. Deleting a file unlinks a name and marks blocks free — bookkeeping invisible below. Unless the filesystem tells the drive those addresses are now meaningless, the drive believes every page it ever wrote is still live, u climbs toward one, and it dutifully relocates data nobody wants. That is what the discard command sends.

How would we know this account is wrong? It makes two predictions, cheap to check against the drive's own host-write and physical-write counters. Leave part of the drive unallocated, and measured amplification should fall with no change to the workload. Convert a random small-write workload into an append-only sequential log and it should fall toward one, with no change to the hardware. Both are standard practice because both work. The refuting observation would be a workload whose amplification is unmoved by over-provisioning and unmoved by making writes sequential — which would say the extra traffic comes from something else, such as metadata, error-correction encoding, or the filesystem above.

c

The analogy

THE ANALOGY #
THE FIGURE

Think of a multi-storey car park where the only way to free a bay is to clear an entire floor at once. When a driver leaves, the attendant marks the bay dead and sends the next arrival to a fresh floor. Eventually no fresh floors remain, so the attendant picks the floor with fewest live cars, drives each of them up to a new floor, and clears the old one. All that driving is work nobody requested, and the fuller the park, the more cars shifted per bay recovered.

WHERE IT BREAKS DOWN

a car that drives out announces its departure, whereas a deleted file does not — the storage layer keeps ferrying data nothing wants until the filesystem sends word, which is why the discard command exists and why a drive that never receives it degrades faster than the arithmetic alone predicts.

d

Clarifying the model

THE MODEL #

Three refinements.

The first is why this matters. Flash cells tolerate a finite number of program and erase cycles, and that budget shrinks as manufacturers store more bits per cell — I will not quote figures, since published endurance ratings vary widely by generation and vendor. Amplification spends the budget faster than the host's write volume suggests, and consumes write bandwidth too, which is why a nearly full drive gets slower as well as older.

The second is the distinction from the garbage collection that pauses a running program. The mechanisms rhyme — both reclaim space held by dead objects by relocating live ones — but a runtime's collector spends latency, a drive's a finite physical endurance budget.

The third is that the real subject is not flash. The durable fact is a granularity mismatch: whenever the unit you can clear is much larger than the unit you write, the difference is paid in relocation — by log-structured filesystems in cleaning, by merge trees in compaction, by shingled disks when overlapping tracks are rewritten. Flash illustrates a constraint that will outlive it.

e

A picture of it

THE PICTURE #
Write amplification
Write amplification The two ribbons on the left are the sources of physical write traffic, sized against each other. This is the case where blocks are three quarters live when reclaimed, so the formula gives an amplification of four: for every unit the host asked to store, three units of still-valid data are shuffled elsewhere to free space. The ribbon on the right is what the flash pays from its finite endurance -- four units, of which only the leftmost carried anything new. Emptier drives and sequential writes narrow the relocation ribbon toward nothing; a full drive with scattered writes widens it. {"generator":"[email protected]","source":"../Socrates/.diagram-cache/_src/write-amplification.md","sourceIndex":1,"sourceLine":4,"sourceHash":"fef9e7168301c5a45d9af53d88a06509f54c977818023d697e718e36e3be8653","diagramType":"sankey","layoutVariant":"source","repairedDuplicateIds":[],"motion":"entrance-with-reduced-motion-fallback","presentation":"editorial","attempt":1,"viewBox":{"x":0,"y":0,"width":720,"height":542},"qa":{"passed":true,"findings":[]}} Hostwrites · 1 Flashprogrammed · 4 Relocatedvalidpages · 3 Endurancespent · 4

How to readThe two ribbons on the left are the sources of physical write traffic, sized against each other. This is the case where blocks are three quarters live when reclaimed, so the formula gives an amplification of four: for every unit the host asked to store, three units of still-valid data are shuffled elsewhere to free space. The ribbon on the right is what the flash pays from its finite endurance — four units, of which only the leftmost carried anything new. Emptier drives and sequential writes narrow the relocation ribbon toward nothing; a full drive with scattered writes widens it.

f

What became clearer

WHAT CLEARED #
WHAT CLEARED

Solid-state storage can be written in small pieces but only cleared in large ones, and that single asymmetry is the whole story. Overwriting never happens in place; it defers the cost by leaving debris, collected later by relocating whatever is still alive around it. The cost of that relocation is one over the fraction of dead space available — a cliff, not a slope — so spare capacity, sequential access and telling the drive what has been deleted are the three levers, all working by lowering how much live data must move to recover a block.

g

Where to go next

ONWARD #
  • How log-structured merge trees trade write amplification against read amplification.
h

Key terms

TERMS #
TermWhat it means
Page / erase blockthe smallest unit of flash that can be programmed, and the much larger unit that must be erased together.
Flash translation layerthe firmware map from host logical addresses to physical locations, which makes out-of-place writing invisible.
Over-provisioningflash the host cannot address, reserved to keep reclaimed blocks from being nearly all live.
Discard commandhow a filesystem tells a drive that certain addresses no longer hold wanted data.

Every term the collection defines is gathered in the glossary.

Nearby on the shelf

4