Generalizing the cost function

  • Replace "accessing the i-th item costs i" with cost f(i) (44:08).

  • f(i) = i recovers plain list update; paging is the choice (45:12):

    f(i) = 0 if i ≤ k, f(i) = 1 otherwise

  • Extra rule in the paging model: when accessing item i with i > k, you must transpose it down to a position ≤ k (46:10).

  • Interpretation: the first k list positions are memory/cache; everything past them is disk, and accessing memory is free (48:27).

The paging problem itself

  • Two levels of storage: k cache lines of fast memory, and an effectively infinite disk split into blocks of one cache line (20:13, 47:00).
  • A hit is free; a miss costs 1 to fetch from disk, after which the page stays free to access (47:43).
  • If memory is full, the fetch forces an eviction — this choice is the entire decision problem (20:41, 48:04).
flowchart TD
    R["request page p"] --> H{"p in cache?"}
    H -- yes --> F["cost 0"]
    H -- no --> C{"cache full?"}
    C -- no --> L["load p, cost 1"]
    C -- yes --> E["choose victim (replacement policy)"] --> L

Cache replacement heuristics and their list-update twins

PolicyRuleList-update analogue
LRUEvict the least recently accessed page (49:06)Exactly move-to-front (49:35)
LFUEvict the least frequently accessed page over all history so far (49:35, 50:05)Not frequency count — a student points out that a forced fetch of a cold page distorts the distribution, and the lecturer agrees (50:05, 50:37)
FIFOEvict the page brought in longest ago (50:54)—
Most-recently-fetchedEvict the page most recently brought in; listed in the Sleator–Tarjan paper, and the lecturer says he doesn't understand why anyone would use it (50:54, 51:42)—

What OPT looks like

  • Farthest-in-the-future eviction is optimal for paging — unimplementable, since it needs the future (1:00:38).
  • Attributed to Belady, IBM Journal of Systems, ~1966 (1:01:09).