If a TLB lookup takes 10 ns, memory access 100 ns and the hit ratio is 90%, what is the effective access time?
EAT = 0.9 x (10 + 100) + 0.1 x (10 + 100 + 100) = 99 + 21 = 120 ns. A TLB hit needs one memory access; a miss needs two, one for the page table and one for the data.
Explain it simply
A TLB is a small, fast cache of recent page-to-frame translations, like keeping the numbers you call most on speed dial. If the number is on speed dial (hit), you call at once. If not (miss), you search the phone book first (the page table in memory), then call.
- TLB hit: TLB lookup, then one memory access for the data.
- TLB miss: TLB lookup, one memory access to read the page table entry, then one memory access for the data.
Example
Given: TLB = 10 ns, memory = 100 ns, hit ratio = 0.9.
- Hit time = 10 + 100 = 110 ns
- Miss time = 10 + 100 + 100 = 210 ns
EAT = 0.9 x 110 + 0.1 x 210 = 99 + 21 = 120 ns.
Without a TLB, every access would cost 100 + 100 = 200 ns, so the TLB saves 40%.
What if the hit ratio rises to 98%? EAT = 0.98 x 110 + 0.02 x 210 = 107.8 + 4.2 = 112 ns.
This is why programs with good locality run faster: they keep reusing the same pages, which stay in the TLB. Some textbooks ignore the TLB lookup time; if the question says so, use hit = 100 and miss = 200.
What to say in the interview
"On a hit I pay the TLB time plus one memory access; on a miss I pay one extra access for the page table. With 90% hits that is 0.9 x 110 + 0.1 x 210 = 120 ns, against 200 ns with no TLB."
Common mistakes
- Charging only one memory access on a miss.