Paging with connections: FIFO strikes again

Similar documents
Calculating lower bounds for caching problems

More on weighted servers

Real-time integrated prefetching and caching

Lecture 8 Sept 25, 2014

Online file caching with rejection penalties

On the online unit clustering problem

Online paging and caching

Algorithmen II. Peter Sanders, Christian Schulz, Simon Gog. Übungen: Michael Axtmann. Institut für Theoretische Informatik, Algorithmik II.

On the Max Coloring Problem

Flexible Coloring. Xiaozhou Li a, Atri Rudra b, Ram Swaminathan a. Abstract

Competitive Analysis of On-line Algorithms for On-demand Data Broadcast Scheduling

A Combined BIT and TIMESTAMP Algorithm for. the List Update Problem. Susanne Albers, Bernhard von Stengel, Ralph Werchner

The hierarchical model for load balancing on two machines

Acyclic Edge Colorings of Graphs

Randomized Weighted Caching. with Two Page Weights. Sandy Irani. Abstract. We consider a special case of the weighted caching problem where

arxiv: v2 [cs.ds] 9 Apr 2009

JOB SHOP SCHEDULING WITH UNIT LENGTH TASKS

ADAPTIVE SORTING WITH AVL TREES

Online algorithms for clustering problems

Lecture Online Algorithms and the k-server problem June 14, 2011

A New and Improved Algorithm for Online Bin Packing

Decreasing the Diameter of Bounded Degree Graphs

Online k-taxi Problem

Randomized Algorithms for Online Matching with Two Sources

Relative Reduced Hops

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

Primality Testing. Public-Key Cryptography needs large prime numbers How can you tell if p is prime? Try dividing p by all smaller integers

Acyclic Edge Colorings of Graphs

Independent Sets in Hypergraphs with. Applications to Routing Via Fixed Paths. y.

7 Distributed Data Management II Caching

Comp Online Algorithms

Superconcentrators of depth 2 and 3; odd levels help (rarely)

On the Performance of Greedy Algorithms in Packet Buffering

Approximation Algorithms for Item Pricing

ON WEIGHTED RECTANGLE PACKING WITH LARGE RESOURCES*

Online Scheduling for Sorting Buffers

From Static to Dynamic Routing: Efficient Transformations of Store-and-Forward Protocols

A Distribution-Sensitive Dictionary with Low Space Overhead

A fast implementation of the optimal off-line algorithm for solving the k-server problem

On the Advice Complexity of Online Problems

A Two-Pass Algorithm for Unordered Colored Bin Packing

6 Distributed data management I Hashing

Abstract. COUNTER algorithms, a family of randomized algorithms for the list update problem, were

Welcome to the course Algorithm Design

Theorem 2.9: nearest addition algorithm

The Rainbow Connection of a Graph Is (at Most) Reciprocal to Its Minimum Degree

IS BINARY ENCODING APPROPRIATE FOR THE PROBLEM-LANGUAGE RELATIONSHIP?

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

Online Scheduling for Sorting Buffers

Operating Systems. Memory: replacement policies

Online Algorithms. - Lecture 4 -

A Primal-Dual Approach for Online Problems. Nikhil Bansal

3 Competitive Dynamic BSTs (January 31 and February 2)

NEW STABILITY RESULTS FOR ADVERSARIAL QUEUING

MEMORY SENSITIVE CACHING IN JAVA

Distributed minimum spanning tree problem

Batch Coloring of Graphs

General properties of staircase and convex dual feasible functions

The strong chromatic number of a graph

Lecture Overview. 2 Online Algorithms. 2.1 Ski rental problem (rent-or-buy) COMPSCI 532: Design and Analysis of Algorithms November 4, 2015

A Guide to Deterministic and Randomized Online Algorithms for the List Access Problem

A SIMPLE APPROXIMATION ALGORITHM FOR NONOVERLAPPING LOCAL ALIGNMENTS (WEIGHTED INDEPENDENT SETS OF AXIS PARALLEL RECTANGLES)

Advanced Algorithms. On-line Algorithms

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

Maximal Monochromatic Geodesics in an Antipodal Coloring of Hypercube

An Optimal Algorithm for the Euclidean Bottleneck Full Steiner Tree Problem

FOUR EDGE-INDEPENDENT SPANNING TREES 1

On the Complexity of the Policy Improvement Algorithm. for Markov Decision Processes

Preemptive Scheduling of Equal-Length Jobs in Polynomial Time

Competitive Buffer Management for Shared-Memory Switches

CS 157 Design and Analysis of Algorithms Valiant. Homework 3

Chordal deletion is fixed-parameter tractable

Report on Cache-Oblivious Priority Queue and Graph Algorithm Applications[1]

ACONCURRENT system may be viewed as a collection of

Comparing the strength of query types in property testing: The case of testing k-colorability

Online Facility Location

Properly Colored Paths and Cycles in Complete Graphs

Competitive Algorithms for Mulitstage Online Scheduling

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

COUNTING THE NUMBER OF WINNING BINARY STRINGS IN THE 1-DIMENSIONAL SAME GAME. Department of Mathematics Oberlin College Oberlin OH 44074

The Competitiveness of On-Line Assignments. Computer Science Department. Raphael Rom. Sun Microsystems. Mountain View CA

Byzantine Consensus in Directed Graphs

On Multi-Stack Boundary Labeling Problems

Lecture 8: The Traveling Salesman Problem

On Rainbow Cycles in Edge Colored Complete Graphs. S. Akbari, O. Etesami, H. Mahini, M. Mahmoody. Abstract

Approximation Algorithms

Algorithm 23 works. Instead of a spanning tree, one can use routing.

On the number of distinct directions of planes determined by n points in R 3

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Dynamic Programming I Date: 10/6/16

The k-server problem June 27, 2005

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17

Efficient Online Strategies for Renting Servers in the Cloud. Shahin Kamali, Alejandro López-Ortiz. University of Waterloo, Canada.

Online Algorithms with Advice

V1.0: Seth Gilbert, V1.1: Steven Halim August 30, Abstract. d(e), and we assume that the distance function is non-negative (i.e., d(x, y) 0).

On-line Steiner Trees in the Euclidean Plane

Lecture 1: An Introduction to Online Algorithms

Maximal Independent Set

K 4,4 e Has No Finite Planar Cover

Transcription:

Paging with connections: FIFO strikes again Leah Epstein a Yanir Kleiman b Jiří Sgall c,1 Rob van Stee d,2 a Department of Mathematics, University of Haifa, 31905 Haifa, Israel. b The Academic College of Tel-Aviv Yaffo, Antokolski 4 61161 Tel-Aviv, Israel. c Mathematical Institute, AS CR, Žitná 25, CZ-11567 Praha 1, Czech Republic, and Dept. of Applied Mathematics, Faculty of Mathematics and Physics, Charles University, Praha. d Department of Computer Science, University of Karlsruhe, P.O. Box 6980, D-76128 Karlsruhe, Germany. Tel. nr. +49-721-6086781, Fax +49-721-6083088 Abstract We continue the study of the integrated document and connection caching problem. We focus on the case where the connection cache has a size of one and show that this problem is not equivalent to standard paging, even if there are only two locations for the pages, by giving the first lower bound that is strictly higher than k for this problem. We then give the first upper bound below the trivial value of 2k for this problem. Our upper bound is k + 4l where l is the number of locations where the requested pages in a phase come from. This algorithm groups pages by location. In each phase, it evicts all pages from one location before moving on to the next location. In contrast, we show that the lru algorithm is not better than 2k-competitive. We also examine the resource augmented model and show that the plain fifo algorithm is optimal for the case h = 2 and all k 2, where h is the size of the offline document cache. We show that also in this case fifo is better than lru, although this is not true for standard paging. Keywords: paging, connection caching, online algorithms Email addresses: lea@math.haifa.ac.il (Leah Epstein), yanirk@gmail.com (Yanir Kleiman), sgall@math.cas.cz (Jiří Sgall), vanstee@ira.uka.de (Rob van Stee). 1 Partially supported by research project MSM0021620838 of MŠMT ČR. 2 Corresponding author. Research supported by the Alexander von Humboldt Foundation. Preprint submitted to Theoretical Computer Science 31 January 2007

1 Introduction The caching problem is one of the major problems in the field of online algorithms. It has been studied considering many different models and aspects of the problem. The basic problem comes from the real world of computing. An operating system has a limited amount of high speed memory and needs to decide which pages of data will be kept in the high speed memory and which pages will be discarded. When a page that was recently discarded is requested again, the operating system pays a significant cost in order to retrieve that page from the low speed memory. This decision must be made with each new request, therefore the solution cannot be pre-computed and must be addressed with an online algorithm. The abstract representation of the problem is as follows. The operating system has k pages of data in its cache. There is no a priori upper bound on the total number of pages that can be requested. An online algorithm is an algorithm that decides after each request which pages to keep in its cache and which pages to discard without knowledge of future requests. The goal is to minimize the number of page faults, i.e. requests to pages while they are not in cache. Connection caching is a version of this problem that deals with a small cache of network connections that has to be maintained in order to access data from different locations. Recently, a combined model was suggested by Albers and van Stee [1]. The model deals with both document caching and connection caching. In this model we have two caches, one that holds documents (or pages) and one that holds connections. The algorithms in [1] perform best if the size of the connection cache is equal to the size of the document cache. However, in practice, the connection cache is usually much smaller. In this article we focus on the case where we have a cache of k pages and only one slot in the connection cache. We call this problem Paging with Connections. In such a model the connection that is stored in the connection cache can be referred to as the (single) current location. There are three types of requests. If the requested page is already in cache, the request costs nothing. If the requested page is not in cache but is from the current location, the request is noted as a page fault (or regular fault) and the cost is one. If the requested page is not in cache and is from a different location, the request is noted as a connection fault and it costs 2, one for switching the connection and another one for putting the requested page in cache. The competitive ratio is the asymptotic worst case ratio between the cost of an online algorithm and the cost of an optimal offline algorithm (denoted by opt) which knows all requests in advance. Throughout the paper we refer 2

to the online algorithm as alg and to the optimal offline algorithm as opt wherever they are mentioned. A generalization of the model is the resource augmentation model. In this model the adversary has less pages in its cache than the online algorithm. This model obviously gives an advantage to the online algorithm and may reduce the competitive ratio. This approach was for instance used by Sleator and Tarjan [12] to give more realistic results for the standard paging problem. Previous work. The classic paging problem. Two common paging algorithms for the classical paging problem are lru (Least Recently Used) and fifo (First In First Out). lru computes for each page which is present in the cache the last time it was used and evicts the page for which this time is minimum. fifo acts like a queue, evicting the page that has spent the longest time in the cache. Variants of both are common in real systems. Although lru outperforms fifo in practice, lru and fifo are known to have the same competitive ratio of k. Further this ratio is known to be the best possible, see [12,10]. The bound k for the standard problem is actually derived directly from a general bound which Sleator and Tarjan [12] showed and which allows resource k augmentation. That is a lower bound of for every online algorithm when k h+1 the caches of opt and alg have sizes of h and k (h k) respectively. They also showed a matching upper bound for lru and fifo. Randomized algorithms. A randomized paging algorithm called mark was introduced in [8] with a competitive ratio of 2H k, where H k is the k-th harmonic number. Randomized algorithms that achieve a better competitive ratio of H k were introduced in [11] and later in [3]. Arbitrary page sizes or costs. In practice not all requested pages are of the same size or cost. Research of models where every page has an arbitrary size was done by Irani [9]. She considered a model where every page has a cost of 1 and a model where every page s cost is equal to its size, and presented randomized online algorithms with a competitive ratio of O(log 2 k) for both models. Young [13] presented a deterministic k-competitive online algorithm for the general case where pages have arbitrary sizes and an arbitrary nonnegative loading cost. Connection caching. Cohen, Kaplan and Zwick [5,6] introduced the connection caching problem, where there is a sequence of requests for TCP connections. Whenever there is a request for a connection that is not open, it must be established. When the cost of opening a connection is uniform over all connections, they presented a k-competitive deterministic online algorithm 3

and a O(H k )-competitive randomized online algorithm, where k is the number of connections that can be simultaneously maintained. The k-competitive deterministic algorithm was developed independently by Cao and Irani [2]. Combined model. As stated above, an integrated document and connection caching model was introduced by Albers and van Stee [1]. Denote the document cache size by k and the connection cache size by k. Their main result is a deterministic algorithm with competitive ratio 2k k + 4. This result is then adapted for other models like randomized algorithms and Irani s models of pages of arbitrary size. It can be seen that the performance guarantee of this algorithms is nearoptimal for a large connection cache, but degrades as the connection cache becomes smaller and is only 2k for a connection cache of size 1. In this paper, we focus on the practically important case of a small connection cache. Specifically, we focus on the case k = 1, i.e. there is only one slot in the connection cache. Albers and van Stee [1] show that lru and fifo perform poorly in this scenario, giving a lower bound of 2k O(1) for these algorithms. fifo versus lru. An issue in the analysis of paging algorithms is the relative performance of fifo and lru. Although lru outperforms fifo in practice, standard competitive analysis cannot distinguish between these two algorithms. This was finally accomplished by Chrobak and Noga [4] using a more refined model. Interestingly, there are several paging models in which the opposite can be shown. One such model was presented by Epstein, Imreh and van Stee [7]. We show in this paper that this role reversal also occurs in paging with connections. New results. We show that this problem is different from the standard paging problem, by showing a lower bound of k+ k 1 for k > 2 and 5 for k = 2. k+1 2 Recall that the best competitive ratio for standard paging is k. Clearly, the k-competitive algorithms for the standard problem are at most 2k-competitive for our model, since each fault costs an algorithm at most 2. We show that lru is not better than this bound. However, fifo achieves a better bound for k = 2, which is the best possible ratio for this case and equals 5. 2 We further design an algorithm which performs much better than lru. Its competitive ratio is k + O(l), where l is the number of different locations. This ratio is k + 8 if there are two locations. We explore the resource augmented problem, where opt has less pages in its cache. We show that in this model as well, our problem is different, since a k lower bound we show is higher than for every h < k. We focus on the k h+1 case h = 2 and show that the tight bound in this case is k+3, achieved by k 4

fifo. This is in contrast to lru that has competitive ratio of exactly k+2 k 1. Notation. A page is denoted by a lower case letter together with zero or more apostrophes, or an index. A location is denoted by a capital letter, which usually (unless stated otherwise) matches the letter of the pages that are at that location. For example, at location A we may have the pages a, a, a 1... We write a state of an algorithm as abc for k = 2, and generalize this in the obvious manner for larger k. When we compare the state of an online algorithm to the state of the offline algorithm, we write the online state first and separate them by a slash. For example abb/aba. If there is an order in which the pages are to be evicted (e.g. in the cache of lru or fifo), then the leftmost page in this writing is first to be evicted, and the rightmost is last. 2 Lower bounds We prove the following theorem, showing that even the problem with k = 1 is not equivalent to the standard paging problem, even if only two distinct locations are present. Theorem 1 Any online algorithm for the paging problem with connections has a competitive ratio at least k + k 1 k+1. Proof. We use two locations and construct a sequence which consists of superphases, where each superphase consists of phases as defined in the sequel. At the time when a superphase starts, opt has pages from a single location in its cache. During the superphase, opt inserts into its cache pages from the other location. A new superphase starts when opt has pages from the other location only. In the beginning of a superphase, both opt and alg are in the same location, the location from which opt has all its pages at that time. We call this location A and the other location B. We next define the phases of a superphase. The length of each phase is at least k. The first phase starts with a request for page b B. This is a page from B that alg does not have in its cache. Let a 1,...,a k denote the pages from A that reside in the cache of opt before the request for b. Every subsequent request of this phase is made for the page in {a 1,...,a k, b} that alg currently does not have in its cache. These requests are made until the earliest time where exactly one page a j {a 1,...,a k } was not yet requested, and this ends the first phase. opt replaces this single page by b in the beginning of the phase, and therefore faults only on b. In this phase, opt has a regular fault as 5

well as a connection fault. In all other phases in this superphase opt will only have one regular fault. Note that alg is not at location B when the first phase ends, since the last request of the phase must be for a page from {a 1,...,a k }. We repeat a similar process until after some phase opt has only pages from B. In this process the first page of a phase is a new page (that is not present in any of the two caches) from B. The rest of the pages are a subset of k 1 pages out of the contents of the cache of opt in the start of the phase. Therefore, except for the beginning of the very first phase, opt has pages of both locations in its cache. At most one page is replaced in the cache of opt in each phase, and thus a superphase lasts at least k phases. Note that at the end of the superphase, both algorithms are connected to B. alg faults on every request, therefore it has at least k regular faults per phase. It is left to count the number of connection faults of alg. In the first phase, alg has a connection fault twice: once at the first request, and another one at the second request, which must be for a page of A. All phases but the last one must have requests for pages of both locations, since once a phase has requests for pages of B only the superphase ends, and each phase has at least one request for a page of B. Let s k be the number of phases. We find a total of at least 1 + 2(s 1) connection faults for alg, and a total cost of at least sk + 2s 1, whereas the total cost of opt is s + 1. We get the ratio sk + 2s 1 s + 1 k + 1 2 s + 1 k + 1 2 k + 1 = k + k 1 k + 1. This concludes the proof. For the cache size equal to 2, we can prove a slightly stronger lower bound. Theorem 2 Any online algorithm with k = 2 slots in the cache has a competitive ratio of at least 5, even if only two locations are allowed. 2 Proof. Denote the two locations by A and B. We start in state abb/aba or abb/a ba. That is, opt has one page from location A in its cache, which may or may not be the same page as the online algorithm has. We show how to return to one of these states in such a way that any online algorithm pays at least 5/2 times the optimal cost. The optimal cost in each such phase is non-zero and bounded by a constant. The cost of reaching such an initial state is also constant. Thus repeating the phase sufficiently many times proves that the competitive ratio is arbitrarily close to 5 2. The main line of the lower bound is as follows (only writing states of the online algorithm): abb a ba A a a aa b a bb or abb. 6

opt serves this request sequence by going to a ba and then back to aba, at cost at most 2 (the cost is 1 if it already had a in its cache). The online algorithm pays 5. Note that the final states are equivalent to the allowed starting states. We now check what happens if the online algorithm deviates from this path at the first or second request. In these cases, the request sequence continues differently. Note that no deviation is possible at the last request. (1) The online state after the first request is a aa. The next request is to b. We go back to a starting state: opt goes to a ba for the first request and stays there. The ratio is 4 : 1. (2) The online state after the second request is baa. opt goes to a aa for the first request and stays there. We now alternate between requests to a and a until the online algorithm goes to a aa as well. Then the next request is to b, followed by a request to the page that the online algorithm drops to serve this request (a or a ). opt goes to location B to serve the request to b, keeping the page that the online algorithm drops in its cache. The final state is thus aba/abb or a ba/a bb, equivalent to second starting state. The overall ratio is at least 8 : 3. Note: if the online algorithm drops b to serve the last request (i.e. it goes back to a aa), we repeat alternating requests to b and the page from A that opt has until it goes to aba or a ba. The ratio only increases. We further show that in contrast to the standard paging problem, the performance of lru is very poor in this model. The competitive ratio of lru is 2k, which can be achieved by any algorithm that uses a marking strategy for the pages and an arbitrary strategy for the connection cache. In particular, lru has a ratio of 4 for k = 2, even using only two locations. This is shown as follows. We start in a state bab/aba, where b is the least recently used page (i.e. the last request was to a and did not cause a fault). The lower bound then works as follows: bab/aba a aa A/a ba b a bb/a ba a ba B/a ba. lru has two connection faults and pays 4. The optimal offline algorithm only pays 1 (for the first request). The final state is equivalent to the starting state. The generalization for general k is as follows. Let a, b 1,...,b k 1 be k pages from k distinct locations. We denote the location of a by A. Let a A as well. The initial state of a phase is b 1 b 2... b k 1 ax/b 1 b 2...b k 1 aa, 7

where X is the location of b k 1. The phase consists of requests for a, b 1,...,b k 1, a. All requests but the last one are both regular and connection faults. Starting from the first request, each of the pages b i, i = 1,...,k 1 are evicted and reloaded in the next step. The last step changes the priority of a. The phase ends at the equivalent state b 1 b 2...b k 1 a X/b 1 b 2...b k 1 a A. opt has a single regular fault, whereas lru has k regular faults and k connection faults. Therefore the competitive ratio of lru is 2k. Note that this example can be implemented using only two locations for even k and three for odd k. 3 Algorithms In this section we introduce the first algorithms for paging with connections with a competitive ratio strictly smaller than 2k for the case where the number of network locations is less than k/4. We first describe an algorithm for the case where all requests come from only two locations, and then show how to generalize this algorithm for more locations. 3.1 Algorithm TwoLocations Denote the location of the very first request by A and the other location by B. On any page fault, first, if all pages are marked, unmark all pages and start a new phase. Second, evict an unmarked page from A if possible. Otherwise evict the unmarked page which has been in the cache the longest. Load the requested page and mark it. Note that pages are only marked when a page fault occurs. Thus this algorithm is not a marking algorithm in the classical sense. In particular, a phase might last longer than that of a marking algorithm, but all we need is that a phase contains requests to k distinct pages, so that each algorithm (in particular the optimal one) must fault at least once per phase. Definition A new page is a page which was not requested in the previous phase. Claim 1 In any phase, the number of connection faults is at most four times the number of new pages requested. 8

Proof. Consider a request sequence. Since TwoLocations does not change its state in response to requests that do not cause faults for it, we begin by removing any requests that do not cause faults. This can only decrease the optimal cost to serve this sequence. Thus we may assume that each request causes a fault for the algorithm TwoLocations. Pages from B are not evicted until all pages from A which were requested in the previous phase have been evicted. Say that the first eviction of a page at B happens at the rth fault. This implies that in the previous phase, r 1 pages from A were requested. We are going to assign connection faults to new pages, depending on when the connection faults occur, as follows: (1) To the first new page (that starts the phase), the connection fault that possibly occurs on this request, and the one that possibly occurs on the first request to an old page from B (2) Up to request r, at most two connection faults to each new page from B (3) After request r, at most two connection faults to each new page requested up to and including request r (from A or B), apart from the first new page (4) After request r, at most two connection faults to each new page from A Thus each new page is assigned at most four connection faults. We now explain that this covers all the connection faults that may occur in the phase. The first request may obviously cause a connection fault, as may the first request to an old page from B. This is handled in Step 1. If no other new pages are requested, these are all the connection faults that occur, since in this case first all the old pages from A are requested and then all the old pages from B. Consider a request no later than r. At this point, no old pages from B can be requested, because they are all still in the cache and each request causes a fault. Only old pages from A can be requested (and, of course, new pages from anywhere). If this page fault causes a connection fault, the request must be to a new page from B, or to a page from A (either old or new) immediately after a new page from B was requested. This is handled in Step 2. Consider a request after the rth request. Suppose that in the first r requests, there were b requests to a (new) page from B. Then there were r b requests to pages from A. Denote the number of requests to new pages from A by a. We have a 1 because the first request, that started this phase, must be to a new page. 9

In the first r requests, there were r b a requests to old pages from A. Since there exist r 1 old pages from A, this means that b + a 1 old pages from A are not yet requested in the current phase at this point. In the worst case, these are requested alternatingly with old pages from B now, leading to at most 2(b + a 1) additional connection faults. These are assigned to the b + a 1 new pages in the requests 2,...,r in Step 3. Finally, connection faults can also occur if new pages from A are requested after the rth request. Each such page can cause two connection faults: one to switch to A and one to switch back (which can happen on an old page from B). This is handled in Step 4. This completes the proof. Theorem 3 TwoLocations (TL) has a competitive ratio of at most k + 8. Proof. Denote the number of new pages in phase i by p i. Denote the cost of algorithm A in phase i by A(i). In phases i 1 and i, k + p i distinct pages are requested. Thus opt(i 1) + opt(i) p i for all i > 1. Summing over all even phases i > 1, we have opt i even p i. We have opt(1) p 1 since by assumption opt and TL start with the same cache contents. So summing over the odd phases gives opt i odd p i. This implies that 2opt i p i. Additionally, we have as usual opt n where n is the number of phases. On the other hand, by Claim 1 we have TL(i) k + 4p i. Thus overall, we have TL nk + 4 p i kopt + 8opt = (k + 8)opt. This completes the proof. 3.2 A generalized algorithm: Evict By Location (EBL) This algorithm works in phases. During a phase, a page is marked if a request to this page caused a fault. Only unmarked pages are evicted, and only if there is a page fault. If there is a page fault and all pages are marked, all pages are unmarked and a new phase begins. At the start of a new phase, group the pages in the cache by their locations. Sort the locations in any order, but start with the location of the current request (which starts this phase). Denote the locations by A 1, A 2,... in this order. During a phase, evict all pages from A i before evicting any page from A i+1, for any i. 10

Theorem 4 The algorithm EBL has a competitive ratio of at most k +4l for an environment with l locations. Proof. We divide the phase into subphases according to the grouping defined above. In subphase i, only pages from A i are evicted. Denote the length of subphase i by k i. We generalize the connection faults assignment from the proof of TwoLocations, and prove that the connection faults can be assigned so that any new page requested in a phase is assigned at most 4l connection faults, where l is the number of different locations requested in this phase. (1) To the first new page in the phase, we assign the first connection fault from each subphase (2) In subphase i, to new pages that are not from A i we assign at most two connection faults in subphases i,..., l (3) In subphase i, to new pages from A i we assign at most two connection faults in subphases i + 1,..., l For each i, the first request in subphase i is not to an old page of A i, because all of them are still in the cache at this point. The second request in subphase i (or the first one to A i ) will cause a connection fault. This is handled in Step 1 (note that the first page requested in the phase is new). Consider subphase 1. All old pages from A 2,... are still in cache. Some old pages in A 1 may be out. Any new page not from A 1 can cause a connection fault, plus another one if the next request is for A 1 again. See Step 2. Suppose there are a 1 such pages. Denote the number of new pages from A 1 by a 1 1. (Note that the first page in this phase is new.) Then after subphase 1, there are still a 1 +a 1 old pages from A 1 which have not been requested in the current phase. We call these pages late. In subphase 2, all old pages from A 3 and later are still in the cache. Some old pages in A 1 and A 2 may be out. Denote the number of new pages requested in this subphase which are not from A 2 by a 2. Each such page can cause two connection faults in this subphase (Step 2). This also holds for the a 1 +a 1 late pages from A 1, if they are requested in subphase 2. Since these correspond to new pages requested in subphase 1, the connection faults are assigned to those new pages (Step 3). Finally, there are a 2 new pages from A 2, which do not cause connection faults in the current subphase, but instead cause late pages. In fact, any request out of these three categories corresponds to one old page from A 2 which is not requested in this subphase, and which might still be requested later and cause extra connection faults (Step 2 and 3). Generally, it may be seen that in each subphase, each new page requested corresponds in a one-to-one fashion to an old page which is not requested in its proper subphase. This concludes the explanation of the assignment procedure. 11

Denoting the number of new pages in subphase j of phase i by n ij, we find that l l ebl (i) k + 2n ij (l + 1 j) k + 2l n ij. j=1 Here we have used that in any phase, l j=1 n ij 1. On the other hand, opt(i 1) + opt(i) l j=1 n ij, and opt n where n is the number of phases. Thus n l ebl kn + 2l n ij kopt + 4lopt = (k + 4l)opt. i=1 j=1 This completes the proof. j=1 4 Resource Augmentation In this section we consider the case where the document cache of opt has size 2 h k. Recall that the tight bound on the competitive ratio in the standard model is k. k h+1 We begin by giving a lower bound for the case h < k. A lower bound for h = k is given by Theorem 1. An interesting question is whether the competitive ratio for the problem with locations tends to 1 when k grows. In this section we show that the tight ratio for the case h = 2 is k+3 and thus it is slightly k worse but still tends to 1. We show that this ratio is achieved by fifo, whereas the competitive ratio of lru is exactly k+2. k 1 Theorem 5 The competitive ratio of any online algorithm, such that the algorithm has k slots in its cache and opt has 2 h < k slots is at least k + 2 + h 1 k h+1. k h + 2 This number is strictly higher than k h+1 k for any h < k. Proof. We use phases. The only requirement for the starting state is that alg is in a different location than opt. We denote the pages of opt by a 1, a 2,...,a h (though they may be from different locations) and the location of opt by B. We issue requests for the following sequence of pages: b 1, b 2,..., b k h B. These pages have in common that none of them appear in either the cache of opt or the cache of alg. 12

After k h such requests there is a request for a page p which is from a different location than all the pages in the caches of opt and alg. Every next step after that, alg has in its cache k pages, thus at least one of the pages q i {a 1, a 2,...,a h, b 1, b 2,...,b k h, p} is not present in its cache. The next request will be issued for page q i. We issue such requests until at least h 1 different pages, not including page p, are requested. opt can choose the pages it discards, so after the first k h requests and the request for page p it will have in its cache page p and the h 1 unique pages that were requested after it. Thus it does not pay for any request after the request for p. Since there are at least h 1 requests after the request for page p, there are at least k requests in the phase. alg pays at least 1 for any of the requests we issued. It pays 2 for at least three requests: The request for page b 1 (the first request), the request for page p and the request for page q 1 which must be from a different location from page p. In total alg pays at least k + 3 for the whole sequence. opt pays only 1 for each of the first k h requests and another 2 for the request for page p, to a total of k h + 2. For large values of h, we can improve the estimate for the cost of alg by taking into consideration the maximum amount of pages from the same location that alg has in its cache. Since opt uses a sequence of k h pages from the location where it was at the start of the phase, throughout the scheme we need only a maximum of k h + 1 pages from each location. Therefore alg has to move to a different location at least every k h + 1 pages. This move costs alg 2 instead of 1 and it occurs h 1 k h+1 holds pages from at least h 1 k h+1 times. In other words, the cache of alg different locations. Hence alg pays at least k + 2 + h 1 and the lower bound is proved. k h+1 k This lower bound is slightly larger than for all values of h < k. Note k h+1 that the proof fails for k = h since in this case there are no initial requests in the phase. 4.1 The case h = 2 For this case, we show matching upper and lower bounds. The optimal upper bound is achieved by fifo. Additionally, we prove that the algorithm lru performs strictly worse than fifo even for h = 2, and give tight bounds on its competitive ratio. Theorem 6 Any online algorithm with k 2 slots in the cache has a competitive ratio of at least k+3 when compared to an offline algorithm with 2 slots k 13

in the cache. Proof. For k > 3, this follows directly from Theorem 5. For k = 2, this is Theorem 2. Theorem 7 The competitive ratio of fifo for h = 2 is k+3 k. Proof. The lower bound was proved in Theorem 6. Consider now a sequence of requests. Since in fifo only faults change the behavior, we are only interested in requests that were faults of fifo, and remove all other requests form the sequence (this may only increase the cost of opt and does not change the cost of fifo). We use the names bad fault for a fault of fifo which is not a fault of opt and good fault for a fault of both opt and fifo. A bad fault is a fault that raises the competitive ratio of fifo and a good fault is a fault that helps fifo maintain a low competitive ratio because opt pays for it as well. We define a phase to be a sequence of faults which starts with a bad fault and ends one request before the next bad fault. In other words, the first request in the phase is a bad fault and the other faults in the same phase, if any, are all good faults. We begin by giving a lower bound of k on the length of any phase. Let p be a request which causes a bad fault, and let q denote the previous request. Already before the request for page p, opt must have in its cache page q that was just requested and page p. Just after p is requested, fifo has in its cache pages p, q and k 2 older pages. If the next bad fault will be on page q it has to occur after at least k 1 faults in order for page q to be discarded by fifo. Similarly, for the next bad fault to be on page p it has to occur after at least k good faults. For the next bad fault to be on a different page, it must occur after at least k + 1 good faults since one good fault is necessary to put the new page in the cache of opt, and afterwards it takes k faults for fifo to discard it. This shows that in all cases, there are at least k 1 good faults after the bad fault that starts the phase. The bad faults cost a maximum of 2 for fifo and nothing for opt. The first good fault may cost 2 for fifo and only 1 for opt. After that both of the algorithms are in the same location, so the next k 2 faults costs the same for fifo and opt. The worst case occurs if all these faults cost 1. In this case fifo pays k +2 and opt pays k 1. We will call a phase with this exact ratio a bad phase for fifo. However, during a bad phase opt does not change its location. Moreover, the next phase starts with a request for page q. This request must be a fault of opt. This is true since for k 2, by definition of fifo, any three consecutive requests must be distinct, therefore, among two consecutive requests, at least 14

one is a fault. Since the first request for page q was a fault of opt (since the request just after it, which is for p is not a fault of opt), opt is still in the location of page q, and so is fifo which is in the same location. Therefore in any phase which immediately follows a bad phase, fifo only pays 1 for the first request, and the same as opt for the remaining requests since they are still in the same location. The ratio of the costs in this phase is at most k : (k 1). This is a good phase for fifo. Every bad phase must be followed by at least one good phase, which yields an average ratio of (2k + 2) : (2k) = (k + 1) : k or even better. To avoid good phases, opt must either change the connection or prolong the phase so another page will be requested in the beginning of the next phase. To change its connection opt must at some point suffer a cost of 2 instead of 1, thus raising its total cost to k. Such a change of connection may cost fifo 2 instead of 1 if done on one of the last k 2 requests, or nothing extra if done on the second request for which fifo already pays 2. Therefore the maximum cost fifo will suffer in this case will be k + 3 instead of k + 2 and the ratio of the phase is (k + 3) : k. We will call such a phase a normal phase. If opt does not change its location, the phase must be prolonged by at least one request. If the phase is prolonged by exactly one request the bad fault will again be the request for page p, and therefore the next phase may be a bad phase or a normal phase. In the prolonged phase, the cost of both opt and fifo is increased by one or two so the ratio of the phase is also (k + 3) : k. This is also a normal phase. Since for every additional request opt and fifo pays the same, prolonging the phase by more than one request will yield a ratio lower than (k + 3) : k. Considering the entire request sequence, the average cost ratio is at most (k + 1) : k in good and bad phases (since there are at least as many good phases as bad phases) and at most (k + 3) : k in normal phases. This proves the upper bound. Finally, we consider the performance of the algorithm lru for the case h = 2. We start with an example where lru achieves a ratio not better than k+2, k 1 and then show a matching upper bound. This is worse than the upper bound of fifo. The example holds for k > 2, an example for k = 2 was given earlier. Finally, we prove the following theorem. Theorem 8 The competitive ratio of lru for h = 2 is exactly k+2, which is k 1 strictly worse than fifo. 15

Proof. We first show the lower bound. For simplicity, let a 1,...,a k 1, a k = a 0 be pages from a location A, and a be a page of location A. The initial state of a phase is a 1 a 2...a k 2 ba k 1 B/a k 1 ba. The phase starts with requests for a k, a 1,...,a k 2. At this time lru does not have b in its cache anymore and this is the next request. The last request is for a k 2. This is not a fault for any of the two algorithms, but it changes the state of lru which is now a k a 1... a k 3 ba k 2 B. opt is in the state a k 2 ba, it had k 1 regular faults on the first k 1 requests. Note that opt never changes its location. lru has a connection fault on the first page of a phase and on b. It has regular faults on all requests but the last one. Therefore the costs of lru are k + 2 and the optimal cost is k 1. Note that the state we reached at the end of a phase is equivalent to the initial one. We now prove the upper bound. We use terminology similar to the proof of Theorem 7, only here we cannot assume that all requests are faults for the algorithm, therefore there are good faults, bad faults and non-faults which are requests that are not a fault for any of the two algorithms, and excellent faults which are faults of opt but not of the algorithm. A change that we do in the sequence without changing the operation of lru or the cost is removal of all requests but one, in sub-sequences of consecutive identical requests. A phase is the sub-sequence of requests, from the time that a bad fault occurs, until just before the next such time. Similarly to the proof for fifo, we denote the first request in a phase by p and the request just before that by q. opt must have had a fault on q. Otherwise the request just before q, r, must be identical to p or to q. Since we removed multiple consecutive instances of the same request, it must be p. However, if p appeared just before q, it is still in the cache of lru, and cannot be a fault of lru. After the first good fault and until the end of the phase, lru pays no more than opt. This can be seen as follows. Immediately after the good fault, lru and opt are at the same location. This does not change as long as there are good faults. There can be no bad faults by definition. lru and opt pay the same as long as they remain at the same location. If opt changes its location and lru does not, this happens on a request that is not a fault for lru. The cost that opt has for this fault can be assigned to the first good fault that follows. Note that we showed above that the phase ends in a good fault. This shows that lru does not pay more than opt after its first good fault. Between the bad fault that starts the phase and the first good fault, lru pays nothing. However lru possibly pays two more than opt for the bad fault that starts the phase, and one more than opt for the first good fault. Thus 16

its overall cost for the phase is at most 3 more than OPT. Denote the page that starts the next phase (i.e. causes a bad fault) by p. After the last time that p is requested, opt keeps p in its cache (otherwise it would not have a reason to load it again before the next request to p, and that means that would not be a bad fault). From this point on, opt can at most serve the very next request without a fault, but after that it has to fault on every request since it has only one free slot in the cache. There are at least k requests until lru drops p, so opt pays at least k 1 (more if there are also connection faults). Note that p may be p or q. This completes the proof. 5 Conclusions We have shown the first algorithms for paging with connections that break the trivial performance bound of 2k. An open question left by these results is the precise role that the locations play in this model. All our lower bounds require only two or three locations, and it is unclear whether using more locations can improve these results. However, it is possible that the competitive ratio of an adaptation of our algorithm EBL is smaller than 2k even for a large number of locations. The idea is to define the size of a location at the time when a phase starts as the number of pages from this location which are present in the cache of the algorithm. Then we use a sorted list of locations (largest location first). References [1] Susanne Albers and Rob van Stee. A study of integrated document and connection caching. In Automata, Languages and Programming, 30th International Colloquium, ICALP 2003, Proceedings, pages 653-667, 2003. [2] Pei Cao and Sandy Irani. Cost-aware www proxy caching algorithms. In USENIX Symposium on Internet Technologies and Systems, 1997. [3] Dimitris Achlioptas, Marek Chrobak and John Noga. Competitive analysis of randomized paging algorithms. Theoretical Computer Science, 234:203-218, 2000. [4] Marek Chrobak and John Noga. LRU is better than FIFO. Algorithmica, 23:180 185, 1999. 17

[5] Edith Cohen, Haim Kaplan and Uri Zwick. Connection caching. In Preceedings of the 31st ACM Symposium on the Theory of Computing, pages 612-621. ACM, 1999. [6] Edith Cohen, Haim Kaplan and Uri Zwick. Connection caching under various models of communication. In Preceedings of the Twelfth ACM Symposium on Parallel Algorithms and Architectures, pages 54-63. ACM, 2000. [7] Leah Epstein, Csanad Imreh, and Rob van Stee. More on weighted servers or FIFO is better than LRU. Theoretical Computer Science, 306(1-3):305 317, 2003. [8] Amos Fiat, Richard Karp, Michael Luby, Lyle A. McGeoch, Daniel Sleator and Neal E. Young. Competitive paging algorithms. Journal of Algorithms, 12(4):685-699, Dec 1991. [9] Sandy Irani. Page replacement with multi-size pages and applications to web caching. In Preceedings of the 29th ACM Symposium on the Theory of Computing, pages 701-710, 1997. [10] Anna Karlin, Mark Manasse, Lyle Rudolph, and Daniel Sleator. Competitive snoopy caching. Algorithmica, 3:79 119, 1988. [11] Lyle McGeoch and Daniel Sleator. A strongly competitive randomized paging algorithm. J. Algorithms, 6:816-825, 1991. [12] Daniel Sleator and Robert E. Tarjan. Amoritzed efficiency of list update and paging rules. Communications of the ACM, 28:202-208, 1985 [13] Neal E. Young. On-line file caching. In Proceedings of the 9th ACM-SIAM Symposium on Discrete Algorithms, pages 82-86, 1998. 18