Department of Mathematics, London School of Economics and Political Science, [email protected] funding from the following sources: NSERC grant 327620-09 and an NSERC DAS Award, European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement no. ScaleOpt–757481), and Dutch Research Council NWO Vidi Grant 016.Vidi.189.087. Google Research, [email protected] Google Research, USA Google Research, [email protected] Google Research, [email protected] \CopyrightSharat Ibrahimpur, Manish Purohit, Zoya Svitkina, Erik Vee, and Joshua R. Wang \ccsdescTheory of computation Caching and paging algorithms \relatedversion \EventEditorsKousha Etessami, Uriel Feige, and Gabriele Puppis \EventNoEds3 \EventLongTitle50th International Colloquium on Automata, Languages, and Programming (ICALP 2023) \EventShortTitleICALP 2023 \EventAcronymICALP \EventYear2023 \EventDateJuly 10–14, 2023 \EventLocationPaderborn, Germany \EventLogo \SeriesVolume261 \ArticleNo91
Efficient Caching with Reserves via Marking111An extended abstract is to appear in the Proceedings of the 50th ICALP, 2023.
Abstract
Online caching is among the most fundamental and well-studied problems in the area of online algorithms. Innovative algorithmic ideas and analysis — including potential functions and primal-dual techniques — give insight into this still-growing area. Here, we introduce a new analysis technique that first uses a potential function to upper bound the cost of an online algorithm and then pairs that with a new dual-fitting strategy to lower bound the cost of an offline optimal algorithm. We apply these techniques to the Caching with Reserves problem recently introduced by Ibrahimpur et al. [10] and give an -competitive fractional online algorithm via a marking strategy, where denotes the size of the cache. We also design a new online rounding algorithm that runs in polynomial time to obtain an -competitive randomized integral algorithm. Additionally, we provide a new, simple proof for randomized marking for the classical unweighted paging problem.
keywords:
Approximation Algorithms, Online Algorithms, Cachingcategory:
1 Introduction
Caching is a critical component in many computer systems, including computer networks, distributed systems, and web applications. The idea behind caching is simple: store frequently used data items in a cache so that subsequent requests can be served directly from the cache to reduce the resources required for data retrieval. In the classical unweighted caching problem, a sequence of page requests arrives one-by-one and an algorithm is required to maintain a small set of pages to hold in the cache so that the number of requests not served from the cache is minimized.
Traditional caching algorithms, both in theory and practice, are designed to optimize the global efficiency of the system and aim to maximize the hit rate, i.e., fraction of requests that are served from the cache. However, such a viewpoint is not particularly suitable for cache management in a multi-user or multi-processor environment. Many cloud computing services allow multiple users to share the same physical workstations and thereby share the caching system. In such multi-user environments, traditional caching policies can lead to undesirable outcomes as some users may not be able to reap any benefits of the cache at all. Recently, Ibrahimpur et al. [10] introduced the Caching with Reserves model that ensures certain user-level fairness guarantees while still attempting to maximize the global efficiency of the system. In this formulation, a cache of size is shared among agents and each agent is guaranteed a reserved cache size of . An algorithm then attempts to minimize the total number of requests that are not served from the cache while guaranteeing that any time step, each agent holds at least pages in the cache. Unlike the classical paging problem, Caching with Reserves is NP-complete even in the offline setting when the algorithm knows the entire page request sequence ahead of time and Ibrahimpur et al. [10] gave a 2-approximation algorithm. They also gave an -competitive online fractional algorithm for Caching with Reserves via a primal-dual technique and then design a rounding scheme to obtain an -competitive online randomized algorithm. Unfortunately, the rounding scheme presented in [10] does not run in polynomial time and the fractional primal-dual algorithm, while simple to state, also does not yield itself to easy implementation.
Caching and its many variants have been among the most well-studied problems in theoretical computer science. It has long been a testbed for novel algorithmic and analysis techniques and it has been investigated via general techniques such as potential function analysis, primal-dual algorithms, and even learning-augmented algorithms. For the classical unweighted caching problem, a particularly simple algorithm, randomized marking [9], is known to yield the optimal competitive ratio (up to constant factors). At any point in time, the randomized marking algorithm partitions the set of pages in cache into marked and unmarked pages and upon a cache miss, it evicts an unmarked page chosen uniformly at random. Cache hits and pages brought into the cache are marked. When a cache miss occurs, but there are no more unmarked pages, a new phase begins, and all pages in the cache become unmarked. In this paper, we build upon this algorithm, adapting it to caching with reserves.
Our Contributions
We study the Caching with Reserves model of Ibrahimpur et al. [10] in the online setting and improve upon those results. Our first main result is a simpler fractional algorithm that is a generalization of randomized marking for classical caching.
Theorem 1.1.
There is an -competitive fractional marking algorithm for online Caching with Reserves. The competitive guarantee holds even when the optimal offline algorithm is allowed to hold fractional pages in the cache.
We remark that our algorithm in Theorem 1.1 and its analysis are more involved than those of the classical randomized marking algorithm. One complication is that due to the reserve constraints, a marking-style algorithm for the caching with reserves setting cannot evict an arbitrary unmarked page. Another key difficulty comes from the fact that even the notion of a phase is non-trivial to define in our setting. In particular, unlike in classical caching, it can happen that the cache still contains unmarked pages, but none of them can be evicted to make space for a new page, because of the reserve constraints. Thus, we need a rule to isolate agents whose reserve constraints prevent the algorithm from having a clean end of a phase, while also ensuring that the already marked pages of such isolated agents are not erased prematurely. To this end, we introduce the notion of global and local phases to effectively model the state of each agent. We elaborate on this in Section 3.1.
Our analysis of the fractional marking algorithm introduces two novel components that may be of independent interest. First, we upper-bound the total cost incurred by our fractional marking algorithm using a new potential function. This potential function, introduced in Section 3.3, depends only on the decisions of the algorithm and is independent of the optimal solution. To the best of our knowledge, all previous potential function based analyses of (variants of) caching [4, 5, 6, 10] define a potential function that depends on the optimal solution. Second, we introduce a new lower bound for the cost of the optimal solution via the dual-fitting method. Our techniques also yield a new simple proof that the classical randomized marking [9] for unweighted paging is -competitive (see Appendix A).
We also design a new online rounding algorithm that converts a deterministic, fractional algorithm into a randomized, integral algorithm while only incurring a constant factor loss in the competitive ratio. Via a careful discretization technique (inspired by Adamaszek et al. [2]), the new rounding algorithm runs in polynomial time and only uses limited randomization. Our fractional marking algorithm (Algorithm 1) maintains that at any point in time, a particular page is either completely in the cache or at least fraction of the page has been evicted. We exploit this key property to show that the fractional solution at any time can be discretized so that the fraction of any page that is evicted is an integral multiple of . This discretization allows us to maintain a distribution over feasible integer cache states with bounded support.
Theorem 1.2.
There is a polynomial-time -competitive randomized integral algorithm for online caching with reserves.
Other Related Work
The unweighted caching (also known as paging) problem has been widely studied and its optimal competitive ratio is well-understood even up to constant factors. Tight algorithms [1, 13] are known that yield a competitive ratio of exactly , where is the th harmonic number. Recently, Agrawal et al. [3] consider the parallel paging model where a common cache is shared among agents – each agent is presented with a request sequence of pages and the algorithm must decide how to partition the cache among agents at any time. It allows the processors to make progress simultaneously, i.e., incur cache hits and misses concurrently. Multi-agent paging has also been extensively studied in the systems community [7, 15, 16] often in the context of caching in multi-core systems. Closely related to the Caching with Reserves setting, motivated by fairness constraints in multi-agent settings, a number of recent systems [11, 12, 14, 17] aim to provide isolation guarantees to each user, i.e., guarantee that the cache hit rate for each user is at least as much as what it would be if each user is allocated its own isolated cache. Also motivated by fairness constraints, Chiplunkar et al. [8] consider the Min-Max paging problem where the goal is to minimize the maximum number of page faults incurred by any agent.
2 Preliminaries and Notation
Formally, an instance of the Caching with Reserves problem consists of the following. We are given a number of agents and a total (integer) cache capacity . Let denote the set . Each agent owns a set of pages (referred to as -pages) and has a reserved cache size . Pages have a unique owner, i.e. for all , and we use to refer to the universe of all pages. For any page , let be the unique agent that owns . We assume without loss of generality that at least one unit of cache is not reserved: .222If all of cache is reserved, the problem decomposes over agents into the standard caching task. At each timestep , a page is requested. We can wrap all these into an instance tuple: .
An integral algorithm for the Caching with Reserves problem maintains a set of pages in the cache such that for each agent , the cache always contains at least pages from . At time , the page request is revealed to the algorithm. If this page is not currently in the cache, then the algorithm is said to incur a cache miss and it must fetch into the cache by possibly evicting another page . For any (integral) algorithm we write its total cache misses on instance as .
A fractional algorithm for the Caching with Reserves problem maintains a fraction for how much each page is in the cache such that the total size of pages in the cache is at most , i.e, , and the total size of -pages is at least , i.e., . At time , the page request is revealed to the algorithm, which incurs a fractional cache miss of size . The algorithm must then fully fetch into cache () by possibly evicting other pages. For any (fractional) algorithm we again write its total size of cache misses on instance as .
Let be the cost of the optimal offline algorithm on instance .
Definition 2.1 (Competitive Ratio).
An online algorithm for Caching with Reserves is said to be -competitive, if for any instance , , where is a constant independent of the number of page requests in . The expectation is taken over all the random choices made by the algorithm (if any).
3 Fractional -Competitive Algorithm for Caching with Reserves
For any time and page , the algorithm maintains a variable representing the portion of page that is outside the cache. Then represents the portion of that is in cache. Algorithm 1 ensures feasibility at all times : the total of all values is exactly the complementary cache size , i.e., ; and the total value for pages of any agent is within its respective complementary reserve size, . When a request for page arrives at time , the algorithm fully fetches into the cache by paying a fetch-cost of while simultaneously evicting a total of amount of other suitably chosen pages.
3.1 Fractional Algorithm
The complete algorithm (referred to as Algorithm in the proofs) is presented in Algorithm 1. We present a high-level discussion here. At any time , we say that an agent is tight if , i.e., the algorithm is not allowed to further evict any pages (even fractionally) of agent . Conversely, an agent is non-tight if .
The algorithm is a fractional marking algorithm and runs in phases where each phase corresponds to a maximal sequence of page requests that can be served while maintaining feasibility and ensuring that no “marked” pages are evicted. Within each phase, the currently requested page is fully fetched into cache by continuously evicting an infinitesimal amount of an “available” (described below) unmarked page with the smallest value; if there are multiple choices of , then all of them are simultaneously evicted at the same rate. Page gets marked after it has been served and this mark may only be erased at the end of a phase.
At the end of a phase, an agent is designated as isolated if strictly fewer than -pages are marked in the cache at this time point. This designation changes to non-isolated as soon as -pages get marked at some point in the future. An isolated agent essentially runs a separate instance of caching on its own pages and in its own reserved space. At the end of a phase, the marks of pages owned by non-isolated agents (i.e., agents with at least marked -pages) are erased.
It remains to describe when a page is considered available for eviction. Clearly, must hold, since otherwise page is already fully outside the cache. Moreover, must be non-tight, i.e., evicting page must not violate the reserve constraint of the agent that owns it. The last condition for to be considered available for eviction depends on whether the agent is isolated or not: (i) if agent is isolated, then should hold, i.e., only unmarked -pages are available for eviction; and (ii) if agent is not isolated, then should also be non-isolated. We recall again that among all available pages for eviction, pages with the smallest value are evicted first.
Notation
Let denote the set of isolated agents at time . For a global phase , we use to denote the set of isolated agents at the end of phase . Let denote the set of tight agents at time . At any time , let denote the value of the local phase counter for agent , and let be the total number of local phases for agent . By definition, for any agent , and denote the set of -pages in the cache (integrally) at the beginning of the th local phase and the end of the th local phase for agent , respectively. For any agent , let denote the set of marked -pages in the cache and denote the set of unmarked -pages.
We emphasize that the notion of pages will only be relevant while referring to pages in for some ; in particular, every -page is not , but we do not refer to it as . Analogous to the notion of clean and stale pages used by the randomized marking algorithm [9], we define clean, pseudo-clean and stale pages as follows. Fix an agent and let be its local phase counter at time . Any -page is considered stale. The currently requested page is said to be clean if . Next, we say that the currently requested page is pseudo-clean if and holds right before Algorithm starts to fetch into the cache. Lemmas 3.6 and 3.8 show that a pseudo-clean page necessarily belongs to an agent who was isolated at the start of (global) phase but is non-isolated at time . To simplify notation, we drop the superscript from all notation whenever the time index is clear from the context.
The following lemma compiles a list of key invariants that are maintained throughout the execution of the algorithm that follow directly from an examination of Algorithm 1.
Lemma 3.1.
Algorithm 1 maintains the following invariants.
-
(i)
When a new phase begins, all marked pages belong to isolated agents.
-
(ii)
At any time , all isolated agents are tight.
-
(iii)
At any time and for any agent , all unmarked pages of agent have the same value.
-
(iv)
Any page belonging to an isolated agent is (fractionally) evicted only in those timesteps when a different page of the same agent has been requested.
The following lemmas show that the algorithm is well-defined and that the operations in Lines 1 and 1 of Algorithm 1 are always feasible.
Lemma 3.2.
If the requested page has and agent is isolated, then can be fetched fully by evicting unmarked pages of agent .
Proof 3.3.
Lemma 3.4.
Proof 3.5.
Suppose page is fetched in a continuous manner. To show that page can be fetched fully, it suffices to show that at any instantaneous time when , there always exists an unmarked page belonging to a non-tight agent such that , i.e. page can be evicted. Observe that . Due to integrality of and , we must have is an integer. Since any marked page always has , is also an integer. Further, since and , we must have and hence there exists a page belonging to some non-tight agent with as desired.
Since we always evict an available page with the least value, at any time step , all available pages (i.e., unmarked pages belonging to non-tight agents and satisfying ) have the same value at all times. We denote this common -value by and refer to the corresponding set of evictable pages (with -value ) as the frontier. The following two key structural lemmas formalize this property.
Lemma 3.6.
At any time , let be an agent that was isolated at the beginning of the current phase, and let be one of its unmarked pages. Then if and only if is still isolated at time .
Proof 3.7.
For the if direction, suppose that is still isolated. By invariant (ii), it is also tight. By invariant (iii), all its unmarked pages have the same -value and in total they occupy units of cache space. Thus, and .
For the only if direction, suppose that is no longer isolated. Just before the th -page to be marked was requested, -pages were marked. Since was tight, the total value of all its unmarked pages must have been 1. Then the algorithm replaced all of them with the th marked page, and the -value of all remaining unmarked pages became . Thus, the property holds for a newly non-isolated agent . This property continues to hold for the rest of the phase since never decreases for an unmarked page.
Lemma 3.8.
At any time , there is a value such that: for any agent that was non-isolated at the beginning of the current phase and any unmarked -page , holds and holds whenever is non-tight.
Proof 3.9.
We prove the lemma by induction. Clearly, the lemma holds at the start of the phase: all unmarked pages belonging to non-isolated agents have -value . Now consider a time during phase such that the lemma holds for all timepoints before in this phase. We may also assume that , since otherwise none of the variables are modified in this timestep.
By induction hypothesis, any unmarked -page satisfies , and this inequality is tight whenever is non-tight. If agent is non-tight, then its unmarked pages are already part of the frontier. Otherwise, Algorithm fetches fully into the cache by increasing the -value of other unmarked -pages until one of the following happens: (a) is fully fetched. In this case, continues to remain tight; or (b) The -value of unmarked -pages becomes equal to the frontier’s -value, . In the latter case, unmarked -pages become part of the frontier and the -value of the frontier is uniformly increased until gets fully fetched into the cache. If some agent becomes tight before the fetch operation is completed, then its unmarked pages get excluded from the frontier and the corresponding -values remain unchanged for the rest of this timestep. In all cases, the lemma continues to hold since the -value of the frontier is never decreased and only tight agents get dropped from the frontier.
Remark 3.10.
Within any phase, is non-decreasing over time and takes values and at the endpoints. This follows from the fact that never decreases for an unmarked page .
The following lemma shows that any page that is not completely in Algorithm ’s cache must be evicted to at least a portion. This property will be useful to us in Sections 3.3 and 4.
Lemma 3.11.
At the end of any time step , for any page , we have or .
Proof 3.12.
First, note that for all marked pages, we have . Let be any tight agent. Then we have . By Lemma 3.1 (part iii), all unmarked pages of agent have the same value: (say). Since is integral, we have either or . Rearranging, we have . Since all terms on the RHS are integral, we have either or .
By Lemma 3.8, all unmarked pages belonging to non-tight agents satisfy . Let be the set of all unmarked pages belonging to all non-tight agents that were also non-isolated at the beginning of the phase. Recall that by definition, we have since all pages in must have been fully in the cache at the beginning of the current phase. Since we have , once again by integrality of and , we must have that is an integer. Hence, either or .
3.2 Analysis Overview
At any time , we consider the set of values of pages in as the state of the system. We define a non-negative potential function that is purely a function of this state. For any page request , we attempt to bound the algorithm’s cost by an increase in the potential function, thereby bounding the total cost incurred by the algorithm by the final value of the potential function. There are two difficulties with this approach: (i) when a phase ends, the potential function abruptly drops since all the unmarked pages that were fully evicted no longer contribute to the state, and (ii) when the agent was isolated at the beginning of the phase but is now non-isolated, the change in potential is not sufficient to cover the fetch cost. In both these situations we charge the cost incurred by the online algorithm to a new quantity that is a function of the sets . To complete the analysis, we show that this quantity is upper-bounded by the cost of the optimal solution.
3.3 Potential Function Analysis
Consider the function defined as:
(1) |
As goes from to , increases from to .
The potential at any time is defined as follows:
(2) |
Note that only unmarked pages at any time contribute to the potential. So when page is fetched at time and marked, it stops contributing to the potential. But since is monotone, the newly evicted pages increase their contribution to the potential. We remark that the potential is purely a function of the state of the system as defined by the values of unmarked pages in the cache and is thus always bounded by a quantity independent of the length of the page request sequence.
Lemma 3.13.
For any , we have and .
Proof 3.14.
The first conclusion follows from the logarithmic inequality which holds for any nonnegative : we have whenever . Next, . So, for any we have , which gives the other conclusion.
The rest of this section is devoted to proving the following theorem where we bound the total cost incurred by the algorithm in terms of the sets and the number of requests to pseudo-clean pages.
Theorem 3.15.
The following bound holds on the cost incurred by to process the first page requests:
Recall that the algorithm incurs a cost of to fetch page at time . So the total cost incurred by the algorithm is simply . We first bound this cost for time steps when the requested page is at least partially in the cache, i.e., . Recall by Lemmas 3.2 and 3.4, the algorithm does not undergo a phase transition in this time step.
Lemma 3.16.
Consider any time step such that for the currently requested (unmarked) page . Let denote the change in the potential function during time step . Then .
Proof 3.17.
We assume that , since otherwise by Lemma 3.11, we must have and the lemma follows trivially. Since , by Lemma 3.8, either agent is tight or we have for every unmarked page owned by any non-tight agent that was non-isolated at the start of this phase. In either case, the pages that get evicted to make space for have their initial values at least . The potential function changes in this step due to two factors: (i) drops as page stops contributing to the potential as soon as it gets marked; and (ii) increases as the -value of (fractionally) evicted pages increases in this step.
Let . At the beginning to time , page contributed exactly to the potential; This contribution is lost as soon as gets marked. To prove the lemma, it suffices to show that the rate of increase in the potential function (without including ’s contribution) is at least throughout the eviction of an amount of unmarked pages belonging to non-tight agents: the term in total pays for the fetch-cost of and the term in total pays for the loss in potential. This directly follows from Lemma 3.13 from the fact that the -values of pages that are fractionally evicted in this timestep were already at least . Here, we also use the monotonicity of the function .
We still need to bound the cost incurred by the algorithm when the incoming request is to a page that is fully outside the cache. Note that the algorithm incurs exactly unit cost for all such time steps. The following lemma shows that the total cost incurred by the algorithm can be bounded by the drop in potential function at the end of a phase and by a term that depends only on the change in the potential function while processing a request to a page fully outside the cache.
Lemma 3.18.
For any global phase , let denote the change in the potential function at the end of phase (line 1 in Algorithm 1). Let denote the total number of global phases and denote the time at the end of phase . Then we have the following upper bound on the cost incurred by for processing the first page requests:
Proof 3.19.
We have:
(Using Lemma 3.16) | ||||
The lemma follows since and . The bound on is because we have agents each with , and .
So, it is enough to bound the total cost and drop in potential for time steps when the requested page is fully outside the cache and also to bound the drop in potential when the phase changes.
Proof 3.20 (Proof of Theorem 3.15).
Consider any time step such that the currently requested page is fully outside the cache, i.e. . We differentiate such requests into two cases depending on whether the page is in the set at the time or not. In other words, we do a case analysis on being clean or pseudo-clean. (Recall that only unmarked pages in contribute to the potential).
Case 1: , i.e, is clean. Since page , it does not contribute to the potential before (or after) the request has been served. Consider any page that is evicted (fractionally) by the algorithm in this step. By Lemma 3.1, before the eviction, we have or . In either case, by Lemma 3.13, we have where denotes the change in -value of page in this step. Since we have , we have .
Case 2: , i.e., is pseudo-clean. By the same reasoning as above, we have . However, in this case, page also contributed exactly to the potential at the beginning of the time step. So we have .
Combining the two cases we get:
(3) |
Consider the end of some phase and let be a non-isolated agent. Let denote the current local phase of agent that must also end along with the global phase . Consider any unmarked page in . As the phase is ending, page must be fully evicted and thus contributes to the potential. Once phase ends and phase begins, page no longer contributes to the potential. Note that the set of such unmarked pages is exactly . Hence, the change in potential at the end of (global) phase is given by:
Since an agent only changes its local phase when it is non-isolated at the end of a global phase, we have:
(4) |
The theorem now follows from Lemma 3.18.
3.4 A Lower Bound on through Dual Fitting
In this section, we give a novel LP-based lower bound on the cost of any offline algorithm for caching with reserves via dual-fitting. This lower bound analysis is new even for the classical unweighted paging setting. Crucially, the lower bound derived here perfectly matches the two terms used to bound the cost of the fractional algorithm in Theorem 3.15, thereby completing the proof of our main result (Theorem 1.1).
We now describe the linear relaxation of the caching with reserves problem and its dual program. The following notation will be useful. For any page , let denote the time steps when is requested in the online sequence. For an integer , define to be the time interval between the th and th requests for . We define for all pages. Let denote the number of requests to page that have been seen until time (inclusive). Hence, by definition, for any time and page , we have . The primal LP has variables which denote the portion of page that is evicted between its th and th requests, i.e., portion of is held in the cache during the time-interval . For convenience, we define and for any . The first and second set of primal constraints encode the cache size constraint and the agent-level reserve constraints for all times. The dual LP has variables and corresponding to these primal constraints. We also have dual variables corresponding to the primal constraint encoding . Besides nonnegativity, the dual has a single constraint for each interval . The primal and dual LPs are stated below. We emphasize that we use these linear programs purely for analysis and the algorithm itself does not need to solve any linear program.
Primal LP
subject to: | ||||
(5) | ||||
(6) | ||||
(7) | ||||
(8) |
Dual LP
subject to: | |||
(9) | |||
(10) |
Consider time that marks the end of a global phase for some integer . Let denote the total cost incurred by an optimal offline algorithm. By weak LP duality, the objective function of the Dual LP yields a lower bound on for any feasible dual solution. We now construct an explicit dual solution whose objective value is roughly equal to the total number of clean and pseudo-clean pages seen by the algorithm. See Section 3.1 to recall relevant notation and terminology. The dual solution is updated at the end of each (global) phase in two stages. Updates in the first stage, denoted , are simple and account for stale pages belonging to non-isolated agents that got evicted in the most recent local phase for that agent. Updates in the second stage, denoted , are more involved and account for the pseudo-clean pages of agents who lost their isolated status in the current phase. The dual solution that we maintain will always be approximately feasible up to factors, so the objective value of this dual solution serves as a lower bound on within a constant factor. We remark that the assumption that marks the end of a phase is without loss of generality since it can lead to at most an additive loss in the lower bound. Formally, we show the following.
Theorem 3.21.
Let denote the timepoint when global phase ends, and let denote the corresponding local phase counters. Let denote the dual solution that is constructed by the end of time , i.e., the solution that arises from a sequential application of dual updates in the order , and . We have:
-
(a)
The dual solution is approximately feasible: for any -page and an integer , holds.
-
(b)
The dual objective value of is:
We first show how Theorem 3.21 implies that our fractional algorithm is -competitive.
Proof 3.22 (Proof of Theorem 1.1).
In Theorem 3.15 we proved the following upper bound on the cost incurred by for processing the first page requests:
Clearly, the second nontrivial term in the above cost-expression matches the first term in the expression for . Now consider an arbitrary global phase and a timestep in this phase. By definition, a pseudo-clean page is necessarily stale, i.e., holds, and it must be that agent was isolated at the start of phase but is non-isolated by time . Therefore, and the following holds:
In the above, the final inequality is because among all pages in (w.r.t. the order in which they were marked by ), the first pages are not pseudo-clean. Thus, the first nontrivial term in the cost-expression for can be bounded by the second term in .
Overall, we have shown that holds. Since the dual solution is -feasible, we get that is -competitive.
We now furnish the details of our dual updates. Initially, all our dual variables , , with are set to zero. We assume that the dual updates are applied in the sequence given in Theorem 3.21. That is, the set of updates in are applied in increasing order of and within each phase first stage updates are applied first. With a slight abuse of notation, let denote the objective value of the dual solution right after updates until (inclusive) have been applied where . Note that . We also define . Throughout our updates, we ensure that the dual objective value never decreases, i.e., holds. We remark that variables may decrease and this only happens in the second stage; However, the and variables never decrease.
In Section 3.4, we describe the first stage of updates and show that the gain in the dual objective corresponds to the first term in Theorem 3.21(b). In Section 3.4, we describe the second stage of updates and show that the gain in the dual objective corresponds to the second term in Theorem 3.21(b). Lastly, in Section 3.4, we show that the dual solution that we maintain is always feasible up to constant factors and thus complete the proof of Theorem 3.21.
First Stage of Dual Updates
Fix a phase and consider the set of agents that are designated as isolated at the end of phase . Let denote the set of timesteps (in this phase) when the following two conditions hold: (a) in the fractional algorithm just before is requested; and (b) is not isolated at time . Define . It is not hard to see that the following is an equivalent expression for .
(11) |
Observe that for agents who are non-isolated both at the start and end of phase , counts all their clean pages. However, for agents who were isolated at the start of this phase but are no longer isolated by the end, only counts clean and pseudo-clean pages that are requested after the agent has become non-isolated. Roughly speaking, the motivation for the definition of comes from the intuition that an offline algorithm should incur, on an average, a cost of to serve page requests in phase .
Description of :
For each time , we separately apply the following updates. First, we increase by . Next, we increase by for every agent . Last, for each agent , we increase by for every -page .
It will be clear from the description of our updates that the and variables that were modified in were previously at . However, no such guarantee holds for the affected variables. We also remark that the same variable can be increased more than once during ; this happens when there are multiple times with the same value. In fact, since the variables arise from intervals that can possibly span across multiple phases, it is possible that the same variable is increased by different amounts across different steps.
For convenience, let be a shorthand for all timepoints in phase . The following result will be useful to us.
Lemma 3.23.
Let denote the dual solution that is obtained right after has been applied. We have: (a) ; and (b) for any agent .
Proof 3.24.
Follows directly from our choice of .
Our key technical result in this section is that the gain in the dual objective value that comes from is equal to the number of stale pages owned by non-isolated agents that were not requested in their most recent local phases. For convenience, we use the prefix to refer to changes that occured during .
Lemma 3.25.
We have , where is the change in the dual objective after .
Proof 3.26.
Since the only affected and variables have are those with and they are all increased by exactly , we get:
Now observe that for every and , the step increases the variable corresponding to exactly unique -pages, each by an amount . So we have . Substituting back into the equation above, we get:
The lemma follows from observing that the above group of terms within the parentheses is : this is because the cache (of size ) at the end of phase consists exactly (fractional) pages for isolated agents and exactly (integral) pages for non-isolated agents .
Second Stage of Dual Updates
We now describe the second stage of dual updates that are carried out at the end of each phase . Unlike the first stage, where we only increased the and variables of time steps in phase , in the second stage we decrease the variables of time steps in the previous phase .
Description of :
These dual updates correspond to agents that were isolated at the end of phase but are no longer isolated at the end of phase . Consider an agent . For every time in phase with (i.e., ), we do the following: we increase by for all -pages followed by resetting to .
For clarity, we note the following: (i) resetting to zero is the only dual update when a variable is decreased; (ii) the updates are applied to timepoints in phase (i.e., the previous phase); and (iii) the variables that we updated above were unchanged while applying at the end of phase because their owner was designated as isolated at that time. The reason for decreasing the variables is that it leads to an increase in the dual objective, which will be needed to pay for costs associated with pseudo-clean pages. We formalize this in the following lemma.
Lemma 3.27.
We have where is the change in the dual objective after .
Proof 3.28.
Fix an agent . In Lemma 3.23 we showed that after , = 1 and . Consider any time in phase with . By the definition of , we decrease by while increasing by the same amount for all pages . Recalling the coefficients in the dual objective function, we see that the updates corresponding to agent increases the dual objective by exactly:
Approximate Dual Feasibility
We finish this section by showing that the dual solution is always approximately feasible.
Lemma 3.29.
Let denote the dual solution that is obtained right after has been applied for some and . For any -page and an integer satisfying , we have .
Proof 3.30.
First of all, for the purposes of this proof, the specific values of and are irrelevant, so we ignore them. Fix some -page and an integer satisfying . Recall that , where denotes the time when is requested for the th time; We redefine to be if holds.
The lemma holds trivially if is empty, so we assume otherwise. Let denote the global phases that contain timesteps and , respectively. Clearly, . Another easy case of the lemma is when holds. The desired conclusion follows easily because all the dual variables are nonnegative and the sum of all variables in any phase is at most (by Lemma 3.23). Formally,
Now suppose that holds. Define . Repeating the above calculation, we get:
so the crux of the lemma is to show that the sum of over timepoints spanning phases in is not much larger than . For a phase , we overload the notation to mean . Note that by nonnegativity of variables and Lemma 3.25, for every . We do a case analysis on phase to get a better handle on the changes that happens during our dual update procedures.
-
(a)
Suppose that holds. Since is isolated by the end of phase , we know that any increase in (as part of ) for some is accompanied with the same increase in . Since holds, does not decrease/reset any of the variables to . Thus, holds. Note that there can be an arbitrary number of phases that fall under this case, but this is not a problem for us since .
-
(b)
Suppose that and hold. We rely on the trivial bound for this case. Since is isolated by the end of phase but is non-isolated by the end of phase , the local phase counter goes up by at the end of phase , and subsequently the set gets updated with some new collection of marked -pages. By definition of , there are no page-requests for during any of the phases in . Thus, there can be at most local phase increments for agent before gets dropped from the set; By the design of , page cannot enter any of the future until the next time it is requested, which does not happen during any of the phases in .
-
(c)
Suppose that and hold. Similar to case (a) above, we know that any increase in (as part of ) for some is accompanied with the same increase in . Now, although decreases/resets all the variables to , it also increases by the same amount since . Thus, equals the increase in due to . So, the difference is essentially .
-
(d)
Suppose and hold. We rely on the trivial bound for this case. Since is non-isolated by the end of phase , the local phase counter goes up by at the end of phase . Repeating the argument from case (c), there can be at most more local phase increment for agent before gets dropped from the set for the rest of the phases in .
-
(e)
Suppose and hold. Since is non-isolated by the end of phase and is not in , we know that any increase in (as part of ) for some is accompanied with the same increase in . Thus, equals the increase in due to . So, the difference is essentially .
From the above case analysis, it follows that is bounded by the number of phases for which case (b) or (d) hold. Since we argued that there can be at most such occurences, holds.
We now prove the main theorem in this section by combining the above lemmas.
4 Rounding
In this section we show how to convert the fractional Algorithm 1 into a randomized integral online algorithm for Caching with Reserves, each step of which runs in polynomial time.
The algorithm maintains a uniform distribution on valid cache states. In each step, these states are updated based on the actions of the fractional algorithm. The randomized algorithm selects one of these states uniformly at random in the beginning, and then follows it throughout the run.
Initially, all cache states in the distribution are the same as the initial cache state in Algorithm 1. Given the fractional algorithm values after each page request, the distribution is updated in two steps. First, we produce a discretized version of these fractions, , which are also a feasible fractional solution. This is based on the technique in [2]. Second, we update the cache states so that all of them remain valid, and for each page , exactly of the states contain . This is based on the technique in [10]. We note that the rounding procedure can be done online, as it does not need the knowledge of any future page requests.
4.1 Discretization Procedure
In this subsection, we explain how to perform the first step: discretizing the fractional algorithm’s values into which are multiples of . Our procedure is quite simple: we iterate over the pages in any order that arranges all pages belonging to the same agent consecutively (i.e., order the agents arbitrarily and order each agent’s pages arbitrarily, but do not interleave pages from different agents). Then for , set:
where denotes rounding down to the nearest multiple of ; formally: .
Lemma 4.1.
Discretization satisfies the following guarantees:
-
1.
is a multiple of
-
2.
-
3.
for each agent ,
-
4.
if , then
Proof 4.2.
The first guarantee, is a multiple of , follows from being a multiple of by definition.
We now prove the second guarantee, . Let be , and we get:
The proof of the third guarantee is essentially the same. It is here we use the fact that each agent’s pages are consecutive in . Suppose our agent’s pages are :
The fourth guarantee follows by noting that if is an integer, then the operator decreases as much as it decreases .
Corollary 4.3.
If satisfy total cache capacity () and reserve requirements (), then so do .
Proof 4.4.
The total cache capacity constraint continues to hold due to a telescoping argument:
Next, we will prove that reserve cache sizes are satisfied. For the sake of contradiction, suppose that for some agent , . Since the right-hand side of this inequality is an integer and therefore a multiple of , the left-hand side, which is also a multiple of due to being a sum of multiples of (by Lemma 4.1’s first guarantee), must be at least a full multiple of less than the right-hand side: . But this contradicts Lemma 4.1’s third guarantee, . Therefore for all agents , , completing the proof.
Corollary 4.5.
Proof 4.6.
Without loss of generality, there are at most agents since we can combine all agents that do not have any reserve. Each agent has at most fractional pages by the algorithm (the -pages that were in cache when ’s local phase began). The value of each fractional page is distorted by at most by Lemma 4.1’s second guarantee, while not being distorted for non-fractional pages by the fourth guarantee. This completes the proof.
Lemma 4.7.
Let and be the amounts of each page in cache in the fractional algorithm for two consecutive time steps, and and be the corresponding discretized values. Then the cost of cache update from to (call it ) is at most twice the cost of cache update from to (call it ).
Proof 4.8.
Lemma 3.11 implies that either (i.e., the requested page was already in cache and there is no change to the cache state), or . In the first case, there is no change to the discretized cache state either, so . So we focus on the second case. By triangle inequality, for any page ,
We note that since cost is incurred for adding pages to cache, and both the original fractional solution and the discretized one add as much page mass to cache as they evict, , and similarly for . Summing the above inequality over , we get
where we used by Corollary 4.5, then , then .
4.2 Updating the Distribution of Cache States
In this subsection, we explain how to perform the second step: updating the cache states. We would like (i) all cache states to be valid, (ii) exactly (integral due to our discretization step) of the states to contain page , and (iii) to not use too many evictions.
Formally, let be a set of cache states with pages each, which corresponds to the discretized values for time step . Given the discretized values for time step , we show how to transform into , in which each page appears in exactly cache states and such that each cache state satisfies all the reserve requirements.
Let be a multiset of pages whose fraction in the cache increased from time to , with each page appearing times. Let be an analagous multiset for decreases, with each page appearing times. Since the total amount of pages in the cache is unchanged, . We find a matching between pages in and and use it to transform into gradually, one pair at a time. The matching is constructed as follows. First, any pages from and that belong to the same agent are matched up. Then, the remaining pages in and are matched up arbitrarily.
Lemma 4.9.
Let be the matching between and described above. Then for any , the fractional solution that adds fraction of pages to and removes fraction of pages from it satisfies all the reserve requirements.
Proof 4.10.
As the pairs are applied, the fractional solution transforms from to , both of which satisfy the reserve requirements (by Corollary 4.3). Inductively, assume that when pairs up to have been applied, the reserved requirements are still satisfied. If and belong to the same agent , then amount of -pages in the cache doesn’t change, thus still satisfying the requirement. If and belong to different agents, then we must be in the second phase of our matching construction. This means that there are no more pages in belonging to , so the amount of -pages in cache does not increase while applying the remainder of the matching pairs. This means that after applying , the amount of -pages in the cache is somewhere between what it has in and in . Since both of those satisfy the reserve requirements, so does the intermediate solution.
We now show how to modify with the next pair from the matching. This follows the procedure in [10], with the difference that we work on a limited number of sets, and the amount of increase in and decrease in is fixed at .
Let be the current set of cache states (possibly modified by the previous page pairs). If there is a cache state such that and , add to and remove from . Otherwise, find cache states and with and , add to and remove from . Next, move some page from to to adjust the set sizes back to .
At this point, each page is in the correct number of cache states. However, reserve requirements could be violated by one page for or in the cache states from which the corresponding pages were removed. In such a case, suppose the requirement is violated for agent in a cache state . Since, by Lemma 4.9, each reserve requirement is satisfied on average, there must be another set which has strictly more than pages belonging to agent . We move one such page from to . Now has pages, so there must be an agent which has more than pages in . We move one of ’s pages from to to restore the sizes. This completes the update, resulting in new valid sets corresponding to the fractions .
We conclude by bounding the cost of update to , and thus the expected cost of the randomized algorithm, relative to the cost of the fractional algorithm.
Lemma 4.11.
The cost of update to is at most 6 times the cost of fractional cache update from to .
Proof 4.12.
Each pair in the matching corresponds to a cost of incurred by the discretized fractional solution. In the updates to sets in , each time a page is removed from one of the cache states incurs a cost of to the randomized algorithm. At most, the following six removals are done: remove from ; remove from ; two pages each are swapped to fix the reserve requirements for and .
References
- [1] Dimitris Achlioptas, Marek Chrobak, and John Noga. Competitive Analysis of Randomized Paging Algorithms. Theoretical Computer Science, 234(1):203–218, 2000. doi:10.1016/S0304-3975(98)00116-9.
- [2] Anna Adamaszek, Artur Czumaj, Matthias Englert, and Harald Räcke. An -Competitive Algorithm for Generalized Caching. ACM Transactions on Algorithms, 15(1):6:1–6:18, 2018. doi:10.1145/3280826.
- [3] Kunal Agrawal, Michael A. Bender, Rathish Das, William Kuszmaul, Enoch Peserico, and Michele Scquizzato. Tight Bounds for Parallel Paging and Green Paging. In Proceedings of the 32nd Symposium on Discrete Algorithms, pages 3022–3041, 2021. doi:10.1137/1.9781611976465.180.
- [4] Nikhil Bansal, Niv Buchbinder, and Joseph Seffi Naor. A Simple Analysis for Randomized Online Weighted Paging. Unpublished Manuscript, 2010.
- [5] Nikhil Bansal, Niv Buchbinder, and Joseph (Seffi) Naor. Towards the Randomized -Server Conjecture: A Primal-Dual Approach: (Extended Abstract). In Proceedings of the 21st Symposium on Discrete Algorithms, pages 40–55, 2010. doi:10.1137/1.9781611973075.5.
- [6] Nikhil Bansal, Christian Coester, Ravi Kumar, Manish Purohit, and Erik Vee. Learning-Augmented Weighted Paging. In Proceedings of the 33rd Symposium on Discrete Algorithms, pages 67–89, 2022. doi:10.1137/1.9781611977073.4.
- [7] Jichuan Chang and Gurindar S Sohi. Cooperative Cache Partitioning for Chip Multiprocessors. In Proceedings of the 21st ACM International Conference on Supercomputing, pages 242–252, 2007. doi:10.1145/1274971.1275005.
- [8] Ashish Chiplunkar, Monika Henzinger, Sagar Sudhir Kale, and Maximilian Vötsch. Online Min-Max Paging. In Proceedings of the 34th Symposium on Discrete Algorithms, pages 1545–1565, 2023. doi:10.1137/1.9781611977554.ch57.
- [9] Amos Fiat, Richard M. Karp, Michael Luby, Lyle A. McGeoch, Daniel D. Sleator, and Neal E. Young. Competitive Paging Algorithms. Journal of Algorithms, 12(4):685–699, 1991. doi:10.1016/0196-6774(91)90041-V.
- [10] Sharat Ibrahimpur, Manish Purohit, Zoya Svitkina, Erik Vee, and Joshua R. Wang. Caching with Reserves. In Proceedings of the 25th International Conference on Approximation Algorithms for Combinatorial Optimization Problems (APPROX), volume 245, pages 52:1–52:16, 2022. doi:10.4230/LIPIcs.APPROX/RANDOM.2022.52.
- [11] Wu Kan, Tu Kaiwei, Patel Yuvraj, Sen Rathijit, Park Kwanghyun, Arpaci-Dusseau Andrea, and Remzi Arpaci-Dusseau. NyxCache: Flexible and Efficient Multi-tenant Persistent Memory Caching. In Proceedings of the 20th USENIX Conference on File and Storage Technologies (FAST), pages 1–16, 2022. URL: https://www.usenix.org/conference/fast22/presentation/wu.
- [12] Mayuresh Kunjir, Brandon Fain, Kamesh Munagala, and Shivnath Babu. ROBUS: Fair Cache Allocation for Data-parallel Workloads. In Proceedings of the 2017 ACM International Conference on Management of Data (SIGMOD), pages 219–234, 2017. doi:10.1145/3035918.3064018.
- [13] Lyle A. McGeoch and Daniel D. Sleator. A Strongly Competitive Randomized Paging Algorithm. Algorithmica, 6:816–825, 1991. doi:10.1007/BF01759073.
- [14] Qifan Pu, Haoyuan Li, Matei Zaharia, Ali Ghodsi, and Ion Stoica. FairRide: Near-Optimal, Fair Cache Sharing. In Proceedings of the 13th USENIX Symposium on Networked Systems Design and Implementation (NSDI), pages 393–406, 2016. URL: https://www.usenix.org/conference/nsdi16/technical-sessions/presentation/pu.
- [15] Harold S. Stone, John Turek, and Joel L. Wolf. Optimal Partitioning of Cache Memory. IEEE Transactions on Computers, 41(9):1054–1068, 1992. doi:10.1109/12.165388.
- [16] G Edward Suh, Larry Rudolph, and Srinivas Devadas. Dynamic Partitioning of Shared Cache Memory. The Journal of Supercomputing, 28(1):7–26, 2004. doi:10.1023/B:SUPE.0000014800.27383.8f.
- [17] Yinghao Yu, Wei Wang, Jun Zhang, and Khaled Ben Letaief. LACS: Load-Aware Cache Sharing with Isolation Guarantee. In Proceedings of the 39th IEEE International Conference on Distributed Computing Systems (ICDCS), pages 207–217. IEEE, 2019. doi:10.1109/ICDCS.2019.00029.
Appendix A Analysis of Randomized Marking for Unweighted Paging
In this section, we consider the classical unweighted paging problem and provide a new proof that the randomized marking [9] algorithm is -competitive.
Recall that the randomized marking algorithm works in phases as follows. Initially all pages in the cache are unmarked. When a page is requested at time , if is already in the cache then it is marked and no other change occurs. If is not in the cache, then a page is chosen uniformly at random from the set of unmarked pages currently in the cache and evicted. Page is then brought into the cache and marked. Once there are no more unmarked pages left for eviction, the current phase ends — all pages in the cache are unmarked and a new phase begins.
Let RM denote the above randomized marking algorithm and let be the total cost incurred on an instance . For analysis, we consider the following fractional version of the marking algorithm: The algorithm maintains a set of marked and unmarked pages as before. At any time , let denote the fraction of page in the cache and denote the fraction of page outside the cache. When a page is requested, the fractional marking algorithm sets and uniformly increases for all unmarked pages in the cache. As in the randomized marking algorithm, a phase ends when all unmarked pages have been fully evicted from the cache. Observe that for any page and time , the value in the fractional marking algorithm exactly equals the marginal probability that page has been evicted from the cache by the randomized marking algorithm. Let FM denote the fractional marking algorithm, then we have: . In the rest of this section, we focus on bounding the total cost incurred by the fractional marking algorithm.
Potential Function
Consider any phase of the fractional marking algorithm and let denote the set of exactly pages in the cache at the beginning of the phase and denote the set of pages in cache at the end of the phase. By definition, is exactly the set of distinct pages that are requested during phase . Following standard terminology, we say a page is stale if and call as clean otherwise. Let denote the total number of clean pages in phase . At any time , let be the set of unmarked pages at time . Consider the following potential function:
where as earlier. At any time step , let be the total change in potential while processing the requested page 444In particular, does not include any change in potential due to a phase change.. Let denote the change in potential due to end of a phase .
Lemma A.1.
At any time , if , then .
Proof A.2.
At any time , all unmarked pages in the cache have been evicted the same amount fractionally, i.e. . While serving the requested page , the potential decreases as page stops contributing to the potential while the potential increases due to the eviction of all other unmarked pages. Page contributed exactly to the potential at the beginning of this step. On the other hand, to fetch page , the other unmarked pages are evicted by a total amount of . By Lemma 3.13, the potential increases at a rate of at least throughout this eviction process. Summing up both the contributions, we get:
Lemma A.3.
At the end of any phase , the potential drops by .
Proof A.4.
At the end of phase , all pages in are unmarked and have been fully evicted from the cache. Each such page contributed exactly to the potential just before the phase ended. Once phase ends (and phase begins), all these pages stop contributing to the potential. The claim follows by noting that .
The previous two lemmas allow us to bound the total cost incurred by the fractional marking algorithm purely in terms of the total number of clean pages.
Lemma A.5.
We have .
Proof A.6.
We have the following chain of equations and inequalities:
Theorem A.7.
The randomized marking algorithm is -competitive.