Skip to content
We areTOP 1%

What is a TLB, and how does it affect effective memory access time?

HardConceptVirtual Memory & Paging
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

The Translation Lookaside Buffer (TLB) is a small, very fast cache inside the MMU that stores recent page-number → frame-number translations. Without it, every memory access would need an extra RAM access just to read the page table.

  • TLB hit: the frame number is found in the TLB, so only one RAM access, for the data, is needed. TLB miss: the page table is read from RAM first, then the data, and the translation is added to the TLB.
  • Hit ratios are often above 99%, thanks to locality of reference.
  • On a context switch, the TLB must be flushed unless its entries are tagged with address-space identifiers (ASIDs).
  • For a single-level page table, with the TLB searched first: EAT = h × (t + m) + (1 − h) × (t + 2m), where h is the hit ratio, t the TLB lookup time and m the memory access time.

Example: t = 10 ns and m = 100 ns. A hit costs 10 + 100 = 110 ns, and a miss costs 10 + 200 = 210 ns.

With h = 0.8: EAT = 0.8 × 110 + 0.2 × 210 = 88 + 42 = 130 ns.

With h = 0.98: EAT = 0.98 × 110 + 0.02 × 210 = 107.8 + 4.2 = 112 ns.

Without any TLB, every access would cost 2 × 100 = 200 ns.

More in Virtual Memory & Paging

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account