Exercises — Average memory access time (AMAT)
Level 1 — Recognition
Goal: recognise which quantity is which, and read the formula.
Recall Solution
- ns — you always look inside the cache, so this is paid on every access.
- — the "not found" fraction.
- ns — the word "extra" is the giveaway: it's the additional cost beyond the look-up.
Paid every access: . The other two only matter when you miss.
Recall Solution
Correct: (b) . Why (b) is the right one — build it from the two possible outcomes. Split every access into its two cases and take the average (the definition of "expected time"):
- With probability you hit and pay just .
- With probability you miss: you still looked in the cache first () and then paid the fetch (), so you pay . The two terms cancel, leaving standing alone (paid every access) and gated by (paid only on misses). That is exactly form (b).
- (a) forgets you pay on the miss path too, so it drops one (see the L1 mistake below).
- (c) multiplies the wrong thing — hit time is unconditional, not gated by .
- (d) forgets that only a fraction of accesses pay the penalty.
Level 2 — Application
Goal: plug numbers into single- and two-level AMAT.
Recall Solution
Read it: of the ns, ns () came from the rare misses. Rare ≠ cheap.
Recall Solution
Convert first: .
Recall Solution
Step 1 — cost of one L1 miss (= AMAT of the L2 subsystem). What: treat L2 as its own little cache. Why: an L1 miss doesn't cost "DRAM time", it costs "whatever the L2 subsystem takes". Step 2 — plug that into L1. Sanity: the ns DRAM trip is scaled by the product , adding only ns of the total.
Level 3 — Analysis
Goal: compare designs and reason about which knob helps most.
Recall Solution
Baseline: ns.
- A: ns (saved ns).
- B: ns (saved ns). Winner: B, by ns over A. Attacking the penalty-weighted term ( ns) beats shaving the flat , because the miss term dominates the average here.
How to read the figure below. It is a bar chart. The horizontal axis simply names the three designs (Baseline, Option A, Option B) — it is not a number line, just three labelled slots. The vertical axis is AMAT in nanoseconds. Each bar's height is that design's computed AMAT, with the exact value printed on top: Baseline , A , B . Two bars are black (Baseline and A); the one red bar is Option B — the accent colour marks the winner, and you can see at a glance it is the shortest bar. Compare heights vertically: A barely dips below Baseline (shaving flat moves the top down by only ns), while B drops far lower (halving removes ns of the penalty term).

Recall Solution
Old: ns. New: ns. Worth it — barely ( ns). The miss saving ( ns dropped) outweighs the rise ( ns). This is the Cache Associativity & Hit Time tradeoff in action: lower can cost you , and you must weigh both.
Turning point: if the new had risen to ns instead, new AMAT — the trade would lose.
Level 4 — Synthesis
Goal: combine AMAT with other formulas (CPU time, local/global rates).
Recall Solution
(a) . (b) L2 only sees the forwarded accesses: . (c) Global = misses that reach DRAM over all accesses: . Check: ✅. This is why the recursive AMAT uses the local rate inside the nested term — L2 is blind to accesses L1 satisfied. See Multi-level Cache Hierarchy.
Recall Solution
First, define the symbols this problem borrows (they come from the CPU Performance Equation):
- CPI = cycles per instruction = how many clock cycles the CPU spends, on average, to finish one instruction.
- = the CPI you'd get if memory were free (every access an L1 hit, no stalls) = here.
- = the effective (real) CPI once you add the cycles the CPU wastes waiting on memory misses.
- ns/cycle = the clock period, ns — the wall-clock duration of one cycle. Dividing a time in ns by ns/cycle converts it into a count of cycles (the ns cancel).
Step 1 — stall time per access. What: the extra (stall) part of AMAT. Why: the flat is already covered by the pipeline's base CPI (the CPU assumes an L1 hit each cycle), so only the penalty term is a true stall. Step 2 — stall time per instruction. What: multiply per-access stall by accesses per instruction. Why: each instruction issues memory accesses on average, and every one of them carries the same expected ns stall, so the stalls add up — total stall time per instruction is (stall per access) (accesses per instruction). Step 3 — convert ns to cycles. Why: CPI is measured in cycles, so divide the stall time by the clock period ( ns/cycle); the ns units cancel, leaving cycles. Step 4 — effective CPI. What: add stalls onto the base. Why: real CPI = the work the CPU would do anyway plus the cycles it sits idle waiting on memory. This is the bridge to the CPU Performance Equation: AMAT's penalty term becomes memory-stall cycles.
Level 5 — Mastery
Goal: invert the formula, design to a target, and reason at limits.
Recall Solution
Set the formula to the limit and solve for : So . Any higher and you blow the ns budget. Note: if alone already exceeded ns, no miss rate (not even ) could meet the target — the flat cost already fails.
Recall Solution
(a) (perfect cache, always a hit): . The penalty vanishes — the best case; you only ever pay the look-up. This is the "perfect cache" baseline used in L4-Q2. (b) (never hits — every access misses): . You pay the look-up and the full fetch every single time. Worst case. (c) : for any . Even a tiny miss rate, if the penalty is unbounded, makes average time explode — the "rare but ruinous" regime AMAT is built to expose. (d) : . The floor is the miss cost alone; making the cache infinitely fast still can't beat the penalty-weighted term.
How to read the figure below and tie it to the formula. The horizontal axis is the miss rate , running from (left) to (right) — this is a genuine number line. The vertical axis is AMAT in ns, with ns and ns fixed. Because is linear in (a "" straight line), the red curve is a straight line whose height at any is literally . Trace it: the left endpoint () sits at height ns — that is case (a), where the term is zero and only the look-up remains. The right endpoint () reaches height ns — that is case (b), the full look-up-plus-fetch worst case. The slope of the line (how fast it rises as you move right) equals itself, ns per unit of : a bigger (case c) tilts the line steeper toward infinity; shrinking (case d) slides the whole line straight down toward the origin without changing its slope.

Recall Solution
Subtract; the common and the factor cancel out of the comparison: Reading it: L2 helps iff its hit time is smaller than the DRAM penalty scaled by L2's hit rate . Since DRAM is slow (hundreds of ns) and L2 hit time is small (a few ns), this is virtually always true — but if were near (L2 useless, almost everything misses through it), the right side shrinks toward and L2 could actually hurt (you'd pay for nothing). Worked check: , , need ✅ — L2 helps by a mile.
Active Recall
Recall Cover and answer
- In L2-Q3, why is the L1 miss penalty ns and not ns?
- In L3-Q1, why did halving miss rate beat halving hit time?
- State the exact inequality for "L2 is worth adding" (L5-Q3).
- Why is memory-stall time and not the full AMAT (L4-Q2)?
- What is AMAT when ? When ?
Which term dominates AMAT when misses are rare but is large?
Effective L1 miss penalty in a two-level cache
Condition for L2 to reduce AMAT
Memory-stall time per access
AMAT when
AMAT when
Connections
- Cache Miss Rate & Miss Types (3 Cs)
- Miss Penalty & Main Memory Latency
- Multi-level Cache Hierarchy
- Cache Associativity & Hit Time tradeoff
- CPU Performance Equation
- Locality of Reference