The randomized marking algorithm for paging (2 H_k-competitiveness) #
This file formalizes the randomized marking algorithm for demand paging (Paging.problem α k,
0 < k) and proves Theorem 1 of Fiat, Karp, Luby, McGeoch, Sleator, and Young, Competitive
Paging Algorithms, Section 3 ("The marking algorithm"),
Theorem 1: randomized marking is 2 H_k-competitive against
an oblivious adversary, with additive constant 0.
Algorithm #
Controller memory (MarkMem α) stores the resident cache : Finset α together with the subset of
currently marked : Finset α pages, initialized to ⟨s₀, s₀⟩ so that all initially cached pages
start marked (as in [FKL+91], Section 3). On request p:
- Cache hit (
p ∈ cache):pis marked andcacheis unchanged (stepCost = 0). - Cache miss into a non-full cache (
p ∉ cache,cache.card < k):pis inserted and marked without eviction (stepCost = 1), extending the source's full initial cache (|s₀| = k) to every admissible initial cache|s₀| ≤ k. - Cache miss into a full cache (
p ∉ cache,cache.card = k): if every cached page is marked (cache ⊆ marked), all marks are cleared first; then a uniformly chosen unmarked cached page is evicted (Cslib.Probability.PMF.uniformOfFinset), andpis inserted and marked (stepCost = 1).
Because marking tosses a fresh uniform coin at unboundedly many evictions, it is packaged as an
Online.BehavioralStrategy (problem α k) (markingStrategy).
Proof architecture #
- Exact stale-subset distribution law (
MarkTracker,markLaw,expectedCost_markingStrategy_eq): At every step, the controller memory distribution equalsmarkLaw tr, wheretr.markedis the deterministic set of marked pages in the current phase,tr.staleis the deterministic set of unmarked pages from the previous phase not yet requested in the current phase, and the cache istr.marked ∪ UforUdrawn uniformly fromtr.stale.powersetCard tr.staleCached. This yields an exact computable rational recursiontrackerExpectedCostforexpectedCost. - Harmonic potential (
trackerPotential,trackerExpectedCost_le_harmonic_mul_cleanCount): Withc = tr.stale.card - tr.staleCachedclean misses so far in the current phase, the potentialc * (harmonic tr.stale.card - harmonic c)absorbs every stale request'sc / |stale|fault probability with zero residual charge and charges at mostharmonic kper clean request, givingE[MARK] ≤ H_k · #cleanacross both completed and incomplete phases. - Two-window offline lower bound (
cleanCount_le_two_mul_scheduleCost): Direct backward induction over arbitrary (not necessarily lazy) valid offline schedules(problem α k).ValidSchedule s₀ reqs offStatestracks the fault setBsince the start of the current phase, proving#clean ≤ 2 · OPTwithout reducing to lazy schedules.
Main definitions #
Cslib.DataStructure.Paging.MarkMem,Cslib.DataStructure.Paging.ValidMarkMem: controller memory and invariant of randomized marking.Cslib.DataStructure.Paging.markingStep,Cslib.DataStructure.Paging.markingStrategy: the randomized marking behavioural online strategy forPaging.problem α k.Cslib.DataStructure.Paging.MarkTracker,Cslib.DataStructure.Paging.markLaw,Cslib.DataStructure.Paging.trackerExpectedCost,Cslib.DataStructure.Paging.cleanCount: deterministic phase bookkeeping, stale-subset cache law, exact rational expected cost recursion, and clean-request count.
Main results #
markLaw_bind_markingStep,expectedCost_markingStrategy_eq: exact distribution invariant and rational expected-cost formula.trackerExpectedCost_le_harmonic_mul_cleanCount: harmonic potential boundE[MARK] ≤ H_k · #clean.cleanCount_le_two_mul_scheduleCost: FKLMSY two-window bound#clean ≤ 2 · OPTagainst arbitrary valid offline schedules.markingStrategy_expectedCost_le,markingStrategy_isCompetitive,markingStrategy_expectedCost_toReal_le: randomized marking is(2 * H_k, 0)-competitive inℝ≥0∞andℝ.
References #
Controller memory and deterministic tracker types #
Deterministic phase bookkeeping for the distribution invariant of markingStrategy:
marked is the set of pages marked in the current phase, stale is the set of unmarked pages from
the previous phase not yet requested in the current phase, and staleCached is the number of stale
pages currently retained in the cache.
Initial tracker state corresponding to markingStrategy.init s₀: all pages of s₀ are marked
and no stale pages exist yet.
Structural invariant of MarkTracker for cache capacity k.
Harmonic phase potential c * (H_{|stale|} - H_c) where c = |stale| - staleCached is the
number of clean misses incurred so far in the current phase.
Behavioural marking strategy #
One-step randomized transition of the marking algorithm for cache capacity k on page p.
The randomized marking online strategy ([FKL+91], Section 3)
for Paging.problem α k (0 < k). Marks are initialized to the initial cache s₀; hits mark the
requested page; misses into a non-full cache insert and mark without eviction; misses into a full
cache unmark all pages when every cached page is marked and evict uniformly among unmarked cached
pages.
Single-step expected cost of markingStrategy depends only on whether p is currently cached:
0 on a hit and 1 on a miss.
Expected cost of markingStrategy on any valid initial cache and request sequence reqs is at
most reqs.length, hence finite (≠ ⊤).
Exact stale-subset distribution law #
Deterministic transition of MarkTracker on page request p.
Run stepTracker across a request list.
Whether request p is clean relative to tracker tr (unmarked, and either starting a new
phase/warmup slot when staleCached = 0 or outside tr.stale).
Total number of clean requests encountered from tracker tr along reqs.
Exact rational single-step expected fault cost from tracker tr on request p.
Exact rational expected fault cost from tracker tr across reqs.
stepTracker preserves ValidTracker when 0 < k.
Exact memory distribution associated with tracker tr: the cache is tr.marked ∪ U for a
uniform tr.staleCached-subset U of tr.stale, and the marked set is tr.marked.
Whenever staleCached = 0, markLaw collapses to the point mass at ⟨marked, marked⟩.
Exact distribution invariant of randomized marking. Stepping markLaw tr by markingStep
on any request p produces markLaw (stepTracker k tr p).
Single-step expected fault cost of markingStrategy under markLaw tr equals
ENNReal.ofReal (stepTrackerCost tr p).
Expected continuation cost of markingStrategy from markLaw tr equals
ENNReal.ofReal (trackerExpectedCost k tr reqs).
Exact rational expected cost of randomized marking. From any valid initial cache s₀,
(markingStrategy k hk).expectedCost s₀ reqs equals
ENNReal.ofReal (trackerExpectedCost k (initTracker s₀) reqs).
Harmonic potential bound (E[MARK] ≤ H_k · #clean) #
Single-step harmonic potential inequality: each stale request is paid exactly out of
trackerPotential, and each clean request increases cost + potential by at most harmonic k.
Telescoped harmonic potential inequality over any request list reqs.
Harmonic phase bound (E[MARK] ≤ H_k · #clean). From any valid initial cache s₀, the
rational expected cost of markingStrategy is at most harmonic k times the number of clean
requests.
FKLMSY two-window offline lower bound (#clean ≤ 2 · OPT) #
FKLMSY two-window offline lower bound (#clean ≤ 2 · OPT). Against any valid offline
schedule from s₀, the number of clean requests encountered from initTracker s₀ is at most
twice the offline fault cost.
Main competitiveness theorems (FKLMSY Theorem 1) #
Rational expected cost of markingStrategy is at most 2 * harmonic k * scheduleCost.
FKLMSY Theorem 1 (ℝ≥0∞ cost bound) [FKL+91]: for every
admissible initial cache s₀ (|s₀| ≤ k), request sequence reqs, and valid offline schedule
offStates from s₀, the expected cost of markingStrategy is at most 2 H_k times the offline
schedule's cost.
FKLMSY Theorem 1 (BehavioralStrategy.IsCompetitive)
[FKL+91]: the randomized marking strategy is (2 * H_k, 0)-competitive
for demand paging against an oblivious adversary.
Real-valued expectation form of FKLMSY Theorem 1.