ECE344 Fall 2026 (Sec 1) Lec 27 - Advanced Page Replacement
Overview
Jon Eyolfson explains how the clock algorithm uses the MMU’s one-bit access flag to approximate LRU cheaply, then examines why scans can still displace frequently reused pages. He compares scan-resistant active/inactive lists, IBM’s adaptive replacement cache (ARC), 2Q, and Linux’s multi-generational LRU, highlighting how each distinguishes recent reuse from one-time access.
Key takeaways
- Clock approximates LRU with one reference bit per frame: the MMU sets the bit on access, and eviction clears set bits until it finds a zero-bit victim.
- A page scan can defeat both LRU and basic clock by making one-time reads look recent, causing frequently reused working-set pages to be evicted.
- An active/inactive policy makes pages earn protection through a second reference, keeping one-time scan pages eligible for eviction.
- ARC uses ghost lists of evicted page identifiers to adapt how much cache space goes to pages seen once versus pages seen repeatedly.
- Linux multi-generational LRU tracks page age in four generations and generally evicts from the oldest generation.
Chapters
- Exact LRU approaches optimal replacement but is expensive because it requires tracking access order or timestamps.
- The MMU sets a page’s access bit to 1 on use, giving the operating system a low-cost signal for approximating recency.
- The clock algorithm builds on this hardware-maintained bit to choose eviction candidates.
- Clock arranges page frames in a circular list, with a hand pointing to the next candidate and one reference bit per page.
- On eviction, a page with bit 0 is replaced; a page with bit 1 has its bit cleared and gets another chance.
- A newly loaded page gets reference bit 1, and the hand advances so the new page is not immediately reconsidered.
- Ordinary page accesses only set the accessed page’s bit, so the replacement scan’s work is deferred until eviction.
- With four frames, the first four distinct page accesses fill memory; each loaded page starts with its reference bit set.
- When every bit is 1, the simulation can clear all bits at once instead of showing the hand make a full lap.
- For one short access string, clock and LRU each incur six faults, while optimal replacement incurs five.
- In a larger example, clock happens to match FIFO’s result, illustrating that its performance depends on the access pattern.
- Clock is also called second chance because a set reference bit lets a page survive one pass of the hand.
- The MMU sets the access bit on a hit, while the operating system clears bits and scans for victims during replacement.
- A sequential scan can make every newly read page appear recently used, pushing out pages that form a repeatedly used working set.
- Disabling swap can avoid performance slowdowns on systems with sufficient RAM, though an out-of-memory killer may then be needed.
- A scan over pages 4, 5, and 6 can displace a working set of pages 1, 2, and 3 under plain LRU.
- The active/inactive policy places new pages on the inactive list and promotes a page to active after it is referenced again.
- Victims come from the inactive list, so one-time scan pages are more likely to leave before pages with repeated use.
- Linux tracks file-backed pages separately from anonymous pages, which may require swap space when evicted.
- IBM’s Adaptive Replacement Cache keeps separate LRU lists for pages seen once and pages seen more than once.
- A target value P controls how much cache space goes to the once-used list, and ARC adjusts P as the workload changes.
- Ghost lists B1 and B2 retain identifiers of evicted pages, not cached page contents, so a later fault can reveal which list needs more space.
- A page fault matching a B1 entry indicates the once-used allocation was too small; a B2 match indicates the repeatedly used allocation needs more.
- The 2Q policy combines a FIFO queue for pages seen once with an LRU list for pages referenced again soon after eviction.
- PostgreSQL adopted ARC in 2005 and later changed policies amid patent concerns; PostgreSQL 8.1 used clock instead.
- ZFS uses an ARC-derived cache, while Linux did not adopt IBM’s ARC algorithm because of its patent status.
- The underlying design question is how to divide limited frames between one-time accesses and pages with demonstrated reuse.
- Linux’s multi-generational LRU, developed with Google’s involvement and merged in Linux 6.1, organizes pages into four age generations.
- When memory pressure triggers aging, pages whose access bits are set move into the youngest generation and their bits are cleared.
- Eviction takes pages from the oldest generation; distributions such as Fedora may enable the feature.
- The lecture’s main comparison is that clock cheaply approximates LRU, while scan-resistant policies use repeated references or page age to protect useful working sets.
Transcript excerpt
1:41 I >> All right, so we are back to it with
5:39 advanced page replacement. Whoa. So recall LRU got close to optimal, but it is too expensive to implement. So right now, if we were like seeing what happens with our MMU, we can take advantage of what already happened. So the hardware already does a little bit for every access. Not quite a time stamp, but there is that a bit or that access bit. And the MMU is going to always set that from whatever value it is to a one whenever that page is accessed. And that comes for free. So, how could we use this one bit to approximate our LRU? So, some of you already said that said that, hey, Wabo, if we keep track of something was
6:26 recently used, hey, we already have that from our MMU. So, all Cisco. So, the clock algorithm uses one bit for page. What the clock algorithm does is have pages in a circular list similarly to some of your ideas during the break, and each has a reference bit, which just indicates whether or not it has been referenced soon-ish. And the hand points to the next page to check. Every access to a page is going to set its reference bit to one if it's not already set. And we're just going to go around that circle looking for victims. So, this is how the algorithm works is to replace a page. We check the page
7:14 under the hand. It's basically just an iterator. Look at the reference bit. If that bit is zero, it means it hasn't been used recently. So, evict it, replace that page with the current page we're trying to do, and we move the hand before we carry on with our normal
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Jon Eyolfson.