Translation Lookaside Buffer (TLB)
You'll learn how a hardware cache called the TLB dramatically speeds up address translation in virtual memory systems.
The Problem: Slow Address Translation
Every memory access in a system using paging requires translating a virtual address to a physical address by looking up the page table. Since page tables reside in memory, this means each memory access actually requires two memory accesses: one to fetch the page table entry, and one to access the actual data. This doubling of memory traffic would cripple performance.
The Solution: The TLB
The Translation Lookaside Buffer (TLB) is a small, fast hardware cache that stores recent virtual-to-physical address translations. It sits inside the MMU and acts as a "shortcut" for the most frequently used page table entries.
How It Works
When the CPU needs to translate a virtual address:
- TLB Hit: If the translation exists in the TLB, the physical address is retrieved immediately (in nanoseconds)
- TLB Miss: If not found, the MMU must perform a full page table walk in memory (much slower), then cache the result in the TLB for future use
Think of it like speed-dial on your phone: you could look up your friend's number in your contacts each time, or you can save their number in a quick-access list for instant dialing.
Why It Works
The TLB exploits locality of reference: programs tend to access the same pages repeatedly. A small TLB (typically 64-512 entries) can achieve hit rates of 95-99%, meaning most translations complete in a single fast lookup rather than requiring memory access.
Key Takeaway: The TLB is a critical hardware cache that stores recent page table entries, converting the potentially expensive two-memory-access pattern of virtual-to-physical translation into a single fast cache lookup in the common case.