Intuition The ONE core idea
A cache is a small fast notebook holding copies of data that really lives in slow main memory. Every symbol on the parent page exists to answer one question: after the CPU scribbles a new value into its notebook copy, when and how do we make the slow "real" memory agree again — right now, or later, and do we even bother copying a block in before writing it?
Before you can read the parent note, you must own every word and letter it throws at you. Below, each item is built from nothing: what it means in plain words → the picture it maps to → why the topic needs it. They are ordered so each one leans only on the ones above it.
Definition Main memory (DRAM)
The big, slow storage that holds the true value of every data location. Think of a huge library with millions of numbered shelves. Slow to walk to, but it is the authority — if two places disagree, memory is the one we must eventually make correct.
A tiny, fast notebook near the CPU holding copies of a few recently-used memory locations. Fast to reach, but small, so it can only hold a handful of copies at once.
Look at the figure: the CPU (left) talks to the small blue cache almost instantly; reaching the big gray memory on the right is a long slow trip. This distance-and-size difference is the entire reason write policies exist — we want to touch the far box as rarely as possible.
Prerequisite depth on this lives in Cache Memory Fundamentals .
Definition Block / cache line
Caches never copy one byte at a time. They copy a fixed-size chunk of neighbouring bytes — a block (typically 64 bytes). One slot in the cache that holds one block is called a line .
Intuition Why a whole block, not one byte?
Programs tend to use data that sits close together (the next array element, the next instruction). Copying a whole neighbourhood at once means the next few accesses are already there. This "things near each other get used together" idea is called locality — remember that word, the whole topic rests on it.
The data is not in the cache. Slow: we must go to memory to get it (or, for a write, decide what to do).
The parent note splits the world into "write HIT " and "write MISS " and gives a different rule for each. So hit/miss is the first fork in every decision — it decides which column of the parent's tables you are in.
A read only looks at the copy — it changes nothing, so memory and cache can never disagree because of a read. A write changes the copy. The instant the CPU writes, the notebook copy and the library shelf can hold different numbers . Every policy on the parent page is a rule for handling exactly this disagreement.
A copy that is out of date — it disagrees with the true, most-recent value. If we let stale data be read, the program (or another core, or a DMA device) computes on a wrong number. Avoiding stale reads is the correctness goal. See also DMA and I/O Consistency and Cache Coherence — MESI for who else can be fooled by stale copies.
A single extra bit attached to each cache line. It answers one yes/no question: "has this copy been written to since we loaded it?"
dirty = 0 (clean): copy still equals memory. Safe to throw away.
dirty = 1 (dirty): copy was changed; memory is now stale and must be rescued before we discard the copy.
The picture shows two lines: a green clean one (0) and a red dirty one (1). The topic needs this bit because write-back delays the memory update — and the only way to later remember "this line owes memory an update" is to have flagged it. Write-through never delays, so it never needs this bit.
Definition Eviction (replacement)
The cache is small. To load a new block into a full line, an old block must be kicked out — evicted . Which one leaves is decided by a replacement policy (a separate topic). What matters here: eviction is the moment a dirty block finally gets written back to memory.
Intuition Why eviction is the trigger
Write-back's whole plan is "delay the memory write as long as possible." The last possible moment is when we're about to reuse the line for someone else — because after that, the old copy is gone. So eviction of a dirty=1 line forces the deferred memory write. This is the single most misunderstood step in the parent note.
The parent's cost formula uses six symbols. Here is each, from zero.
h = hit rate — the fraction of writes that hit. A probability, so 0 ≤ h ≤ 1 . If h = 0.95 , then 95 out of 100 writes find their block already cached.
m = 1 − h = miss rate — the leftover fraction that miss. Because every write either hits or misses, h and m must add to 1.
t c = cache access time — how many cycles one cache touch costs (small, e.g. 1).
t m = memory access time — how many cycles one memory touch costs (large, e.g. 50).
d = dirty fraction — of the blocks we evict, what fraction were dirty (and so cost an extra write-back). Also a probability, 0 ≤ d ≤ 1 .
Recall Why is
t m multiplied by m in write-back but not in write-through?
Because write-through hits memory on every write (so the coefficient is 1), while write-back only reaches memory on the misses (coefficient m ), plus the occasional dirty write-back (m ⋅ d ). Small m ⇒ big savings.
More on how these times chain into overall performance: Memory Hierarchy and AMAT .
A tiny queue that catches memory-bound writes so the CPU can keep running instead of waiting for slow DRAM. The write "leaves" instantly into the buffer; the buffer drains to memory in the background.
Intuition Why the parent mentions it
Write-through looks fatally slow (a t m on every write), but a write buffer can hide that latency in practice — which is exactly why the "write-through is always slower, nobody uses it" mistake is wrong. Deep dive: Write Buffers and Store Buffers .
Memory vs Cache two notebooks
Eviction triggers write back
Write buffer hides latency
Read the arrows top-to-bottom: nothing points into a box until everything it depends on is already built. That is the order this page introduced them.
Self-test: cover the right side and answer before revealing.
Where does the "true" value of a data location live? In main memory (DRAM); the cache only holds copies.
What is a block / cache line? A fixed-size chunk of neighbouring bytes (e.g. 64 B) — the smallest unit the cache copies at once.
What is locality and why does it matter? The tendency to reuse nearby data soon; it makes caching (and write-back) pay off.
Hit vs miss in one line each? Hit = the wanted data is already cached; miss = it is not, so we must reach memory.
Why are writes harder than reads? A read changes nothing, but a write makes the cached copy disagree with memory (possible stale data).
What is stale data? A copy that is out of date — it no longer matches the true value in memory.
What does the dirty bit record, and its two values? Whether a line was written since load: 0 = clean (matches memory), 1 = dirty (memory is stale).
Which policy needs the dirty bit, and why? Write-back, so it remembers which evicted lines still owe memory an update.
What event forces a dirty block's memory write in write-back? Eviction (replacement) of that dirty line.
What do h and m mean and how are they related? Hit rate and miss rate; m = 1 − h .
What do t c and t m stand for? Cache access time (small) and memory access time (large).
What does d mean? The fraction of evicted blocks that are dirty (they pay an extra write-back).
What does a write buffer do? Queues memory-bound writes so the CPU need not stall waiting for slow DRAM.