600 likes | 848 Views
Online Algorithms and Competitive Analysis. Paging Algorithms. Data brought from slower memory into cache. RAM. CPU. Paging Algorithms. Data brought from slow memory into small fast memory (cache) of size k Sequence of requests: equal size pages Hit: page in cache,
E N D
Paging Algorithms • Data brought from slower memory into cache RAM CPU
Paging Algorithms • Data brought from slow memory into small fast memory (cache) of size k • Sequence of requests: equal size pages • Hit: page in cache, • Fault: page not in cache
Minimizing Paging Faults • On a fault evict a page from cache • Paging algorithm ≡ Eviction policy • Goal: minimize the number of page faults
Worst case • In the worst case page, the number of page faults on n requests is n. E.g. cache of size 4, request sequence p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12
Difficult sequences Cache of size 4, request sequence p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 Sequence is difficult, for one it never repeats pages so it is impossible to have a page hit
Compare to optimal p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 … is hard for everyone (i.e. 13 faults) p1 p2 p3 p4 p5 p1 p2 p3 p4 p5 p1 p2 p3 p4 … 8 faults Optimal algorithm knows the future
Offline optimum Optimal algorithm knows the future, i.e. offline OPT. Compare online paging strategy to offline paging strategy
Competitive Ratio Defined as : cost of online algorithm on I cost of offline optimum on I sup I
Paging • One of the earliest problems to be studied under the online model • Competitive ratio defined by Sleator and Tarjan
Competitive Ratio • First appeared in the 1960’s in search context, e.g. • On the linear search problem (Beck, 1964) • More on the linear search problem (1965) • Yet more on the linear search problem (1970) • The return of the linear search problem (1972) • Son of the linear search problem (Beck & Beck 1984) • The linear search problem rides again (1986) • The revenge of the linear search problem (1992) • Shmuel Gal • Search Games, Academic Press, 1980 • The Theory of Search Games and Rendezvous (with Steve Alpern), Kluwer Academic Press, 2002
Paging Algorithms • Least-Recently-Used (LRU) • First-In-First-Out (FIFO) • Flush-When-Full (FWF) Classes of Paging algorithms • Lazy Algorithms: LRU and FIFO • Marking Algorithms: LRU and FWF
Paging • Competitive analysis not always satisfactory, e.g. LRU “as good as” FWF • Real life inputs well understood and characterized (temporal + spatial locality) Goal: derive from first principles a new measure that better reflects observations in practice
Theory • Commonly studied under competitive ratio framework • Worst case analysis • Marking algorithms optimal • In practice LRU is best • LFD is offline optimal • Competitive ratio is k • User is malicious adversary • No benefit from lookahead • Systems • Commonly studied using fault rate measure • Typical case analysis • LRU and friends is best • LRU is impractical • Huh? • Competitive ratio is 2 or 3 • User is your friend • Lookahead helps
Fix the Theory-Practice disconnect • Make both columns match How? • Fix reality or • Fix the model A more realistic theoretical model is likely to lead to practical insights
Previous work • Disconnect has been noted before. • Intense study of alternatives, viz. • Borodin and Ben David • Karlin et al. • Koutsoupias and Papadimitriou • Denning • Young • Albers et al. • Boyar et al. • Sleator and Tarjan + many others
Theory: competitive ratio of paging algorithms • k for LRU, FIFO, and FWF • Thus LRU, FIFO, and FWF equally good • Lookahead does not help Practice: • LRU never encounters sequences with competitive ratio bigger than 4 • LRU better than FIFO and much better than FWF • Lookahead helps
Previous work • Partial separation : • Access graph model. Borodin, Raghavan, Irani, Schieber [STOC ‘91] • Diffuse adversary. Koutsopias and Papadimitrou [FOCS ‘94] • Diffuse adversary. Young [SODA ‘98] • Accommodating ratio. Boyar, Larsen, Nielsen [WADS ‘99] • Relative worst order ratio. Boyar, Favrholdt, and Larsen [SODA ‘05]
Previous work • Concave Analysis. Albers, Favrholdt, Gielet [STOC ‘02] LRU ≠ certain marking algorithms • Adequate Analysis. Pangiotou, Souza [STOC 06] + many others. See survey L-O, Dorrigiv [SIGACT News ’05] None provide full separation between LRU and FIFO and/or FWF
Online motion planning • Commonly studied under competitive ratio framework • Worst case analysis • Continuous curved motions • Perfect scans • Flawless detection • No error in motion • Architects are your enemy • Robotics • Commonly studied using distance & scan cost • Typical case analysis • Piecewise linear • Scanning error • High detection error • Forward & rotational lag • Architects are your friend
“Architects are your friend” Most of the time, anyhow.
Alternatives • Turn ratio • Performance Ratio • Search Ratio • Home Ratio • Travel Cost • Average Ratio • Effective Ratio • Smooth Analysis • Concave Analysis • Bijective Analysis • Others
Performance Ratio Defined as : maxp { length of search from s to p } maxq { length of path from s to q } • general idea: focus on distant targets searches, those should be efficient • allows high inefficiency for target’s near-by
Search Ratio Defined as : length of search from s to target p shortest off-line search fromsto p sup p • finer, fairer measure than competitive ratio • many on-line “unsearchable” scenarios suddenly practicable, e.g. trees
Search Ratio Example: Searching for a node at depth h in a complete binary tree with unit length edges Competitive ratio = O(2h / h) Search ratio = O(1)
Home Ratio Defined as : length of search from s to target p shortest path from s to p sup p • where the position of p is known • e.g. target has radioed for help, position known, shape of search area unknown
Home Ratio • Surprisingly, in some cases is as large as competitive ratio, e.g. street polygons • [L-O, Schuierer, 1996]
Travel Cost Defined as : sup { length of search from s to target p } p • unnormalized • similar to standard algorithmic analysis
Average Ratio Defined as : length of search from s to target p shortest path from s to p avg sup P p • Searching on the real line is 4.59 competitive on the average • Doubling is 5.27 competitive
Effective Ratio • Defined as : • Ψ ratio + F(cost of computing solution) • where Ψє { Competitive, Performance, Turn, Search, Home, Average, etc.} • Function F reflects the difference in computational and navigational costs • Sensible adjustments n, n2, i.e. • F(solt’n) = time / n2
Other considerations • Robustness • navigational errors • detection errors (revisit area) • Known probability densities of target location • Time sensitive considerations
Example • Rescue in high seas (man overboard) • High detection error • Known probability density from ocean currents data • Time sensitive (person must be found within 4 hours in North Atlantic)
Search and Rescue (SAR) • Current coast guard strategy • scan high probability area • when done . . . scan again • if several vessels available, rescan
Bijective Analysis cost Σn = {σ1,σ2,…,σ10}: the set of all possible input sequences of length n A(σ) 5 7 3 9 7 5 3 7 5 7 B(σ) 6 7 4 3 10 7 6 6 8 10
Bijective Analysis cost A ≤ B B ≤ A A < B A(σ) 5 7 3 9 7 5 3 7 5 7 B(σ) 6 7 4 3 10 7 6 6 8 10
Bijective Analysis Competitive ratio of A: 9 Competitive ratio of B: 4 A(σ) 5 7 3 9 7 5 3 7 5 7 OPT(σ) 3 2 4 1 3 4 2 5 2 3 B(σ) 6 7 4 3 10 7 6 6 8 10
Σ3 Σ2 Σ* Σ1 Input sequences Strict separation is complex Theorem If the performance measure does not distinguish between sequences of the same length, then no such separation exists
Proof We prove strong equivalence of all lazy marking algorithms. I.e. given two marking algorithms A1and A2, there is a one-to-one correspondence b() between inputs such that the performance characteristics of A1(I) are identical to A2(b(I)).
Proof A σ1 σ2 σ3 σ1 σ4 σ4 σ2 B σ1 σ2 σ3 σ1 σ4 σ4 σ3 map any σ2in A’s sequence to σ3 in B’s sequence
Σ3 Σ2 Σ* Σ1 Input sequences Partitioning Input Space • We need a natural model to partition space. How?
Not all inputs are equal • Adversarial model is wrong model for paging. • The user is not out to get you (contrast this with crypto case). • Compilers go to great lengths to preserve locality of reference. • Designers go to great lengths to create cache friendly (conscious) algorithms.
Updated model Competitive ratio Friendly models: • Fault model, Torng [FOCS ’95] • Concave analysis, Albers et al. [STOC ’02] ALG(I) nice(I) Cooperative
Cooperative ratio • Agreement between user and algorithm about inputs which are: • likely • common • good • important
Cooperative ratio • Badly written code (not cache conscious) • (Rightly) considered the programmer’s fault • Paging strategy not responsible for predicting non-standard paging behaviour • Well written code (cache conscious) • Code can rely on well defined paging behaviour to produce better code (e.g. I/O model, cache oblivious model)
Friendly models • Torng fault model doesn’t fully separate • Albers et al. concave analysis doesn’t either • Bijective + concave analysis separates
Concave analysis f( ): an increasing concave function Definition A request sequence is consistent with f if the number of distinct pages in any window of size n is at most f(n) Intuition Not too many consecutive newly requested pages, i.e. locality of reference Proposed by Albers et al. [AFG05], based on Denning’s working set model
Subpartitioning of Input Space • Subsets compatible with f( ) Σ* Σf3 Σf5 Σf4 Input sequences
Bijective analysis Theorem. LRU ≤f,b A for all paging algorithms A Proof. Construct a continuation of b() such that b(σ∙r)= b(σ)∙r’ and LRU(σ∙r) ≤ A(b(σ∙r)) Corollary. avg(LRU) ≤ avg(A)
Strict separation Theorem For any given paging algorithm A there exists f such that A >f,avg LRU i.e. LRU is unique best [SODA ’07]