A translation lookaside buffer (TLB) is a small, fast hardware cache of recent address translations that the memory management unit consults before walking the page tables. In memory management, it is the component that makes virtual memory practical, because without it every memory access would require several additional reads of page table entries.
The TLB sits inside the processor core, close to the load and store pipeline. Operating systems do not normally fill it directly, but they control its contents indirectly by changing page tables, switching address spaces and issuing explicit invalidation instructions.
How a TLB lookup works
Every load, store and instruction fetch uses a virtual address that must be translated into a physical address. The processor splits the virtual address into a virtual page number and an offset, then searches the TLB for an entry that matches the page number.
- The core presents the virtual page number to the TLB, usually in parallel with the first-level cache lookup.
- On a TLB hit, the entry supplies the physical frame number and permission bits within about one cycle.
- On a TLB miss, a hardware page walker, or on some architectures the operating system, reads the page table levels in memory.
- If the walk finds a valid entry, the translation is inserted into the TLB and the access is retried.
- If no valid entry exists, the processor raises a page fault and the kernel takes over.
Each entry stores more than the frame number. It also holds permission bits (read, write, execute, user or supervisor), a valid bit, and often an address space identifier that tells which process the translation belongs to. Permission checks therefore happen on every access at no extra cost.
TLB organization and key parameters
Modern processors use a multilevel TLB hierarchy, much like the data cache hierarchy. Small first-level TLBs are extremely fast, while a larger second-level TLB catches most of their misses. Exact sizes vary by microarchitecture, so the values below are typical orders of magnitude rather than fixed specifications.
| Parameter | Typical range | What it affects |
|---|---|---|
| L1 data TLB entries | 48 to 96 for 4 KiB pages | Hit rate of hot data accesses |
| L1 instruction TLB entries | 64 to 256 | Instruction fetch performance |
| Second-level TLB entries | 1,024 to 4,096 or more | Miss rate for large working sets |
| Hit latency | About 1 cycle for L1, several cycles for L2 | Load-to-use delay |
| Miss penalty | Tens to hundreds of cycles | Cost of each page walk |
| Associativity | Fully associative to 12-way | Conflict misses |
The most useful derived metric is TLB reach: the number of entries multiplied by the page size. A 1,536-entry TLB with 4 KiB pages covers only about 6 MiB of memory, which is far smaller than the working set of a database or a virtual machine host.
Page size and TLB reach
Larger pages are the main tool operating systems use to extend TLB reach without adding hardware entries. One entry for a large page replaces hundreds of entries for small pages, so the same TLB covers much more memory.
| Page size | Reach of 1,000 entries | Typical use |
|---|---|---|
| 4 KiB | About 4 MiB | Default for most allocations |
| 2 MiB | About 2 GiB | Databases, JVM heaps, transparent huge pages |
| 1 GiB | About 1 TiB | Hypervisors, very large in-memory datasets |
The trade-off is internal fragmentation and allocation difficulty. A 2 MiB page must be physically contiguous and aligned, and memory fragmentation can make such regions scarce on long-running systems. Huge pages also make copy-on-write and swapping coarser, so the kernel must balance TLB efficiency against memory flexibility.
TLB management by the operating system
Because the TLB caches page table contents, the operating system must keep it consistent whenever translations change. A stale entry could let a process access memory it no longer owns, which makes TLB invalidation a correctness and security requirement, not merely an optimization.
| Event | Required action | Performance impact |
|---|---|---|
| Context switch | Flush user entries or switch address space identifier | Lost warm entries after the switch |
| Unmapping a page | Invalidate the single entry | Small, local cost |
| Permission change | Invalidate affected entries | Required for copy-on-write correctness |
| Change on a multicore system | TLB shootdown via inter-processor interrupts | Can cost microseconds per event |
| Kernel page table isolation | Separate kernel and user tables | Extra switching overhead without identifiers |
Address space identifiers (called PCID on x86-64 and ASID on Arm) let entries from several processes coexist, so a context switch no longer requires a full flush. A TLB shootdown is the most expensive case: the initiating core must interrupt every other core that might cache the translation and wait for acknowledgment.
TLB compared with related memory components
The TLB is easy to confuse with other parts of the memory system. It caches translations, not data, and it is distinct from the structures that define those translations.
| Component | What it stores | Location |
|---|---|---|
| TLB | Recent virtual-to-physical translations | Inside the processor core |
| Page table | Complete translation map of an address space | Main memory |
| Memory management unit | Translation logic including the TLB and page walker | Processor |
| CPU data cache | Copies of memory contents | Processor, by cache level |
| Page cache | File data held in RAM by the kernel | Main memory, managed in software |
Performance problems and common mistakes
TLB effects are often invisible in ordinary profiling because they appear as general memory stalls. Hardware performance counters for data TLB misses and page walk cycles reveal them directly.
- Random access over huge arrays produces a TLB miss on almost every access; huge pages or better data locality reduce it.
- Frequent mapping changes in allocators trigger shootdowns that hurt multithreaded throughput.
- Assuming a flush is free is a mistake: losing warm entries after a context switch can cost more than the switch itself.
- Disabling address space identifiers to work around firmware issues removes a major mitigation for page table isolation costs.
- Virtual machines double the walk, because nested paging can require up to about two dozen memory references per miss.
The idea in brief
Programs use made-up addresses, and the computer has to look up where each one really lives in memory. That lookup uses a large directory stored in memory, which is slow to consult every time.
The translation lookaside buffer is like a sticky note of recently used directory entries. If the answer is on the note, the processor gets it instantly. Most lookups hit the note, which is why virtual memory feels fast.
A practical scenario
A database engineer runs an analytics server with 256 GiB of RAM and a 180 GiB in-memory buffer pool on 4 KiB pages. Performance counters show that page walks consume about 15 percent of CPU cycles, because queries touch rows scattered across the whole pool.
The engineer reserves 2 MiB huge pages at boot and configures the database to allocate its buffer pool from them. The number of page table entries needed to map the pool drops by a factor of 512, and the TLB now covers gigabytes instead of megabytes.
After the change, page walk cycles fall to under 3 percent and average query latency improves by roughly a tenth, a measurable gain with no hardware upgrade.