Translation Lookaside Buffer (TLB)
You'll learn: How a special hardware cache speeds up virtual-to-physical address translation by remembering recent lookups.
The Speed Problem
We've seen how the Memory Management Unit (MMU) translates virtual addresses to physical addresses using page tables. But here's the catch: every memory access requires a translation, and consulting the page table (stored in main memory) means an extra memory read before fetching your actual data. That would double memory access time!
What is a TLB?
The Translation Lookaside Buffer (TLB) is a small, ultra-fast hardware cache inside the CPU that stores recently-used address translations. Think of it as the MMU's "speed dial" for addresses it's seen before.
When the CPU needs to translate a virtual address:
- TLB Hit: If the translation is in the TLB, the physical address is retrieved instantly (nanoseconds)
- TLB Miss: If not found, the MMU must walk the page table in memory (slower), then caches the result in the TLB for next time
Real-World Analogy
Imagine looking up phone numbers in a massive directory (page table). After finding a number, you write it on a sticky note on your desk (TLB). Next time you call that person, you check your sticky notes first instead of thumbing through the entire directory again.
Why It Matters
Programs exhibit locality of reference—they tend to access the same memory regions repeatedly. The TLB exploits this: typical TLB hit rates exceed 95%, meaning most translations happen at CPU speed rather than memory speed. Without TLBs, virtual memory would be impractically slow.
Key Takeaway: The TLB is a hardware cache that dramatically speeds up address translation by storing recent virtual-to-physical mappings, preventing the MMU from constantly accessing the page table in memory.