core24 min studyLesson 118 in Engineering

TLBs and the working set of translations

Separate address translation misses from data misses and page faults, then reason about page-size tradeoffs.

On this page

What you’ll understand

  • Distinguish TLB misses, page-table walks, and page faults.
  • Calculate nominal translation reach with explicit page geometry.
  • Explain why larger pages and fewer invalidations involve tradeoffs.

Before a virtual address can identify the intended physical storage, the processor needs translation and access-permission information. A translation lookaside buffer caches that information so most accesses avoid a full page-table walk. Its working set is measured in translations rather than application elements. A program can therefore have warm data caches yet pay translation costs, or miss in a TLB while its page remains resident and valid. Keep those events distinct when interpreting a memory slowdown.

A missing translation is not a missing page

A TLB hit supplies a cached translation and relevant permission information for the access. A miss can trigger a hardware page-table walk, or an architecture-specific software mechanism, to recover the mapping. Page-table entries themselves are stored in memory and may benefit from caches and dedicated walk caches. The translation machinery therefore has its own access pattern and overlap limits. Counting one miss as one fixed-cost main-memory access is usually too crude for a real performance model.

A page fault is a different condition requiring operating-system handling, such as an absent mapping, a protection violation, or deferred population of a valid region. A resident, permitted page may require a TLB refill without any page fault. Conversely, a fault may involve allocation, copy-on-write, or I/O and cost far more than an ordinary walk. Name the event precisely and inspect the architecture and operating-system definitions before converting a counter into a latency estimate.

Rnominal=EPR_{\rm nominal}=E P
A simplified TLB with E usable entries, each mapping a P-byte page of one selected size, has nominal reach EP bytes. This ignores associativity conflicts, multiple TLB levels, separate page-size structures, reserved entries, and competing address spaces.↔ Scroll wide equations horizontally.

Access order matters to translations too

Touching a few bytes on many pages can exhaust translation entries while consuming little useful payload. Repeatedly processing all nearby elements within a page may amortize translation work, provided the access order is legal. Just as cache associativity can matter before byte capacity is exhausted, TLB set conflicts may matter before nominal reach is exhausted. A reach calculation is a useful scale estimate; it does not prove that every mapping within that byte span stays cached.

Larger pages can increase bytes covered per translation, but their allocation and management costs differ. They can increase internal fragmentation, complicate placement, or require expensive promotion and compaction. Support and available TLB capacity may differ by page size, so multiplying an unchanged entry count by a larger page size is only a hypothetical comparison unless hardware documentation justifies it. Measure the full workload and memory pressure rather than treating huge pages as a universal optimization.

Npages=⌈o+DP⌉N_{\rm pages}=\left\lceil\frac{o+D}{P}\right\rceil
A nonempty contiguous D-byte range beginning o bytes into a P-byte page intersects this many pages, with 0≤o<P. The count is geometric; it does not predict resident translations, page faults, or how many walks occur during repeated access.↔ Scroll wide equations horizontally.

Changing a mapping requires coordination

When software changes a mapping or permission, cached translations must cease supplying an obsolete interpretation where required by the architecture. Operating systems use invalidation mechanisms and coordinate with processors that may retain relevant entries. This can create cross-core work, often called a TLB shootdown. Precise invalidation can preserve unrelated translations, while broader invalidation may be cheaper to issue but cause extra refills. The tradeoff depends on the architecture, affected range, and active processors.

The function lab shows y=ax² and nothing about translation. Interpret positive x as a normalized side length of a dense square allocation and positive a as bytes per entry, then predict its growth. Use that payload to motivate a separate page-count calculation under a declared page size. The sliders cannot select page size, TLB entries, or invalidation scope. This separation matters: a smooth payload curve does not imply a smooth transition in discrete page counts or measured walk costs.

Nominal reach versus actual capacity

Compare two hypothetical 64-entry translation structures: one maps only 4 KiB pages and the other only 2 MiB pages. A page-aligned dense allocation contains 16 MiB. Assume all its pages are populated.

  1. For 4 KiB pages, nominal reach is 64×4 KiB=256 KiB. The allocation spans 16 MiB/4 KiB=4,096 pages, far more than 64 translations.

  2. For 2 MiB pages, the hypothetical reach is 64×2 MiB=128 MiB, and the allocation spans eight pages. Eight mappings fit the declared entry budget, although conflicts and competing translations remain possible.

  3. Do not infer 4,096 page faults from the smaller-page count: the prompt says pages are populated. Also do not assume a real processor supplies 64 large-page entries just because it supplies 64 small-page entries.

The result

Page size changes the translation count dramatically under explicit geometry. Translation residency and operating-system faults still require separate evidence.

Explore the model

Interactive lab

Interactive lab · function

Payload growth before translation counting

Use positive a and x in y=ax² to inspect square-allocation payload growth. Calculate page counts separately for a stated page size. The lab does not model TLB entries, page-table walks, faults, or invalidations.

Payload growth before translation countingThis lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Current readings: y at chosen x: 0.608; Tangent slope · 2ax: 1.35; Signed area · ax³/3: 0.182. All parameters are adjustable with the labeled controls below.−2.4−1.201.22.4−9−4.504.59xy(x, ax²)
y = ax²TangentSigned integral
y at chosen x
0.608
Tangent slope · 2ax
1.35
Signed area · ax³/3
0.182
t = 0 s

This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forByte footprint and translation footprint are related through explicit page geometry, not through an automatic latency rule.

Check your understanding

A load misses in the TLB but its mapping is valid, permitted, and backed by a resident page. Which statement is correct?

Try it yourself

A 12 KiB nonempty region starts 2 KiB into a 4 KiB page. Count intersected pages and explain why this alone cannot determine its TLB miss count over ten traversals.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Include the initial offset, then distinguish unique pages from repeated accesses.

Compare with the solution

The count is ceil((2+12)/4)=4 pages. Ten traversals do not necessarily cause forty TLB misses: translations may remain cached between accesses, conflict with other mappings, or be invalidated. Actual misses depend on access order, TLB organization, intervening activity, and invalidations. The page count supplies a footprint, not an execution trace.

Take it with you

  • TLB misses, data-cache misses, and page faults describe different mechanisms.
  • Nominal reach depends on entry count and supported page size.
  • Larger pages and invalidation scope trade refill work against management and memory costs.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.