Docsity

Adaptive Caching by Refetching - Machine Learning | CMPS 242, Papers of Computer Science

Toggle sidebar
bg1
Adaptive Caching by Refetching
(View in Color)
Robert B. Gramacy
, Manfred K. Warmuth
, Scott A. Brandt, Ismail Ari
f
rbgramacy, manfred, scott, ari
g
@cs.ucsc.edu
University of California Santa Cruz
Abstract
We are constructing caching policies that have 13-20% lower miss rates
than the best of twelve baseline policies over a large variety of request
streams. This represents an improvement of 49–63% over Least Recently
Used, the most commonly implemented policy. We achieve this not by
designing a specific new policy but by using on-line Machine Learning
algorithms to dynamically shift between the standard policies based on
their observed miss rates. A thorough experimental evaluation of our
techniques is given, as well as a discussion of what makes caching an
interesting on-line learning problem.
1 Introduction
Caching is ubiquitous in operation systems. It is useful whenever we have a small, fast main
memory and a larger, slower secondary memory. In file system caching, the secondary
memory is a hard drive or a networked storage server while in web caching the secondary
memory is the Internet. The goal of caching is to keep within the smaller memory data
objects (files, web pages, etc.) from the larger memory which are likely to be accessed again
in the near future. Since the future request stream is not generally known, heuristics, called
caching policies, are used to decide which objects should be discarded as new objects are
retained. More precisely, if a requested object already resides in the cache then we call it a
hit, corresponding to a low-latency data access. Otherwise, we call it a miss, corresponding
to a high-latency data access as the data is fetched from the slower secondary memory into
the faster cache memory. In the case of a miss, room must be made in the cache memory
for the new object. To accomplish this a caching policy discards from the cache objects
which it thinks will cause the fewest or least expensivefuture misses.
In this work we consider twelve baseline policies including seven common policies
(RAND, FIFO, LIFO, LRU, MRU, LFU, and MFU), and five more recently devel-
oped and very successful policies (SIZE and GDS [CI97], GD* [JB00], GDSF and
LFUDA [ACD
+
99]). These algorithms employ a variety of directly observable criteria
including recency of access, frequency of access, size of the objects, cost of fetching the
objects from secondary memory, and various combinations of these.
The primary difficulty in selecting the best policy lies in the fact that each of these policies
may work well in different situations or at different times due to variations in workload,
system architecture, request size, type of processing, CPU speed, relative speeds of the
Partial support from NSF grant CCR 9821087
pf3
pf4
pf5

Partial preview of the text

Download Adaptive Caching by Refetching - Machine Learning | CMPS 242 and more Papers Computer Science in PDF only on Docsity!

Adaptive Caching by Refetching

(View in Color)

Robert B. Gramacy  , Manfred K. Warmuth  , Scott A. Brandt, Ismail Ari frbgramacy, manfred, scott, [email protected] University of California Santa Cruz

Abstract

We are constructing caching policies that have 13-20% lower miss rates than the best of twelve baseline policies over a large variety of request streams. This represents an improvement of 49–63% over Least Recently Used, the most commonly implemented policy. We achieve this not by designing a specific new policy but by using on-line Machine Learning algorithms to dynamically shift between the standard policies based on their observed miss rates. A thorough experimental evaluation of our techniques is given, as well as a discussion of what makes caching an interesting on-line learning problem.

1 Introduction

Caching is ubiquitous in operation systems. It is useful whenever we have a small, fast main memory and a larger, slower secondary memory. In file system caching, the secondary memory is a hard drive or a networked storage server while in web caching the secondary memory is the Internet. The goal of caching is to keep within the smaller memory data objects (files, web pages, etc.) from the larger memory which are likely to be accessed again in the near future. Since the future request stream is not generally known, heuristics, called caching policies , are used to decide which objects should be discarded as new objects are retained. More precisely, if a requested object already resides in the cache then we call it a hit , corresponding to a low-latency data access. Otherwise, we call it a miss , corresponding to a high-latency data access as the data is fetched from the slower secondary memory into the faster cache memory. In the case of a miss, room must be made in the cache memory for the new object. To accomplish this a caching policy discards from the cache objects which it thinks will cause the fewest or least expensive future misses.

In this work we consider twelve baseline policies including seven common policies (RAND, FIFO, LIFO, LRU, MRU, LFU, and MFU), and five more recently devel- oped and very successful policies (SIZE and GDS [CI97], GD* [JB00], GDSF and LFUDA [ACD+^ 99]). These algorithms employ a variety of directly observable criteria including recency of access, frequency of access, size of the objects, cost of fetching the objects from secondary memory, and various combinations of these.

The primary difficulty in selecting the best policy lies in the fact that each of these policies may work well in different situations or at different times due to variations in workload, system architecture, request size, type of processing, CPU speed, relative speeds of the

 Partial support from NSF grant CCR 9821087

0

205000 210000 215000 220000 225000 230000 235000

fifolru mrulifo size mfulfu randgds lfudagdsf gd

0

205000 210000 215000 220000 225000 230000 (a) (b)

205000 210000 215000 220000 225000 230000 235000

Lowest miss rate policy switches between SIZE, GDS, GDSF, and GD* size gdsfgds gd

205000 210000 215000 220000 225000 230000

Lowest miss rate policy ... SIZE, GDS, GDSF, and GD*

(c) (d)

Figure 1: Miss rates (y axis)of a) the twelve fixed policies (calculated w.r.t. a window of 300 requests) over 30,000 requests (x axis), b) the same policies on a random permutation of the data set, c) and d) the policies with the lowest miss rates in the figures above.

different memories, load on the communication network, etc. Thus the difficult question is: In a given situation, which policy should govern the cache? For example, the request stream from disk accesses on a PC is quite different from the request stream produced by web-proxy accesses via a browser, or that of a file server on a local network. The relative performance of the twelve policies vary greatly depending on the application. Furthermore, the characteristics of a single request stream can vary temporally for a fixed application. For example, a file server can behave quite differently during the middle of the night while making tape archives in order to backup data, whereas during the day its purpose is to serve file requests to and from other machines and/or users. Because of their differing decision criteria, different policies perform better given different workload characteristics. The request streams become even more difficult to characterize when there is a hierarchy or a network of caches handling a variety of file-type requests. In these cases, choosing a fixed policy for each cache in advance is doomed to be sub-optimal.

The usual answer to the question of which policy to employ is either to select one that works well on average, or to select one that provides the best performance on some im- portant subset of the workload. However, these strategies have two inherent costs. First, the selection (and perhaps tuning) of the single policy to be used in any given situation is done by hand and may be both difficult and error-prone, especially in complex system architectures with unknown and/or time-varying workloads. And second, the performance of the chosen policy with the best expected average case performance may in fact be worse than that achievable by another policy at any particular moment. Figure 1 (a) shows the hit rate of the twelve policies described above on a representative portion of one of our data sets (described below in Section 3) and Figure 1 (b) shows the hit rate of the same policies on a random permutation of the request stream. As can be clearly be seen, the miss rates on the permuted data set are quite different from those of the original data set, and it is this difference that our algorithms aim to exploit. Figures 1 (c) and (d) show which policy is best at each instant of time for the data segment and the permuted data segment. It is clear from these (representative) figures that the best policy changes over time.

To avoid the perils associated with trying to hand-pick a single policy, one would like to be able to automatically and dynamically select the best policy for any given situation. In other words, one wants a cache replacement policy which is “adaptive”. In our Systems

expensive. A better master policy keeps a single weight wi for each policy (non-negative and summing to one) which represents an estimate of its current relative performance. The master policy is always governed by the policy with the maximum weight^2.

Weights are updated by using the combined loss and share updates of Herbster and War- muth [HW98] and Bousquet and Warmuth [BW02] from the expert framework [CBFH+^ 97] for on-line learning. Here the experts are the caching policies. This technique is preferred to the window-based master policy because it uses much less memory, and because the parameters of the weight updates are easier to tune than the window size. This also makes the resulting master policy more robust (not shown).

2.1 The Weight Updates

Updating the weight vector (w 1 ; : : : ; w 12 ) after each trial is a two-part process. First, the weights of all policies that missed the new request are multiplied by a factor 2 (0; 1) and then renormalized. We call this the loss update. Since the weights are renormalized, they remain unchanged if all policies miss the new request. As noticed by Herbster and War- muth [HW98], multiplicative updates drive the weights of poor experts to zero so quickly that it becomes difficult for them to recover if their experts subsequently start doing well. Therefore, the second share update prevents the weights of experts that did well in the past from becoming

0

1

205000 210000 215000 220000 225000 230000 235000

FSUP Weight

Requests Over Time

Weight History for Individual Policies lru mrufifo sizelifo lfu randmfu gdsfgds lfuda gd

Figure 2: Weights of baseline policies.

too small, allowing them to recover quickly, as shown in Figure 2.

There are a number of share updates [HW98, BW02] with various recovery properties. We choose the F IXED S HARE TO U NIFORM PAST (FSUP) update because of its simplicity and efficiency. Note that the loss bounds proven in the expert framework for the combined loss and share update do not apply in this context. This is because we use the mixture weights only to select the best policy (discussion in full paper). However, our experimental results suggest that we are exploiting the recovery properties of the combined update that are discussed extensively by Bousquet and Warmuth [BW02].

Formally, for each trial t, the loss update is

w mt;i =

wt;i misst;i Zt+

; Zt+1 =

X^ N

i=

wt;i misst;i^ ; for i = 1 ; : : : ; N ;

where is a parameter in (0; 1) and misst;i is 1 if the t-th object is missed by policy i and 0 otherwise. The initial distribution is uniform, i.e. w 1 ;i = 1 =N. The Fixed-Share to Uniform Past mixes the current weight vector with the past average weight vectorP rt = t q =1 w^

m q =t, which is easy to maintain: wt+1 = (1 ) w mt + rt 1 ;

where is a parameter in (0; 1). A small parameter causes high weight to decay quickly if its corresponding policy has currently more misses than other policies with high weights.

(^2) This can be sub-optimal in the worst case since it is always possible to construct a data stream

where two policies switch back and forth after each request. However, real request streams appear to be divided into segments that favor one of the twelve policies for a substantial number of requests (see Figure 1).

-0.

0

205000 210000 215000 220000 225000 230000

Miss Rate

Requests Over Time

Miss Rate Differences

bestF - demd bestF - dfrd bestF - inst

Figure 3: BestFixed - P, where P 2 fInstantaneous, Demand, and Background Rolloverg.

The higher the the more quickly past good policies will recover. In our experiments we used = 1 =e and = 1 = 5000.

2.2 Demand vs. Instantaneous Rollover

When space is needed to cache a new request, the master policy discards objects not present in the governing policy’s virtual cache^3. This causes the content of the real cache to “roll over” to the content of the current governing virtual cache. We call this demand rollover because objects in the governing virtual cache are refetched into the real cache on demand. While this master policy works almost as well as BestFixed, we were not satisfied and wanted to do as well as BestShifting. We noticed that the content of the real cache lagged behind the content of the governing virtual cache and had more misses. As a consequence, the miss rate of the master policy was greatly improved if, as soon as we switched over to a new governing policy, we refetched all the files in that policy’s virtual cache that were not retained in the real cache. We call this instantaneous rollover. By appropriate tuning of the update parameters and , the number of instantaneous rollovers can be kept reasonably small and the miss rates of our master policy are almost as good as BestShifting(K ; L). Here an upper bound for K is chosen (generously) to be twice the number of rollovers used by our master policy, and L is set to the maximum segment length.

2.3 Background Rollover

Because instantaneous rollover immediately refetches everything in the governing virtual cache that is not already in the real cache, it may cause a large number of refetches even when the number of policy switches is kept small. If all refetches are counted as misses, then the miss rate of such a master policy is comparable to that of BestFixed. The same is true for BestShifting. However, from a user perspective, refetching is advantageous be- cause of the latency advantage gained by having required objects in memory before they are needed. And from a system perspective, refetches can be “free” if they are done when the system is idle. To take advantage of these “free” refetches, we introduce the concept of background rollover. The exact criteria for when to refetch each missing object will depend heavily on the system, workload, and expected cost and benefit of each object. To characterize the performance of background rollover without addressing these architectural details, the following background refetching strategies were examined: 1 refetch for every cache miss; 1 for every hit; 1 for every request; 2 for every request; 1 for every hit and 5 for every miss, etc. Each background technique gave fewer misses than BestFixed, approach- ing and nearly matching the performance obtained by the master policy using instantaneous

(^3) We update the virtual caches before the real cache, so there are always objects in the real cache

that are not in the governing virtual cache when the master policy goes to find space for a new request.

4 Conclusion

Operating systems have many hidden parameter tweaking problems which are ideal appli- cations for on-line Machine Learning algorithms. These parameters are often set to values which provide good average case performance on a test workload. For example, we have identified candidate parameters in device management, file systems, and network proto- cols. Previously the on-line algorithms for predicting as well as the best shifting expert were used to tune the time-out for spinning down the disk of a PC [HLSS00]. In this pa- per we use the weight updates of these algorithms for dynamically determining the best caching policy. This application is more elaborate because we needed to actively gather performance information about the caching policies via virtual caches. In future work we will do a more thorough study of feasibility of deferred rollover by building actual sys- tems using the algorithms we investigated in the simulations described in this paper. We will also explore the relationship of our methods to reinforcement learning and multi-arm bandit problems.

Acknowledgements: Thanks to Jonathan Panttaja, Ahmed Amer, and Ethan Miller for their contributions to this research.

References

[AAG+^ ar] Ismail Ari, Ahmed Amer, Robert Gramacy, Ethan Miller, Scott Brandt, and Darrell D. E. Long. ACME: Adaptive caching using multiple experts. In Proceedings of the 2002 Workshop on Distributed Data and Structures (WDAS 2002). Carleton Scientific, (to appear). [ACD+^ 99] Martin Arlitt, Ludmilla Cherkasova, John Dilley, Rich Friedrich, and Tai Jin. Eval- uating content management techniques for Web proxy caches. In Proceedings of the Workshop on Internet Server Performance (WISP99) , May 1999. [BW02] O. Bousquet and M. K. Warmuth. Tracking a small set of experts by mixing past posteriors. J. of Machine Learning Research , 2002. To appear, prel. version in COLT01.

[CBFH+^ 97] N. Cesa-Bianchi, Y. Freund, D. Haussler, D. P. Helmbold, R. E. Schapire, and M. K. Warmuth. How to use expert advice. Journal of the ACM , 44(3):427–485, 1997. [CI97] Pei Cao and Sandy Irani. Cost-aware WWW proxy caching algorithms. In Proceedings of the 1997 Usenix Symposium on Internet Technologies and Systems (USITS-97) , 1997. [HLSS00] David P. Helmbold, Darrell D. E. Long, Tracey L. Sconyers, and Bruce Sherrod. Adap- tive disk spin-down for mobile computers. ACM/Baltzer Mobile Networks and Appli- cations (MONET) , pages 285–297, 2000. [HW98] M. Herbster and M. K. Warmuth. Tracking the best expert. Journal of Machine Learn- ing , 32(2):151–178, August 1998. Special issue on concept drift. [JB00] Shudong Jin and Azer Bestavros. Greedydual* web caching algorithm: Exploiting the two sources of temporal locality in web request streams. Technical Report 2000-011, 4, 2000. [KW97] J. Kivinen and M. K. Warmuth. Additive versus exponentiated gradient updates for linear prediction. Information and Computation , 132(1):1–64, January 1997. [LW94] N. Littlestone and M. K. Warmuth. The weighted majority algorithm. Information and Computation , 108(2):212–261, 1994. [MS96] Lily Mummert and Mahadev Satyanarayanan. Long term distributed file reference tracing: Implementation and experience. Software - Practice and Experience (SPE) , 26(6):705–736, June 1996.