24
Algorithmica DOI 10.1007/s00453-013-9800-5 Parameterized Analysis of Paging and List Update Algorithms Reza Dorrigiv · Martin R. Ehmsen · Alejandro López-Ortiz Received: 22 December 2011 / Accepted: 5 June 2013 © Springer Science+Business Media New York 2013 Abstract It is well-established that input sequences for paging and list update have locality of reference. In this paper we analyze the performance of algorithms for these problems in terms of the amount of locality in the input sequence. We define a measure for locality that is based on Denning’s working set model and express the performance of well known algorithms in terms of this parameter. This explicitly introduces parameterized-style analysis to online algorithms. The idea is that rather than normalizing the performance of an online algorithm by an (optimal) offline al- gorithm, we explicitly express the behavior of the algorithm in terms of two more natural parameters: the size of the cache and Denning’s working set measure. This technique creates a performance hierarchy of paging algorithms which better reflects their experimentally observed relative strengths. It also reflects the intuition that a larger cache leads to a better performance. We also apply the parameterized analy- sis framework to list update and show that certain randomized algorithms which are superior to MTF in the classical model are not so in the parameterized case, which matches experimental results. Keywords Online algorithms · Paging · List update · Locality of reference A preliminary version of this paper appeared at WAOA 2009 [25]. R. Dorrigiv (B ) · A. López-Ortiz Cheriton School of Computer Science, University of Waterloo, Waterloo, Canada e-mail: [email protected] A. López-Ortiz e-mail: [email protected] M.R. Ehmsen Department of Mathematics and Computer Science, University of Southern Denmark, Odense, Denmark e-mail: [email protected]

Parameterized Analysis of Paging and List Update Algorithms

Embed Size (px)

Citation preview

AlgorithmicaDOI 10.1007/s00453-013-9800-5

Parameterized Analysis of Paging and List UpdateAlgorithms

Reza Dorrigiv · Martin R. Ehmsen ·Alejandro López-Ortiz

Received: 22 December 2011 / Accepted: 5 June 2013© Springer Science+Business Media New York 2013

Abstract It is well-established that input sequences for paging and list update havelocality of reference. In this paper we analyze the performance of algorithms forthese problems in terms of the amount of locality in the input sequence. We definea measure for locality that is based on Denning’s working set model and expressthe performance of well known algorithms in terms of this parameter. This explicitlyintroduces parameterized-style analysis to online algorithms. The idea is that ratherthan normalizing the performance of an online algorithm by an (optimal) offline al-gorithm, we explicitly express the behavior of the algorithm in terms of two morenatural parameters: the size of the cache and Denning’s working set measure. Thistechnique creates a performance hierarchy of paging algorithms which better reflectstheir experimentally observed relative strengths. It also reflects the intuition that alarger cache leads to a better performance. We also apply the parameterized analy-sis framework to list update and show that certain randomized algorithms which aresuperior to MTF in the classical model are not so in the parameterized case, whichmatches experimental results.

Keywords Online algorithms · Paging · List update · Locality of reference

A preliminary version of this paper appeared at WAOA 2009 [25].

R. Dorrigiv (B) · A. López-OrtizCheriton School of Computer Science, University of Waterloo, Waterloo, Canadae-mail: [email protected]

A. López-Ortize-mail: [email protected]

M.R. EhmsenDepartment of Mathematics and Computer Science, University of Southern Denmark, Odense,Denmarke-mail: [email protected]

Algorithmica

1 Introduction

The competitive ratio, first introduced formally by Sleator and Tarjan [47], has servedas a practical measure for the study and classification of online algorithms. An algo-rithm (assuming a minimization problem) is said to be α-competitive if the cost ofserving any specific request sequence never exceeds α times the cost of an optimaloffline algorithm which knows the entire sequence in advance. The competitive ra-tio is a measure relatively simple to evaluate yet powerful enough to quantify, to alarge extent, the performance of many online algorithms. Notwithstanding the wideapplicability of competitive analysis, it has been observed by numerous researchers(e.g. [11, 15, 18, 39, 51]) that in certain settings the competitive ratio produces resultsthat are too pessimistic and/or fails to separate algorithms with vastly different per-formance in practice. Indeed, the original paper by Sleator and Tarjan discusses thevarious drawbacks of the competitive ratio and uses resource augmentation to addresssome of the observed drawbacks.

A well known example of the shortcomings of competitive analysis is the pag-ing problem [13, 15, 18, 39, 51]. A paging algorithm mediates between a slowerand a faster memory called cache. Assuming a cache of size k, it decides whichk memory pages to keep in the cache without the benefit of knowing in advancethe sequence of upcoming page requests. At each step, if the requested page is incache we have a hit and the algorithm serves the request at no charge. Otherwise,we have a fault and the online algorithm must decide which page to evict, in theevent that the cache is full. The objective is to design online algorithms that min-imize the total number of faults. A demand paging algorithm only evicts pages onfaults [13, p. 33]. It can be proved [13] that any paging algorithm can be madea demand paging algorithm without increasing its cost on any sequence. Thus weonly consider demand paging algorithms in this paper. Three well known paging al-gorithms are LEAST-RECENTLY-USED (LRU), FIRST-IN-FIRST-OUT (FIFO), andFLUSH-WHEN-FULL (FWF) [13]. All these paging algorithms have competitive ra-tio k, which is the best among all deterministic online paging algorithms [13]. Onthe other hand, experimental studies show that in practice LRU has a performanceratio at most four times the optimal offline [51]. Furthermore, it has been consistentlyobserved empirically that LRU (and/or variants thereof) are, in practice, preferablepaging strategies to all other known paging algorithms [13, 46, 51].

Such anomalies have led to the introduction of many alternatives to competitiveanalysis of online algorithms. Next we give an overview of some known alternativeapproaches to competitive analysis. We refer the reader to the survey of Dorrigiv andLópez-Ortiz [26] for a comprehensive and detailed exposition. Loose competitive-ness, which was first proposed by Young in [51] and later refined in [54], considersan offline adversary that is oblivious to the cache size k. The adversary must then pro-duce a sequence that is bad for most values of k rather than for just a specific value.It also ignores those sequences on which the online algorithm incurs a cost less thana certain threshold. This results in a weaker adversary and gives rise to paging algo-rithms of constant performance ratio. The diffuse adversary model by Koutsoupiasand Papadimitriou [39] as well as Young [52, 53] refines the competitive ratio by re-stricting the set of legal request sequences to those derived from a class (family) of

Algorithmica

probability distributions. This restriction follows from the observation that althougha good performance measure could in fact use the actual distribution over the requestsequences, determining the exact distribution of real-life phenomena is a difficult task(e.g., depending on the intended application different distributions might arise). Byrestricting the input to a class Δε of distributions, they are able to show more re-alistic ratios for the performance of well known paging algorithms. The Max/Maxratio, introduced by Borodin and Ben-David [11] compares online algorithms basedon their amortized worst-case behaviour (here the amortization arises by dividing thecost of the algorithm over the length of the request sequence). This measure is basedon directed comparison of online algorithms and reflects the influence of lookahead.However, it does not provide better separation results than competitive analysis ofpaging algorithms. The relative worst order ratio [18–20] combines some of the de-sirable properties of the Max/Max ratio and the random order ratio (the latter mea-sure was introduced in [38] in the context of the online bin packing problem). Aswith the Max/Max ratio, it allows for direct comparison of two online algorithms.Informally, this measure compares the performance of two algorithms on a given re-quest sequence by considering the worst-case ordering (permutation) of the sequence,for each algorithm. It then selects among all possible sequences the one that maxi-mizes this worst-case performance. This measure reflects the influence of lookaheadfor paging and separates the performance of LRU from FWF [19]. Relative intervalanalysis [28] is a more recent technique that directly compares two paging algorithmsby considering their fault rates across the entire range of inputs of a given size. Simi-lar to the relative worst order ratio, relative interval analysis shows the superiority ofLRU to FWF and reflects the influence of lookahead [28]. However, FIFO outper-forms LRU according to this technique.

It is well known that input sequences for paging and several other problems showlocality of reference [2, 3, 10, 13, 14, 49]. By definition, a sequence has locality ifwhen a page is requested it is more likely to be requested in the near future. Thereforeseveral models for paging with locality of reference have been proposed. In the earlydays of computing, Denning recognized the locality of reference principle and mod-eled it using the well-established working set model [22, 23]. He defined the workingset of a process as the set of most recently used pages and addressed thrashing usingthis model. After the introduction of the working set model, the locality principle hasbeen intentionally built into the operating systems, databases, hardware architectures,compilers, and many other areas. Therefore it has amplified the effect. Indeed, [24]states “locality of reference is one of the cornerstones of computer science.”

One apparent reason for the drawbacks of competitive analysis of paging is thatit does not incorporate the concept of locality of reference. Several models incorpo-rating locality have been proposed. In all these models, we restrict the set of legalinput sequences to those with locality of reference, for some definition of locality.Borodin, Raghavan, Irani, and Schieber [14] proposed the access graph model inwhich the universe of possible request sequences is reduced to reflect the fact thatactual sequences depend heavily on the structure of the program being executed. Thespace of request sequences can then be modeled by a graph in which paths betweenvertices correspond to request sequences. Chrobak and Noga showed that the com-petitive ratio of LRU is at least as good as FIFO on every access graph [21]. In a

Algorithmica

generalization of the access graph model, Karlin, Phillips, and Raghavan [37] pro-posed a model in which the space of request sequences has a distribution inducedby a Markov chain process. Given such a Markov chain, the objective is to find anefficient online algorithm that minimizes the expected number of faults per request.They provided an efficient algorithm that achieves bounds within a constant of thebest online algorithm.

Albers et al. [2] introduced a model in which input sequences are classified ac-cording to a measure of locality of reference. The measure is based on Denning’sworking set model [22] and reflects the fact that efficient algorithms must performcompetitively in each class of inputs of similar locality of reference, as opposed tothe worst case alone. Given a concave function f , we say that a request sequenceis consistent with f if the number of distinct pages in any window of size n is atmost f (n), for any n ∈ N. We model locality of reference by restricting the input tothe set of sequences that are consistent with f . Using this model, they showed thatLRU has better performance than FWF and FIFO. In other work, Becchetti [10]refined the diffuse adversary model of Koutsoupias and Papadimitriou described ear-lier by considering only probabilistic distributions in which locality of reference ispresent. Using this model he proves that LRU has constant (expected) competitiveratio on sequences with locality of reference.

Panagiotou and Souza proposed adequate analysis as a model for explaining theefficiency of LRU in practice [42]. In their work, they classified request sequencesaccording to some parameters and proved an upper bound on the competitive ratioof LRU as a function of these parameters. Then they argued that, in practice, typicalrequest sequences have parameters that lead to a constant competitive ratio for LRU.For each request σi to a page p in a given sequence σ , let di be the number ofdistinct pages that have been requested since the last request to p (not including p).Let cj be the number of requests σi for which di = j . We have LRU(σ ) = ∑

j≥k cj .

They proved that OPT(σ ) ≥ 12

∑j≥k

j−k+1j

cj . An (α,β)-adversary can only choosesequences for which

αk−1∑

j=k

cj ≤ β∑

j≥αk

cj .

They proved that the competitive ratio of LRU against (α,β)-adversaries is at most

2(1 + β)

(

1 + 1

α − 1

)

+ ε,

for some 0 ≤ ε ≤ 1. They argued that sequences in practice have large α and small β ,and thus the competitive ratio of LRU on them is small.

Observe that the models of Albers et al. [2] and Panagiotou and Souza [42] canbe considered as applying parameterized analysis to paging algorithms. The maindifference between these models and the model proposed in this paper is that theprevious models do not assign a single numerical value to the amount of locality ina sequence. They just restrict the input to a subset of sequences that satisfy someproperty. On the other hand in our model we consider all sequences, assign a locality

Algorithmica

value to each sequence, and bound the performance of each algorithm in terms of thislocality parameter.1

More recently, Angelopoulos et al. introduced Bijective Analysis and Average Ana-lysis [5] which combined with the locality model of Albers et al. [2], shows thatLRU is the sole optimal paging algorithm on sequences with locality of reference.This resolved an important disparity between theory and practice of online pagingalgorithms, namely the superiority of LRU in practice. In Bijective Analysis andAverage Analysis we directly compare two online algorithms on all sequences ofthe same length. In Bijective Analysis we try to find a bijection on all sequencesof the same length such that the performance of one algorithm on each sequence σ

is at least as good as the performance of the other algorithm on the image of σ . InAverage Analysis we compare the total cost of two algorithms on all sequences ofthe same length. An analogous result for list update and MTF is shown in [6] and theseparation of LRU was strengthened by Angelopoulos and Schweitzer in [7]. Theselast separation results are based on heavy machinery specifically designed to resolvethis singular long-standing question yet leave open the question of how to efficientlycharacterize the full spectrum of performance of the various known paging and listupdate algorithms. In contrast, the new measure we propose in this paper is easier toapply (as we shall see) and creates a performance hierarchy of paging and list updatealgorithms which better reflects their experimentally observed relative strengths. Thisis a strength of the new model in that it is effective, is readily applicable to variouspaging and list update algorithms, and provides meaningful results.

Paging and list update are the best testbeds for developing alternative measures,given our extensive understanding of these problems. We know why competitive anal-ysis fails, what are typical sequences in practice and we can better evaluate whethera new technique indeed overcomes known shortcomings. It is important to note thateven though well studied, most of the alternative models for these problems are onlypartially successful in resolving the issues posed by them and as such these problemsare still challenging case studies against which to test a new model.

In this paper we apply parameterized analysis [29, 32] to paging and list update.Classical complexity theory measures the performance of algorithms as a function ofthe size of the input. Parameterized complexity or parameterized analysis is a refine-ment of this model that measures the performance of algorithms not only in terms ofthe input size, but in addition in terms of a parameter; which is a numerical valuethat may depend on the input in an arbitrary way [32]. We analyze the performanceof well known paging and list update algorithms in terms of a measure of locality ofreference. This measure is related to Denning’s working set model [22], the localityof reference model of [2], the local entropy defined in [36] as a “natural statistic ofa text” for data compression, and the working set theorem in the context of the splaytrees and other self-organizing data structures [16, 34, 35, 48]. In this sense, the mea-sure is natural in that it is similar to others that have been proposed with differentapplications in mind. For paging, this leads to better separation than the competitive

1Angelopoulos also applied parameterized analysis to the online Steiner tree problem in a Dagstuhl tech-nical report [4], however this result postdates the original distribution of our results as a technical report[27] and is simultaneous with our conference paper [25].

Algorithmica

ratio. This means that it can separate the performance of algorithms with the samecompetitive ratio and vastly different behaviour in practice. Furthermore, in contrastto competitive analysis it reflects the intuition that a larger cache leads to better per-formance. We also provide experimental results that justify the applicability of ourmeasure in practice. For list update, we show that this new model produces the finestseparation yet of list update algorithms. We obtain bounds on the parameterized per-formance of several list update algorithms and prove the superiority of MTF. Wealso apply our measures to randomized list update algorithms and show that certainrandomized algorithms which are superior to MTF in the classical model are not soin the parameterized case. Some of the proofs follow the general outline of standardcompetitive analysis proofs (e.g., those in [13]), yet often provide finer separation ofpaging and list update algorithms. In particular, most lower bound proofs in our paperuse the same adversarial instances as the ones used for proving lower bounds on thecompetitive ratio of paging and list update algorithms. The reason for this is that thecorresponding worst-case sequences were carefully designed to precisely reflect theworst-case behaviour of these algorithms. In other words, the lower bound sequencesare properly developed, but competitive analysis falls short of using them to give sat-isfactory results. Our model, on the other hand, can use the same sequences to obtainmore satisfactory results.

2 Parameterized Analysis of Paging Algorithms

Recall that on a fault (with a full cache), LRU evicts the page that is least recentlyrequested, FIFO evicts the page that is first brought to the cache, FWF empties thecache, LAST-IN-FIRST-OUT (LIFO) evicts the page that is most recently broughtto the cache, and LEAST-FREQUENTLY-USED (LFU) evicts the page that has beenrequested the least since entering the cache. LFU and LIFO do not have a constantcompetitive ratio [13]. A paging algorithm is called conservative if it incurs at most k

faults on any consecutive subsequence that contains at most k distinct pages. A pagingalgorithm is said to be a marking algorithm if it never evicts a marked page, wherea page is marked if accessed and if all pages are marked they are all unmarked atonce. LRU and FIFO are conservative algorithms, while LRU and FWF are markingalgorithms [13]. The phase decomposition of a sequence σ is the partitioning of σ

into a set of phases, where each phase starts just after the previous phase and containsthe maximal set of requests to at most k distinct pages. Observe that the definition ofphases is independent of paging algorithms.

As stated before input sequences for paging show locality of reference in practice.We want to express the performance of paging algorithms on a sequence in terms ofthe amount of locality in that sequence. Therefore we need a measure that assigns anumber proportional to the amount of locality in each sequence. None of the previ-ously described models provide a unique numerical value as a measure of locality ofreference of a given sequence. We define a quantitative measure for non-locality ofpaging instances.

Definition 1 Consider a sequence σ and let p be the page requested at the ith step. Ifthis is the first request to p we define dσ [i] as the number of distinct pages that have

Algorithmica

been requested so far. Otherwise, dσ [i] is defined as the number of distinct pages thathave been requested since the last request to p (including p).2 Now we define λ(σ ),the “non-locality” of σ , as λ(σ ) = 1

|σ |∑

1≤i≤|σ | dσ [i]. We denote the non-locality by

λ if the choice of σ is clear from the context.

Intuitively, if σ has high locality of reference, the number dσ [i] of distinct pagesbetween two consecutive requests to a page is small for most values of i and thusσ has low non-locality. Note that while this measure is related to the working setmodel [22] and the locality model of [2], it differs from both in several aspects. Al-bers et al. [2] consider the maximum/average number of distinct pages in all windowsof the same size, while we consider the number of distinct pages requested since thelast access to each page. Also our analysis does not depend on a concave functionf whose identification for a particular application might not be straightforward. Ourmeasure is also closely related to the working set theorem in self-organizing datastructures [48]. For binary search trees (such as splay trees), the working set bound isdefined as

∑1≤i≤|σ | log (dσ [i] + 1). The logarithm can be explained by the logarith-

mic bounds on most operations in binary search trees. Thus our measure of localityof reference can be considered as a variant of this measure in which we remove thelogarithm. Another relevant measure is the local entropy of a string in the context ofdata compression algorithms. Although local entropy was implicitly used in [12, 40],it was explicitly defined by Kaplan et al. [36] to obtain a simpler and more realisticanalysis of Burrows-Wheeler-based compression. Local entropy of a sequence is de-fined in the same way as its working set bound, and therefore it is closely related toour measure.

Example 1 Let k = 3 be the size of the cache and consider the request sequenceσ = (p1,p2,p3,p4,p5,p4,p5,p3,p5,p5,p1,p2,p6,p4,p5). We have dσ [i] = i

for 1 ≤ i ≤ 5 and dσ [13] = 6 as these are the first requests to their correspond-ing pages. By Definition 1 we have dσ [6] = 2, dσ [7] = 2, dσ [8] = 3, dσ [9] = 2,dσ [10] = 1, dσ [11] = 5, dσ [12] = 5, dσ [14] = 6, dσ [15] = 5. Thus

λ(σ ) = 1

|σ |∑

1≤i≤|σ |dσ [i]

= 1

15(1 + 2 + 3 + 4 + 5 + 2 + 2 + 3 + 2 + 1 + 5 + 5 + 6 + 6 + 5) = 52

15.

The rest of this section is organized as follows. In Sect. 2.1 we study the non-locality measure of sequences from a set of real-life traces. We then provide boundson the performance of well known paging algorithms in terms of the non-localitymeasure in Sect. 2.2. We define two other possibilities for locality measure of pagingin Sect. 2.3. Finally, in Sect. 2.4 we discuss the connection between our approach andadaptive analysis.

2Observe that we somehow assume that all pages are requested just before the first request of the se-quence. This is similar to the prefetching optimization trick of LZ77 in which the alphabet is syntheticallyprepended to the text.

Algorithmica

Table 1 Locality of address traces collected from SPARC processors running the SPEC92 benchmarks

espresso li eqntott compress tomcatv ear sc swm gcc

Distinct 3913 3524 9 189 5260 1614 561 3635 2663

λ 193.1 195.2 1.7 2.3 348.3 34.1 5.4 166.7 90.6

Ratio 4.9 % 5.5 % 19.3 % 1.2 % 6.6 % 2.1 % 1.0 % 4.6 % 3.4 %

2.1 Experimental Evaluation of the Measure

In order to check validity of our measure we ran some experiments on traces of mem-ory reference streams from the NMSU TraceBase [50]. Here we present the resultsof our experiments on address traces collected from SPARC processors running theSPEC92 benchmarks. We considered a page size of 2048 bytes and truncated themafter 40000 references. The important thing to notice is that these are not special casesor artificially generated memory references, but are access patterns which a real-lifeimplementation of any paging algorithm might face. The results for the correspond-ing nine program traces are shown in Table 1. The first row shows the number ofdistinct pages, the second row shows λ, and finally the third row shows the ratio ofthe actual non-locality to the worst possible non-locality. The worst possible localityof a trace asymptotically equals the number of distinct pages in that trace. It is clearfrom the low ratios that in general these traces exhibit high locality of reference asdefined by our measure.

2.2 Theoretical Results

Next we analyze several well known paging algorithms in terms of the non-localityparameter. We consider the fault rate, the measure usually used by practitioners. Thefault rate of a paging algorithm A on a sequence σ is defined as A(σ )/|σ |, i.e., thenumber of faults A incurs on σ normalized by the length of σ . The fault rate of A,FA, is defined as the asymptotic worst case fault rate of A on any sequence.

Observe that the bounds are in the worst case sense, i.e., when we say FA ≥ f (λ)

we mean that there is a sequence σ such that A(σ )|σ | ≥ f (λ(σ )) and when we say

FA ≤ g(λ) we mean that for every sequence σ we have A(σ )|σ | ≤ g(λ(σ )). Also for

simplicity, we ignore the details related to the special case of the first few requests(the first block or phase). Asymptotically and as the size of the sequences grow, thiscan only change the computation by additive lower order terms. Most of the proofsbelow use constructions similar to the ones found in [13]. This is an advantage as wereuse the same techniques to prove sharper results.

Lemma 1 For any deterministic paging algorithm A, λk+1 ≤ FA ≤ λ

2 .

Proof For the lower bound consider a slow memory containing k + 1 pages. Letσ be a sequence of length n obtained by first requesting p1,p2, . . . , pk,pk+1, andafterwards repeatedly requesting the page not currently in A’s cache. Since A(σ )

|σ | =

Algorithmica

n/n = 1, and λ is at most k + 1 (there are k + 1 distinct pages in σ ), the lower boundfollows.

For the upper bound, consider any request sequence σ of length n. For i > 1, ifthe ith request is a fault charged to A, then dσ [i] ≥ 2 (otherwise σi cannot have beenevicted). Hence, 2A(σ ) ≤ ∑n

i=1 dσ [i] and the upper bound follows. �

We now show that LRU attains the best possible performance in terms of λ. Weremark that the same result has already been proved in [42].

Theorem 1 [42] FLRU = λk+1 .

Proof It follows from Lemma 1 and the observation that after the first phase LRUfaults on the request σi if and only if dσ [i] ≥ k + 1, which implies LRU(σ ) ≤

λk+1 |σ |. �

Next, we show a general upper bound for conservative and marking algorithms.

Lemma 2 Let A be a conservative or marking algorithm, then FA ≤ 2λk+3 .

Proof Let σ be an arbitrary sequence and let ϕ be an arbitrary phase in the decom-position of σ . A incurs at most k faults on ϕ. For any phase except the first, the firstrequest in ϕ, say σi , is to a page that was not requested in the previous phase, whichcontained k distinct pages. Hence, dσ [i] ≥ k + 1. There are at least k − 1 other re-quests in ϕ to k − 1 distinct pages, which all could have been present in the previous

phase. But these pages contribute at least∑k−1

j=1(j +1) = k−1+ k2−k2 to λ. It follows

that the contribution of this phase to |σ |λ is at least k + 1 + k − 1 + k2−k2 = k2+3k

2 .Hence,

A(σ )

|σ |λ ≤ k

k2+3k2

= 2

k + 3⇒ FA ≤ 2λ

k + 3. �

There is a matching lower bound for FWF.

Lemma 3 FFWF ≥ 2λk+3 .

Proof Consider the sequence σ obtained by n times repeating of the block {p1p2 · · ·pkpk+1pkpk−1 · · ·p2}. We have FWF(σ ) = 2kn, since FWF faults on all the re-quests. Now consider any block except the first. First, consider a page pi , 2 ≤ i ≤ k.The first and second request to pi contribute i and k + 2 − i to |σ |λ, respec-tively, giving a total contribution of k + 2. The requests to p1 and pk+1 con-tribute k + 1 each. Hence, the total contribution (for all phases except the first) is(k − 1)(k + 2) + 2(k + 1) = k2 + 3k. Therefore

FWF(σ )

|σ |λ = 2k

k2 + 3k= 2

k + 3. �

Algorithmica

Thus FWF has approximately twice as many faults as LRU on sequences with thesame locality of reference, in the worst case. FIFO also has optimal performance interms of λ.

Lemma 4 FFIFO ≤ λk+1 .

Proof Let σ be an arbitrary sequence. Consider a fault σi on a page p and let σj1,

σj2, . . . , σjm be the requests to p since p last entered the cache. By definition all therequests σj1, σj2, . . . , σjm are hits and p is evicted between σjm and σi . Observe thatfor p to get evicted at least k distinct pages other than p have to be requested since p

entered the cache, hence dσ [i] + ∑mh=1 dσ [jh] ≥ k + 1. It follows that for each fault

charged to FIFO we have at least a contribution of k + 1 to |σ |λ. �

Lemma 5 FLFU ≥ 2λk+3 .

Proof Consider the (usual) sequence σ = pn1pn

2 · · ·pnk−1{pkpk+1}n, where

LFU(σ ) = k − 1 + 2n. For |σ |λ, each of the pages pi , 1 ≤ i ≤ k − 1, contributesi + n − 1, and the pages pi , k ≤ i ≤ k + 1, contribute i + 2(n − 1) each. Hence,|σ |λ = 1 + 2 + · · · + (k − 1) + k + (k + 1) + (k − 1)(n − 1) + 2(2n − 2) =(k + 3)n + (k2 + k − 4)/2, and therefore

LFU(σ )

|σ |λ = 2n + k − 1

(k + 3)n + (k2 + k − 4)/2,

which converges to 2k+3 as n grows. �

In contrast LIFO has the worst possible performance in terms of λ.

Lemma 6 FLIFO ≥ λ2 .

Proof Consider the sequence σ = p1p2 · · ·pkpk+1{pkpk+1}n. We have LIFO(σ ) =k + 1 + 2n and |σ |λ = (k + 1)(k + 2)/2 + 2 · 2n, and the bound follows. �

LRU-2 is another paging algorithm proposed by O’Neil et al. for database diskbuffering [41]. On a fault, LRU-2 evicts the page whose second to the last request isleast recent. If there are pages in the cache that have been requested only once so far,LRU-2 evicts the least recently used among them. Boyar et al. proved that LRU-2has competitive ratio 2k, which is worse than FWF [17].

Lemma 7 2kλ(k+1)(k+2)

≤ FLRU−2 ≤ 2λk+1 .

Proof Let σ be the sequence obtained by n times repetition of the block {p1p2 · · ·pk−1pkpkpk−1 · · ·p1pk+1pk+1}. Now, consider any block except the first. LRU-2faults on all requests except the second request to pk and the second request to pk+1,giving a total of 2k faults. The first request to pi , 1 ≤ i ≤ k − 1, contributes i to |σ |λand the second request to pi contributes k + 2 − i. Hence, each of these k − 1 pages

Algorithmica

contributes k + 2. For the pages pk and pk+1, their first request contributes k + 1and the second only 1 to |σ |λ. This gives a total contribution of (k + 1)(k + 2), andasymptotically the result follows.

For the upper bound, given a page p consider three consecutive faults on it in σ .At least k other distinct pages should have been requested since the first fault on p

(at least k − 1 other pages with at least 2 request and at least one other page). �

While no deterministic on-line paging algorithm can have competitive ratio betterthan k, there are randomized algorithms with better competitive ratio. The random-ized marking algorithm MARK, introduced by Fiat et al. [31], is 2Hk-competitive,where Hk is the kth harmonic number. On a fault, MARK evicts a page chosen uni-formly at random among the unmarked pages. Let σ be a sequence and ϕ1, ϕ2, . . . , ϕm

be its phase decomposition. A page requested in phase ϕi is called clean if it was notrequested in phase ϕi−1 and stale otherwise. Let ci be the number of clean pagesrequested in phase ϕi . Fiat et al. proved that the expected number of faults MARKincurs on phase ϕi is ci(Hk − Hci

+ 1) [31].

Lemma 8 FMARK = 2λ3k+1 .

Proof Let σ be {p1p2 · · ·pkpk+1pk+2 · · ·p2kpkpk−1 · · ·p1p2k · · ·pk+1}n. This se-quence has n blocks and 4n phases. All pages of each phase are clean. There-fore we have ci = k for 1 ≤ i ≤ 4n and the expected number of faults MARKincurs on each phase is k × (Hk − Hk + 1) = k. Thus the expected number offaults of MARK in each block is 4k. Each block except the first one contributes4(k + 1 + k + 2 + · · · + 2k) = 4(k2 + k(k + 1)/2) = 2(3k2 + k) to |σ |λ. Hence

E(MARK(σ ))

|σ |λ = 4k

2(3k2 + k)= 2

3k + 1,

which proves the lower bound.For the upper bound, consider an arbitrary sequence σ and let ϕ1, . . . , ϕm be its

phase decomposition. Consider the ith phase ϕi for i > 1 and suppose that it has ci

clean pages. The expected cost of MARK on ϕi is at most ci(Hk −Hci+1). The first

request to the j th clean page in ϕi contributes at least k + j to |σ |λ (k pages fromprevious phase and j − 1 clean pages that have been seen so far). The first request tothe j th stale page in ϕi contributes at least j + 1. Therefore the contribution of phasei to |σ |λ is at least

∑ci

j=1 (k + j) + ∑k−ci

j=1 (j + 1) = (2c2i − 2ci + k2 + 3k)/2, and

E(MARK(σ ))

|σ |λ ≤ 2ci(Hk − Hci+ 1)

2c2i − 2ci + k2 + 3k

,

where 1 ≤ ci ≤ k. This is an increasing function in terms of ci and attains its maxi-mum at ci = k. Thus we have

E(MARK(σ ))

|σ |λ ≤ 2k(Hk − Hk + 1)

2k2 − 2k + k2 + 3k= 2

3k + 1. �

Algorithmica

Table 2 Bounds for pagingAlgorithm Lower bound Upper bound

Deterministic λk+1

λ2

LRU λk+1

λk+1

Marking λk+1

2λk+3

FWF 2λk+3

2λk+3

FIFO λk+1

λk+1

LFU 2λk+3

λ2

LIFO λ2

λ2

LRU-2 2kλ(k+1)(k+2)

2λk+1

MARK 2λ3k+1

2λ3k+1

LFD λ3k+1

2λ3k+1

Finally we bound the performance of LONGEST-FORWARD-DISTANCE (LFD),an optimal offline algorithm. On a fault, LFD evicts the page whose next request isfurthest in the future.

Lemma 9 λ3k+1 ≤ FLFD ≤ 2λ

3k+1 .

Proof Let σ be {p1p2 · · ·pkpk+1pk+2 · · ·p2kpkpk−1 · · ·p1p2k · · ·pk+1}n. This se-quence has 4n phases and n blocks. Each two consecutive phases of σ contain 2k

distinct pages. LFD contains at most k pages in its cache before serving these phasesand thus it would incur at least k faults on serving any two consecutive phases. ThusLFD incurs at least 2k faults in each block. Each block except the first one contributes4(k + 1 + k + 2 + · · · + 2k) = 4(k2 + k(k + 1)/2) = 2(3k2 + k) to |σ |λ. Hence

LFD(σ )

|σ |λ ≥ 2k

2(3k2 + k)= 1

3k + 1,

which proves the lower bound.For the upper bound observe that any randomized algorithm can be viewed as a

probability distribution on a set of deterministic algorithms. Since the performanceof LFD on any sequence is at least as good as the performance of any deterministicalgorithm on that sequence, the performance of LFD is no worse than the expectedperformance of a randomized algorithm on any sequence. Thus the upper bound fol-lows from Lemma 8. �

The results are summarized in Table 2. According to these results, LRU and FIFOhave optimal performance among deterministic algorithms. Marking algorithms canbe twice as bad and FWF is among the worst marking algorithms. LIFO has theworst performance possible and LRU-2 is almost twice as bad as LRU. Observe that

Algorithmica

LFD, an optimal offline algorithm, is only a factor of 3 better than LRU under thismeasure. Contrast this with the competitive ratio for which LFD is k times betterthan LRU.

2.3 Alternative Measures of Non-locality

A natural question is whether there are better measures for non-locality of paginginstances. In this section, we consider two other natural non-locality measures forpaging. We will see that these measures are not as effective as λ. Thus, λ is at leasta reasonable measure for non-locality of paging sequences. The first alternative is asimple measure that is based on the phase decomposition of sequences.

Definition 2 For a sequence σ , let |D(σ)| be the number of phases of σ . We de-fine λ̃(σ ), the “non-locality” of σ , as |D(σ)|/|σ |. We denote the non-locality by λ̃ ifthe choice of σ is clear from the context.

We can easily get results comparable to competitive analysis using this simpledefinition of non-locality. First we obtain a lower bound on the performance of anydeterministic online algorithm.

Lemma 10 For any deterministic online algorithm A we have FA ≥ k · λ̃.

Proof We construct a sequence σ that contains k + 1 distinct pages by requestingthe page that is not in A’s cache at each time. A incurs a fault on each request ofσ and we have A(σ )/|σ | = 1. Since the length of each phase is at least k, we have|D(σ)| ≤ |σ |/k ⇒ λ̃(σ ) ≤ 1/k. Therefore A(σ )/|σ | ≥ k · λ̃(σ ). �

As in competitive analysis, all marking and conservative paging algorithms haveoptimal performance. This follows from the fact that any marking or conserva-tive algorithm incurs at most k faults in each phase. The performance of LIFOand LFU cannot be bounded in terms of λ̃. For LIFO, consider the sequenceσ = p1p2 · · ·pkpk+1{pkpk+1}n for an arbitrary integer n. LIFO incurs a fault on allrequests of σ , while we have |D(σ)| = 2. Therefore LIFO(σ )/|σ | = 1 = |σ |

2 λ̃(σ ).For LFU, consider the sequence σ = pn

1pn2 · · ·pn

k−1{pkpk+1}n for an arbitrary inte-ger n. We have |D(σ)| = 2 and LFU incurs a fault on all last 2n requests. HenceLFU(σ ) = 2n/|σ | = n · λ̃(σ ). Since we can select an arbitrarily large n, LFU doesnot have a bounded fault rate in terms of λ̃.

Thus the phase-based definition of non-locality does not give better separationresults than competitive analysis. A more elaborate definition can be obtained as fol-lows.

Definition 3 Let σ be a request sequence. We call a page request “non-local” if it isthe first request to that page or at least k distinct pages have been requested since theprevious request to this page in σ . The non-locality of σ , λ̂, is defined as the numberof non-local requests in σ , divided by |σ |.

Algorithmica

If a sequence has high locality of reference, there are not many distinct pages be-tween two consecutive requests to a page. Therefore there are not many non-localrequests and the sequence has small non-locality. First we show that LRU achievesthe optimal fault rate in terms of λ̂. We remark that Panagiotou and Souza [42] pro-vided and proved the same result.

Theorem 2 [42] FLRU = λ̂.

Proof LRU always maintains in its cache the last k distinct pages that are requested.Therefore a request is a fault for LRU if and only if it is a non-local request. Thus wehave LRU(σ )/|σ | = λ̂(σ ). �

Lemma 11 For any deterministic online paging algorithm A, FA ≥ λ̂.

Proof Consider a sequence σ obtained by requesting an item that is not in A’s cacheat each time. We have A(σ ) = |σ |. On the other hand, σ has at most |σ | non-localrequests and we have λ̂(σ ) ≤ 1. Therefore A(σ )/|σ | = 1 ≥ λ̂(σ ) �

The following lemma shows that marking algorithms are a reasonable choice ingeneral, even if not always optimal.

Lemma 12 For any conservative or marking algorithm A, we have FA ≤ k · λ̂.

Proof Let σ be an arbitrary sequence and let ϕ be an arbitrary phase of the decom-position of σ . We know that A incurs at most k faults on ϕ. We claim that the firstrequest in ϕ is always non-local. If this is the first phase, then this is the first request toa page and is non-local by definition. Otherwise, it should be different from k distinctpages that are requested in the previous phase. Therefore it is not requested in theprevious phase and at least k distinct pages have been requested since the last requestto this page. Thus we have at most k faults and at least one non-local request in eachphase and this proves the desired upper bound. �

Other well known algorithms are not optimal in terms of λ̂.

Lemma 13 FFIFO = k · λ̂.

Proof The upper bound follows from Lemma 12. For the lower bound, considerthe sequence σ that starts with σ0 = p1p2 · · ·pkp1p2 · · ·pk−1pk+1p1p2 · · ·pk−1 andcontains k + 1 distinct pages. After the initial subsequence σ0, σ consists of severalblocks. Each block starts right after the previous block and contains 2k − 1 requeststo k distinct pages. Let p be the page that is not in the cache at the beginning ofa block B , q be the page that is requested just before B , and π be the ordered se-quence of k − 1 pages that are requested in the previous block before last requestto q . B starts by π , then has a request to page p, and finally ends by another copyof π . Initial blocks of σ are shown in Fig. 1.

Algorithmica

p1 p2 · · · pk

p1 p2 p3 · · · pk−1 pk+1 p1 p2 p3 · · · pk−1pk+1 p1 p2 · · · pk−2 pk pk+1 p1 p2 · · · pk−2pk pk+1 p1 · · · pk−3 pk−1 pk pk+1 p1 · · · pk−3

· · · · · · · · · · · · · · · · · ·Fig. 1 The sequence σ in the proof of Lemma 13

It is easy to verify that FIFO incurs a fault on the last k requests of each blockwhile only the middle request of every block is non-local. Let n be the number ofblocks of σ . We have FIFO(σ ) = n · k and λ̂(σ ) = n and the lower bound follows. �

We can obtain a similar lower bound for FWF by considering the sequence ob-tained by sufficient repetitions of the pattern p1p2 · · ·pkpk+1pkpk−1 · · ·p2.

Lemma 14 FFWF = k · λ̂.

Lemma 15 The fault rate of LFU and LIFO cannot be bounded in terms of λ̂.

Proof Consider the sequence σ = pn1pn

2 · · ·pnk−1{pkpk+1}n. LFU incurs a fault on

the last 2n requests of σ . Only the first request to a page is non-local in σ and wehave λ̂(σ ) = (k + 1)/|σ |. Therefore LFU(σ )/|σ | = 2n/|σ | = 2n

k+1 λ̂(σ ). Since n can

be selected arbitrarily larger than k, the fault rate of LFU is not bounded in terms of λ̂.For LIFO, consider the sequence p1p2 · · ·pkpk+1{pkpk+1}n. LIFO incurs a fault onall requests of σ , while we have λ̂(σ ) = (k + 1)/|σ |. Therefore LIFO(σ )/|σ | = 1 =|σ |k+1 λ̂(σ ). �

Theorem 3 FLRU−2 = k · λ̂.

Proof [Lower bound] Let σ be the sequence introduced in the proof of Lemma 7, i.e.,σ = {p1p2 · · ·pk−1pkpkpk−1 · · ·p1pk+1pk+1}n. As we proved there, LRU-2 incurs2k faults in each block. In each block except the first, only two requests are non-local, namely the first request to pk and the first request to pk+1. Consider a pagepi for 1 ≤ i ≤ k − 1 and a block bj for 2 ≤ j ≤ n. There are at most k − 1 distinctpages between the first request to pi in bj and the previous request to pi (which isin the previous block), since pk is not requested in this period. Thus the first requestto pi in bj is local. Also pk+1 is not requested between the two requests to pi in bj .Therefore the second request to pi in bj is local too. The first request to pk and thefirst request to pk+1 in bj are non-local. Thus at each block we have two non-localrequests, while LRU-2 incurs 2k faults and the lower bound follows.

[Upper bound] Let σ be an arbitrary sequence of page requests. Partition σ intoa set of consecutive blocks so that each block consists of a maximal sequence thatcontains exactly one non-local request. Note that each block starts with a non-localrequest and all other requests of the block are local. We prove that LRU-2 incursat most k faults in each block. Let B1,B2, . . . ,Bm be the blocks of σ . B1 con-tains requests to one page and LRU-2 incurs one fault on it. Consider an arbi-trary block Bi for i > 1, let p be the first request of Bi , and let p1,p2, . . . , pk−1

Algorithmica

be the k − 1 most recently used pages before the block Bi in this order. We havep �∈ P = {p1,p2, . . . , pk−1}, because p is a non-local request. We claim that eachrequest of Bi is either to p or to a page of P . Assume for the sake of contradictionthat Bi contains a request to a page q �∈ {p} ∪ P and consider the first request to q

in Bi . All pages p,p1,p2, . . . , pk−1 have been requested since the previous requestto q . Therefore at least k distinct pages have been requested since the last request toq and q is non-local. This contradicts the definition of a block. Hence Bi contains atmost k distinct pages.

We claim that LRU-2 incurs at most one fault on every page q in block Bi . As-sume that this is not true and LRU-2 incurs two faults on a page q in Bi . Thereforeq is evicted again at some point after its first request in Bi . Assume that this evictionhappened on a fault on a page r and consider the pages that are in LRU-2’s cache justbefore that request. Since r ∈ {p} ∪P is not in the cache and |{p} ∪P | = k, there is apage s �∈ {p} ∪ P in the cache. The last request to s is before the last request to pk−1before the block Bi , while the second to last request to q is after this request. There-fore LRU-2 does not evict q on this fault, which is a contradiction. Thus, LRU-2contains at most k distinct pages in each block and incurs at most one fault on eachpage. Hence, LRU-2(σ )/|σ | ≤ km/|σ | = k · λ̂(σ ). �

The performance of MARK in terms of λ̂ is worse than LRU but better than otherwell known deterministic algorithms.

Theorem 4 FMARK = Hk · λ̂.

Proof [Lower bound] Consider the sequence σ = {p1p2 · · ·pkpk+1pkpk−1 · · ·p2}nfor some integer n. This sequence has 2n phases, each odd numbered phase has theform p1p2 · · ·pk and each even numbered phase has the form pk+1pk · · ·p2. Alsoeach phase has only one clean page, namely its first request. Therefore we have ci = 1for 1 ≤ i ≤ 2n and the expected number of faults MARK incurs on each phase is1 × (Hk − H1 + 1) = Hk . Thus E(MARK(σ )) = 2nHk . Only the first request ofeach phase is non-local and we have λ̂(σ ) = 2n/|σ |. Hence

E(MARK(σ ))

|σ | = 2nHk · λ̂(σ )

2n= Hk · λ̂(σ ).

[Upper bound] Consider an arbitrary sequence σ and let ϕ1, ϕ2, . . . , ϕm be itsphase decomposition. Suppose that the ith phase ϕi has ci clean pages. Thereforethe expected cost of MARK on σ is

∑ni=1 ci(Hk − Hci

+ 1) ≤ ∑ni=1 ciHk . The first

request to a clean page in a phase is non-local because it is not among the k distinctpages that are requested in the previous phase. Therefore we have |σ |λ̂(σ ) ≥ ∑n

i=1 ci .We have

E(MARK(σ ))

|σ | ≤∑n

i=1 ciHk∑n

i=1 ci

· λ̂(σ ) = Hk · λ̂(σ ). �

If there is no restriction on the number of distinct pages in the sequence, we canprove a lower bound of λ̂ on the fault rate of LFD, by always requesting a page thathas not been requested so far. Each request is non-local and LFD incurs a fault on it.

Algorithmica

Table 3 Bounds for pagingalgorithms in terms of λ̂ andnumber of distinct pages M

Algorithm Lower bound Upper bound

Deterministic λ̂ unbounded

LRU λ̂ λ̂

Marking λ̂ k · λ̂FWF k · λ̂ k · λ̂FIFO k · λ̂ k · λ̂LFU unbounded unbounded

LIFO unbounded unbounded

LRU-2 k · λ̂ k · λ̂MARK Hk · λ̂ Hk · λ̂LFD (M − k)λ̂/M λ̂

Thus LFD does not have a better performance than LRU on this general setting. If werestrict the number of distinct pages to M then we get a lower bound of (M − k)/M

on the fault rate of LFD by considering the sequence σ = {p1,p2, . . . , pM}n. In eachblock there are M distinct pages. Since the size of cache is k, LFD incurs at leastM − k faults in each block. All requests are non-local and we have λ̂(σ ) = 1. ThusLFD(σ )/|σ | = (M − k)/M = M−k

Mλ̂(σ ). The results are summarized in Table 3.

Comparison of the Three Measures We have seen three possible measures for non-locality of sequences for paging. We obtain different results in our parameterizedframework by using each measure. The measure λ̃ is simplest among them, but itdoes not give better separation results than standard competitive analysis. Thereforeit shares most of the shortcomings of competitive analysis described in the Introduc-tion. The remaining two measures provide better separation between paging algo-rithms. They both separate the performance of LRU from FWF. However, they donot always give equivalent results. According to λ, LRU and FIFO are both opti-mal deterministic online algorithms. Also the performance of MARK is better thanLRU. In contrast, when we consider λ̂, LRU has strictly better performance thanboth FIFO and MARK. Furthermore, FIFO, LRU-2, and FWF have the same per-formance. The performance of MARK is between LRU and FIFO. It seems that thedefinition of λ̂ is tailored to the behavior of LRU, as it considers a clear distinctionbetween local and non-local requests. We remark that a similar distinction was usedin adequate analysis [42]. A good feature of λ is that we obtain better performancepredictions by increasing the size of the cache, while the reverse is true for the othermeasures. Overall, λ̂ and λ both have their own merits and shortcomings, but λ seemsto be the preferable choice for non-locality measure.

2.4 Adaptive Analysis

In this section we study the connection between the λ measure and adaptive analysis.Recall that the adaptive performance of an algorithm is obtained by describing itstraditional worst-case performance in terms of the size and difficulty of the instance.Observe that the competitive ratio can be seen as a special case of adaptive analysis,

Algorithmica

namely the case where the measure of difficulty is the performance of the off-line OPT

algorithm. Our model can be expressed in terms of adaptive analysis by consideringthe non-locality of each sequence as its difficulty measure.

Thus we can generalize this framework to other online problems too. For eachproblem, we can choose the measure that best reflects the difficulty of the input.As in the case of parameterized complexity and previous adaptive analysis results,choosing the right measure of difficulty is a non-trivial task which can require severaliterations. For example see the survey by Estivill-Castro and Wood [30] for severaldifficulty measures for the sorting problem. In the case of most on-line problemsstudied, the off-line optimum does not seem to be a good measure and hence thequest for alternative measures [5, 11, 15, 18, 39, 51]. We have seen several alternativemeasures for paging in this section.

In certain online problems, good performance under competitive analysis necessi-tates the algorithm to make a move that is suboptimal in most cases except for a patho-logical worst case scenario. If the application is such that these pathological cases areagreed to be of lesser importance, then the online strategy can perform somewhatmore poorly in these and make the choice that is best for the common case. Thismeans that the input is no longer assumed to be adversarially constructed. This betterreflects the case of paging, in which programmers, compilers, instruction schedulersand optimized virtual machines (such as HotSpot) go to great lengths to maintainand increase locality of reference in the code. Hence it is more realistic to assumethat paging sequences are not adversarial and that furthermore, the user/programmerfully expects code with low locality of reference to result in a degradation in per-formance. The same observation has been made in scenarios such as online robotexploration and network packet switching, in which a robot vacuuming a room or arouter serving a packet sequence need only optimize in well behaved common cases.A vacuuming robot need not efficiently vacuum a maze, neither does the router haveto keep up with denial-of-service floods.

3 Parameterized Analysis of List Update Algorithms

In this section we study the parameterized complexity of list update algorithms interms of locality of reference. In the list update problem, we have an unsorted listof � items. The input is a sequence of n requests that should be served in an onlinemanner. Let A be an arbitrary online list update algorithm. To serve a request to anitem x, A should linearly search the list until it finds x. If x is the ith item in thelist, A incurs cost i to access x. Immediately after accessing x, A can move x to anyposition closer to the front of the list at no extra cost. This is called a free exchange.Also A can exchange any two consecutive items at a cost of 1. These are called paidexchanges. The objective is to use free and paid exchanges to minimize the overallcost of serving a sequence.

Three well known deterministic online list update algorithms are Move-To-Front(MTF), Transpose, and Frequency-Count (FC). MTF moves the requested item tothe front of the list and TRANSPOSE exchanges the requested item with the item thatimmediately precedes it. FC maintains a frequency count for each item, updates this

Algorithmica

count after each access, and makes necessary moves so that the list always containsitems in non-increasing order of frequency count. Sleator and Tarjan showed thatMTF is 2-competitive, while TRANSPOSE and FC do not have constant competitiveratios [47]. Albers introduced the algorithm TimeStamp (TS) and showed that it is2-competitive [1]. After accessing an item a, TS inserts a in front of the first item b

that appears before a in the list and was requested at most once since the last requestfor a. If there is no such item b, or if this is the first access to a, TS does not reorderthe list.

While list update algorithms can be more easily distinguished using competitiveanalysis than in the paging case, the experimental study by Bachrach and El-Yanivsuggests that the relative performance hierarchy as computed by the competitive ra-tio does not correspond to the observed relative performance of the algorithms inpractice [8]. Several authors have pointed out that input sequences of list update algo-rithms in practice show locality of reference [13, 33, 45] and indeed online list updatealgorithms try to take advantage of this property [33, 44]. Recently, Angelopouloset al. [6] and Albers and Lauer [3] have studied list update with locality of reference.We define the non-locality of sequences for list update in an analogous way to the cor-responding definition for paging (Definition 1). The only difference is that we do notnormalize the non-locality by the length of the sequence, i.e., λ̂(σ ) = ∑

1≤i≤|σ | dσ [i].This change is due to the fact that unlike fault rate for paging, we do not normalizethe cost of list update algorithms by the length of the sequence.

Theorem 5 For any deterministic online list update algorithm A we have λ̂ ≤A(σ ) ≤ � · λ̂.

Proof [Upper bound] Consider an arbitrary sequence σ of length n. Since the maxi-mum cost that A incurs on a request is �, we have A(σ ) ≤ n�. We have dσ [i] ≥ 1 forall values of i. Thus λ̂ ≥ n. Therefore A(σ )

λ̂≤ n�

n= �.

[Lower bound] Consider a sequence σ of length n obtained by requesting theitem that is in the last position of the list maintained by A at each time. We haveA(σ ) = n�, and dσ [i] ≤ � because σ has at most � distinct items. Therefore λ̂ ≤ n�,and A(σ )

λ̂≥ n�

n�= 1. �

Theorem 6 MTF is optimal in terms of λ̂: MTF(σ ) = λ̂.

Proof Consider the ith request of σ . The cost of MTF on σi is exactly dσ [i]. Hence,MTF(σ ) = ∑

1≤i≤n dσ [i] = λ̂. �

The following lemmas show that other well known list update algorithms are notoptimal in terms of λ̂.

Lemma 16 TRANSPOSE(σ ) ≥ �·̂λ2 .

Proof Let L0 = (a1, a2, . . . , a�) be the initial list. Consider a sequence σ of length n

obtained by several repetitions of pattern a�a�−1. We have TRANSPOSE(σ ) = n · �.

Algorithmica

Also we have dσ [i] = i for 1 ≤ i ≤ 2 and dσ [i] = 2 for 2 < i ≤ n. Therefore λ̂ =3 + 2n − 4 = 2n − 1, and

TRANSPOSE(σ )

λ̂= n · �

2n − 1,

which becomes arbitrarily close to �/2 as n grows. �

Lemma 17 FC(σ ) ≥ (�+1)̂λ2 ≈ �·̂λ

2 .

Proof Let L0 = (a1, a2, . . . , a�) be the initial list and n be an arbitrary integer. Con-sider the following sequence: σ = an

1an2an

3 · · ·an� . On serving σ , FC does not change

the order of items in its list and incurs cost∑�

i=1 ni = n∑�

i=1 i = n�(�+1)

2 . We have

λ̂ = ∑�i=1(i + (n − 1)) = � · n + �(� − 1)/2. Therefore

FC(σ )

λ̂= n

�(�+1)2

� · n + �(� − 1)/2,

which approaches �+12 as n grows. �

Lemma 18 TS(σ ) ≥ 2�·̂λ�+1 ≈ 2̂λ.

Proof Let L0 = (a1, a2, . . . , a�) be the initial list and n be an arbitrary integer. Con-sider the sequence σ obtained by the repetition of the block a2

�a2�−1 · · ·a2

1 n times. LetB be an arbitrary block of σ . Each item ai is accessed twice in B . TS does not moveai after its first access in B , because each item has been accessed twice since the lastaccess to ai . After the second access, TS moves the item to the front of the list. There-fore each access is to the last item of the list and TS incurs a cost of � on each access.Thus, we have TS(σ ) = 2�2n. Next we compute λ̂. The first and second access to ai

in the first block contribute �− i +1 and 1 to λ̂, respectively. Let B be the ith block ofσ for i > 1. The first and second access to ai in B contribute � and 1 to λ̂, respectively.Thus we have λ̂ = (� + 1)(� + 2)/2 − 1 + �(� + 1)(n − 1) = �(� + 1)n − �(� − 1)/2.Therefore

TS(σ )

λ̂= 2�2n

�(� + 1)n − �(� − 1)/2,

which approaches 2��+1 as n grows. �

Observe that parameterized analysis by virtue of its finer partition of the inputspace resulted in the separation of several of these strategies which were not sep-arable under the classical model. This introduces a hierarchy of algorithms betterreflecting the relative strengths of the strategies considered above. We can also applythe parameterized analysis to randomized list update algorithms by considering theirexpected cost.

In the next theorem we show that, surprisingly, certain randomized algorithmswhich are superior to MTF in the standard model are not so in the parameterized

Algorithmica

Table 4 Bounds for list updateAlgorithm Lower bound Upper bound

General λ̂ � · λ̂MTF λ̂ λ̂

TRANSPOSE �·̂λ2 � · λ̂

FC ≈ �·̂λ2 � · λ̂

TS ≈2̂λ � · λ̂BIT ≈ 3

2 λ̂

case. Observe that in the competitive ratio model a deterministic algorithm must servea pathological, rare worst case even if at the expense of a more common but notcritical case, while a randomized algorithm can hedge between the two cases, hencein the classical model the randomized algorithm is superior to the deterministic one.In contrast, in the parameterized model the rare worst case, if pathological, has alarger non-locality measure, leading to a larger λ factor. Hence such a case can safelybe ignored, with a resulting overall increase in the measured quality of the algorithm.

The algorithm BIT, considers a bit b(a) for each item a and initializes thesebits uniformly and independently at random. Upon an access to a, it first comple-ments b(a), then if b(a) = 0 it moves a to the front, otherwise it does nothing. BIT

has competitive ratio 1.75, thus outperforming any deterministic algorithm [43]. Inthe parameterized model this situation is reversed.

Theorem 7 E(BIT(σ )) ≥ (3�+1)̂λ2�+2 ≈ 3̂λ/2.

Proof Let L0 = (a1, a2, . . . , a�) be the initial list and n be an arbitrary integer. Con-sider the sequence σ defined in the proof of Lemma 18, i.e., σ = {a2

�a2�−1 · · ·a2

1}n.Let σi and σi+1 be two consecutive accesses to aj . After two consecutive accessesto each item, it will be moved to the front of the list with probability 1. Therefore aj

is in the last position of the list maintained by BIT at the time of request σi and BIT

incurs cost � on this request. After this request, BIT moves aj to the front of the listif and only if b(aj ) is initialized to 1. Since b(aj ) is initialized uniformly and inde-pendently at random, this will happen with probability 1/2. Therefore the expectedcost of BIT on σi+1 is 1

2 (� + 1) and the expected cost of BIT on σ is n�(� + �+12 ).

We have λ̂ = �(� + 1)n − �(� − 1)/2. Therefore

E(BIT(σ ))

λ̂= n · �(� + �+1

2 )

�(� + 1)n − �(� − 1)/2,

which approaches 3�+12�+2 as n grows. �

The results are summarized in Table 4. According to these results, MTF has thebest performance among well known list update algorithms. TS has performanceat least twice as bad as MTF. The performance of TRANSPOSE and FC is at least�/2 times worse than MTF. The performance of BIT is worse than MTF, while its

Algorithmica

competitive ratio is better. Experimental results of [9] show that MTF has betterperformance than BIT in practice. Thus our measure leads to results that better matchexperiments.

4 Conclusions

We applied parameterized analysis in terms of locality of reference to paging and listupdate algorithms and showed that this model gives promising results. The plural-ity of results shows that this model is effective in that we can readily analyze wellknown strategies. Using a finer, more natural measure we separated paging and listupdate algorithms which were otherwise indistinguishable under the classical model.We showed that a randomized algorithm which is superior to MTF in the classicalmodel is not so in the parameterized case, which matches experimental evidence.This confirms that the ability of the online adaptive algorithm to ignore pathologicalworst cases can lead to the selection of algorithms that are more efficient in practice.

References

1. Albers, S.: Improved randomized on-line algorithms for the list update problem. SIAM J. Comput.27(3), 682–693 (1998)

2. Albers, S., Favrholdt, L.M., Giel, O.: On paging with locality of reference. J. Comput. Syst. Sci. 70(2),145–175 (2005)

3. Albers, S., Lauer, S.: On list update with locality of reference. In: Proceedings of the 35th InternationalColloquium on Automata, Languages and Programming (ICALP ’08). Lecture Notes in ComputerScience, vol. 5125, pp. 96–107 (2008)

4. Angelopoulos, S.: Parameterized analysis of online steiner tree problems. In: Adaptive, Output Sen-sitive, Online and Parameterized Algorithms. Dagstuhl Seminar Proceedings, vol. 09171 (2009)

5. Angelopoulos, S., Dorrigiv, R., López-Ortiz, A.: On the separation and equivalence of pagingstrategies. In: Proceedings of the 18th Annual ACM-SIAM Symposium on Discrete Algorithms(SODA ’07), pp. 229–237 (2007)

6. Angelopoulos, S., Dorrigiv, R., López-Ortiz, A.: List update with locality of reference. In: Proceed-ings of the 8th Latin American Theoretical Informatics Symposium (LATIN ’08). Lecture Notes inComputer Science, vol. 4957, pp. 399–410 (2008)

7. Angelopoulos, S., Schweitzer, P.: Paging and list update under bijective analysis. In: Proceedingsof the 20th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA ’09), pp. 1136–1145(2009)

8. Bachrach, R., El-Yaniv, R.: Online list accessing algorithms and their applications: recent empiri-cal evidence. In: Proceedings of the 8th Annual ACM-SIAM Symposium on Discrete Algorithms(SODA ’97), pp. 53–62 (1997)

9. Bachrach, R., El-Yaniv, R., Reinstaedtler, M.: On the competitive theory and practice of list accessingalgorithms. Algorithmica 32(2), 201–246 (2002)

10. Becchetti, L.: Modeling locality: a probabilistic analysis of LRU and FWF. In: Proceedings of the12th Annual European Symposium on Algorithms (ESA ’04). Lecture Notes in Computer Science,vol. 3221, pp. 98–109 (2004)

11. Ben-David, S., Borodin, A.: A new measure for the study of on-line algorithms. Algorithmica 11(1),73–91 (1994)

12. Bentley, J.L., Sleator, D.D., Tarjan, R.E., Wei, V.K.: A locally adaptive data compression scheme.Commun. ACM 29(4), 320–330 (1986)

13. Borodin, A., El-Yaniv, R.: Online Computation and Competitive Analysis. Cambridge UniversityPress, Cambridge (1998)

14. Borodin, A., Irani, S., Raghavan, P., Schieber, B.: Competitive paging with locality of reference.J. Comput. Syst. Sci. 50(2), 244–258 (1995)

Algorithmica

15. Borodin, A., Irani, S., Raghavan, P., Schieber, B.: Competitive paging with locality of reference.J. Comput. Syst. Sci. 50(2), 244–258 (1995)

16. Bose, P., Douïeb, K., Langerman, S.: Dynamic optimality for skip lists and B-trees. In: Proceedingsof the 19th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA ’08), pp. 1106–1114(2008)

17. Boyar, J., Ehmsen, M.R., Larsen, K.S.: A theoretical comparison of LRU and LRU-K. Acta Inform.47(7–8), 359–374 (2010)

18. Boyar, J., Favrholdt, L.M.: The relative worst order ratio for online algorithms. ACM Trans. Algo-rithms 3(2) (2007)

19. Boyar, J., Favrholdt, L.M., Larsen, K.S.: The relative worst-order ratio applied to paging. J. Comput.Syst. Sci. 73(5), 818–843 (2007)

20. Boyar, J., Medvedev, P.: The relative worst order ratio applied to seat reservation. ACM Trans. Algo-rithms 48, 1 (2008)

21. Chrobak, M., Noga, J.: LRU is better than FIFO. Algorithmica 23(2), 180–185 (1999)22. Denning, P.J.: The working set model for program behaviour. Commun. ACM 11(5), 323–333 (1968)23. Denning, P.J.: Working sets past and present. IEEE Trans. Softw. Eng. 6(1), 64–84 (1980)24. Denning, P.J.: The locality principle. Commun. ACM 48(7), 19–24 (2005)25. Dorrigiv, R., Ehmsen, M.R., López-Ortiz, A.: Parameterized analysis of paging and list update algo-

rithms. In: Proceedings of the 7th Workshop on Approximation and Online Algorithms (WAOA ’09).Lecture Notes in Computer Science, vol. 5893, pp. 104–115 (2009)

26. Dorrigiv, R., López-Ortiz, A.: A survey of performance measures for on-line algorithms. ACMSIGACT News 36(3), 67–81 (2005)

27. Dorrigiv, R., López-Ortiz, A.: The cooperative ratio of on-line algorithms. Technical Report CS-2007-39, Cheriton School of Computer Science, University of Waterloo (October 2007)

28. Dorrigiv, R., López-Ortiz, A., Munro, J.I.: On the relative dominance of paging algorithms. Theor.Comput. Sci. 410(38–40), 3694–3701 (2009)

29. Downey, R.G., Fellows, M.R.: Parameterized Complexity. Springer, Berlin (1999)30. Estivill-Castro, V., Wood, D.: A survey of adaptive sorting algorithms. ACM Comput. Surv. 24(4),

441–476 (1992)31. Fiat, A., Karp, R.M., Luby, M., McGeoch, L.A., Sleator, D.D., Young, N.E.: Competitive paging

algorithms. J. Algorithms 12(4), 685–699 (1991)32. Flum, J., Grohe, M.: Parameterized Complexity Theory (Texts in Theoretical Computer Science. An

EATCS Series). Springer, New York (2006)33. Hester, J.H., Hirschberg, D.S.: Self-organizing linear search. ACM Comput. Surv. 17(3), 295 (1985)34. Iacono, J.: Improved upper bounds for pairing heaps. In: Proceedings of the 7th Scandinavian Work-

shop on Algorithm Theory (SWAT ’00). Lecture Notes in Computer Science, vol. 1851, pp. 32–45(2000)

35. Iacono, J.: Alternatives to splay trees with O(logn) worst-case access times. In: Proceedings of the12th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA ’01), pp. 516–522 (2001)

36. Kaplan, H., Landau, S., Verbin, E.: A simpler analysis of Burrows–Wheeler-based compression.Theor. Comput. Sci. 387(3), 220–235 (2007)

37. Karlin, A.R., Phillips, S.J., Raghavan, P.: Markov paging. SIAM J. Comput. 30(3), 906–922 (2000)38. Kenyon, C.: Best-fit bin-packing with random order. In: Proceedings of the 7th Annual ACM-SIAM

Symposium on Discrete Algorithms (SODA ’96), pp. 359–364 (1996)39. Koutsoupias, E., Papadimitriou, C.: Beyond competitive analysis. SIAM J. Comput. 30(1), 300–317

(2000)40. Manzini, G.: An analysis of the Burrows–Wheeler transform. J. ACM 48(3), 407–430 (2001)41. O’Neil, E.J., O’Neil, P.E., Weikum, G.: The LRU-K page replacement algorithm for database disk

buffering. In: ACM SIGMOD Record, vol. 22, pp. 297–306 (1993)42. Panagiotou, K., Souza, A.: On adequate performance measures for paging. In: Proceedings of the 38th

Annual ACM Symposium on Theory of Computing (STOC ’06), pp. 487–496 (2006)43. Reingold, N., Westbrook, J.: Randomized algorithms for the list update problem. Technical Report

YALEU/DCS/TR-804, Yale University (June 1990)44. Reingold, N., Westbrook, J., Sleator, D.D.: Randomized competitive algorithms for the list update

problem. Algorithmica 11(1), 15–32 (1994)45. Schulz, F.: Two new families of list update algorithms. In: Proceedings of the 9th International Sym-

posium on Algorithms and Computation (ISAAC ’98). Lecture Notes in Computer Science, vol. 1533,pp. 99–108 (1998)

Algorithmica

46. Silberschatz, A., Galvin, P.B., Gagne, G.: Operating System Concepts. Wiley, New York (2002)47. Sleator, D.D., Tarjan, R.E.: Amortized efficiency of list update and paging rules. Commun. ACM

28(2), 202–208 (1985)48. Sleator, D.D., Tarjan, R.E.: Self-adjusting binary search trees. J. ACM 32(3), 652–686 (1985)49. Torng, E.: A unified analysis of paging and caching. Algorithmica 20(2), 175–200 (1998)50. New Mexico State University. Homepage of new Mexico state university tracebase (online). Available

at: http://tracebase.nmsu.edu/tracebase.html51. Young, N.E.: The k-server dual and loose competitiveness for paging. Algorithmica 11(6), 525–541

(1994)52. Young, N.E.: Bounding the diffuse adversary. In: Proceedings of the 9th Annual ACM-SIAM Sym-

posium on Discrete Algorithms (SODA ’98), pp. 420–425 (1998)53. Young, N.E.: On-line paging against adversarially biased random inputs. J. Algorithms 37(1), 218–

235 (2000)54. Young, N.E.: On-line file caching. Algorithmica 33(3), 371–383 (2002)