Download presentation
Presentation is loading. Please wait.
Published byZoie Gauld Modified over 9 years ago
1
Outperforming LRU with an Adaptive Replacement Cache Algorithm Nimrod megiddo Dharmendra S. Modha IBM Almaden Research Center
2
Outline Introduction. ARC intuition. Cache replacement Algorithms. Cache and History. Adaptive replacement Cache. Experimental Results. Conclusion.
3
Introduction A commonly used criterion for evaluating replacement policy is its hit ratio Hit ratio: the frequency with which it finds a page in the cache. The LRU is the policy of choice in cache management. Attempts to outperform LRU in practice had not succeeded because of the overhead issues and the need to pretune parameters. The Adaptive replacement cache (ARC) is: – Self-tuning. – Low-overhead that responds online to changing access patterns. –Continually balances between recency and frequency features of the workload, demonstrating that adaptation eliminates the need for the workload-specific pretuning that plagued many previous proposals to improve LRU.
4
Introduction –Easy to implement, its running time per request is essentially independent of the cache size. (a real life implementation revealed that ARC has low space overhead—0.75 percent of the cache size). –Scan-resistant: it allows one-time sequential requests to pass through without polluting the cache or flushing pages that have temporal locality, otherwise.
5
ARC Intuition ARC maintains two LRU pages lists: L1 and L2. –L1 maintains pages that have been seen only once, recently. –L2 maintains pages that have been seen at least twice, recently ARC caches only a fraction of pages on these lists. The pages that have been seen twice within a short time may be thought of as having high frequency or having longer term reuse potential. Hence. –L1 captures recency. –L2 captures frequency. If the cache holds c pages, we strive to keep these two lists to roughly the same size, c.
6
ARC Intuition The two lists, together, comprise a cache directory that holds at most 2c pages. ARC caches a variable number of most recent pages from both L1 and L2 such that the total number of cached pages is c. ARC continually adapts the precise number of pages from each list that are cached. To contrast an adaptive approach with a non adaptive approach, suppose FRC p provides a fixed-replacement policy that attempts to keep in cache the p most recent pages from L1 and c - p most recent pages in L2. thus, ARC behaves like FRC p except that it can vary p adaptively.
7
ARC Intuition Most algorithms use recency and frequency as predictors of the likelihood that pages will be reused in the future. ARC acts as an adaptive filter to detect and track temporal locality. –If either recency or frequency becomes more important at sometime, ARC will detect the change and adapt its investment in each of the two lists accordingly.
8
Cache Replacement Algorithms Offline optimal –Lazlo A. Belady’s MIN is an optimal, offline policy for replacing the page in the cache that has the greatest distance to its next occurrence. Recency –the LRU policy always replaces the least recently used page. –This policy has undergone many improvements. –Three of the most important related algorithms: –Clock, WS (working set), WSClock.
9
Cache Replacement Algorithms Frequency –The independent reference model (IRM) captures the notion of page reference frequencies. –Requests received at different times are independent 1.LFU replaces the least frequently used pages –Drawbacks LFU’s running time per request is logarithmic in the cache size. It is oblivious to recent history. Adapts poorly to variable access patterns by accumulating stale pages with past high-frequency counts, which may no longer be useful. 2.LRU-2 memorizes the times for each cache page’s two most recent occurrences and replaces the page with the least –second – most – recent occurrence.
10
Cache Replacement Algorithms Drawbacks –Using a priority queues, which gives it logarithmic complexity. –It must tune the parameter – correlated information period, That captures the amount of time a page that has only been seen once recently should be kept in the cache. 3.2Q is an improved method with constant complexity that is used to alleviate (overcome) logarithmic complexity. –Similar to LRU-2, except that it uses simple LRU list instead of priority queue. –ARC’s low computational overhead resembles 2Q’s. –Drawback: –Tuning the parameter – correlated information period.
11
Cache Replacement Algorithms The low inter reference recency set’s (LIRS) design builds upon 2Q. –LIRS maintains a variable size LRU stack of unbounded size that serves as a cache directory. –LIRS selects a few top pages from the directory, depending on two parameters that affects its performance. Drawback –Due to a certain stack pruning operation, LIRS has an average – case rather than worst – case constant – time overhead, which is a significant drawback.
12
Cache Replacement Algorithms Summary In contrast to LRU-2, 2Q, LIRS, LRFU algorithms – which all require offline selection of tunable parameters – ARC policy functions online and is completely self tuning. ARC doesn’t suffer from periodic rescaling parameters since it doesn’t maintain frequency count. Unlike LIRS, ARC doesn’t require potentially unbounded space overhead. ARC, LIRS, and 2Q have constant time implementation complexity while LFU and LRU-2 have logarithmic implementation complexity.
13
Cache and History Assume that c is the cache size in pages Two policies were introduced: 1.DBL(2c) policy, this policy memorizes 2c pages and manages an imaginary cache of size 2c. 2.A class (c) policy of cache replacement polices. –DBL(2c) maintains two LRU lists: L1 which contains the pages that have been seen recently only once. L2 which contains pages that have been seen recently at least twice. –A page resides in L1 if: it has been requested exactly once since the last time it was removed from it was requested only once and never removed from –A page resides in L2 if: It has been requested more than once since the last time it was removed from it was requested more than once and was never removed from
14
Cache and History The policy functions as follows: –If L1 contains exactly C pages, replace the LRU page in L1, otherwise replace the LRU page in L2. –Initially, the lists are empty: L1 = L2 = –if a requested page resides in, then the page will be moved to the MRU positions of L2, otherwise. –The page will be moved to the MRU position of L1. In the later case, If |L1| = C, then, the policy removes the LRU member of L1 If |L1| < C and |L1| + |L2| = 2C the policy removes the LRU member of L2. The algorithm tries to equalize the sizes of the two lists. The algorithm ensures that, the following invariants will hold always 0<= |L1| + |L2| <=2C and 0<= |L1| <= C. –II(c) are used to track all the 2C items that would be present in a cache of size 2C managed by DBL(2C), but at most C are actually kept in cache.
15
Cache and History L1 is divided into: –T1, contains the top or most-recent pages in L1 –B1, contains the bottom or least-recent pages in L1. L2 is also partitioned into T2 top and B2 bottom, subject to the following conditions: –If |L1| + |L2| < C, then B1 = B2 =. –If |L1| + |L2| > C-1, then |T1| + |T2| = C. –For i=1,2, either T i or B i is empty or the LRU page in T i is more recent than MRU page in B i. For all traces and at each time, contains exactly those pages, that would be cached under a policy in the class. Pages in T1 and T2 reside in the cache directory and in the cache. History pages in B1 and B2 reside only in the cache directory
16
Cache and History Once the cache directory has 2c pages, and will both contain exactly C pages. ARC leverages the extra history information in to effect a continual adaptation.
17
Adaptive replacement cache A fixed replacement cache FRC p ( c ) with a tunable parameter p, 0<= p <= C, in the class ( c ) attempts to keep in cache the p most recent pages from L1 and C – p most recent pages in L2. –If either |T1| > p or (|T1| = p and x B2), replace the LRU page in T1. –If either |T1| < p or (|T1| = p and x B1), replace the LRU page in T2. P represents the current target size for the list T1. ARC behaves like FRC p ( c ), except that p changes adaptively. A hit in B1 suggests an increase in the size of T1. A hit in B2 suggests an increase in the size of T2. The continual updates of P effect these increases. The learning rates depend on the relative sizes of B1 and B2 ARC attempts to keep T1 and B2 to roughly the same size. ARC attempts to keep T2 and B1 to roughly the same size. On a hit in B1, p increments by max{|B1|/|B2|, 1}, But doesn’t exceed C.
18
Adaptive replacement cache On a hit in B2, p decrements by max{|B1|/|B2|, 1}, but it never drops below zero. ARC never stops adapting, so it always responds to workload changes from IRM to SDD and vice versa. Because = always contain the LRU C pages, LRU cannot experience cache hits unbeknownst to ARC, but ARC can and often does experience cache hits unbeknownst to LRU. If a page is not in, the system places it at the top of L1. from there, it makes its way the LRU position in L1, unless requested once again prior to being evicted from L1, it never enters L2. ARC is scan resistant, since long sequence of read-once requests passes through L1 without flushing out possibly important pages in L2.
20
Experimental results Comparing the performance of various algorithms on various traces OLTP contains an hour’s worth of references to a CodasyI database. Collecting P1 through P14 over several months from a Windows NT. –COnCat, obtained by concatenating traces P1 through P14. –Merge(P), obtained by merging them using time stamps on each request. –DS1, a seven day trace, from a commercial database server –All these traces have a page size of 512byts. Capture a trace of the storage performance Council’s SPC1-like synthetic benchmark, which contains long sequential scans in addition to random access and has a page size of 4Kbytes.
21
Experimental results Considering three traces – S1, S2, and S3 – that perform desk read accesses initiated by a large commercial search engine in response to various Web search requests over several hours. The traces have a page size of 4Kbytes. Merge(S), obtained by merging S1 through S3 using time stamp on each request. All hit ratio are cold starts and are in percentages.
22
The tunable parameters for FBR and LIRS are set according to their original description. The tunable parameters for LRU-2, 2Q, and LRFU were selected offline for the best result for each cache size. ARC requires no user specified parameters. ARC outperforms LRU, LFU, FBR, LIRS and MQ. ARC performs as well as LRU-2, 2Q, LRFU, and MIN with their respective offline best parameters values.
23
The tunable parameter for MQ were set online The tunable parameters for other algorithms were chosen offline to be optimized for each cache size and workload. ARC outperforms LRU and performs nearly as well as competitively against 2Q, LRU-2, LRFU, LIRS, and MQ
24
Comparing ARC with LRU for all traces with practically relevant sizes Due to scan resistant, ARC outperforms LRU sometimes, dramatically ARC, working online, performs closely to and sometimes better than FRC p with best offline fixed choice of the parameter P for all traces.
25
ARC and LRU hit ratio(in percentages) vs Cache size (in pages) in log-log scale for traces P6, spc1-like, and Merge(S)
26
Conclusion The results show that the self – tuning, lower-overhead, scan- resistant ARC cache-replacement policy outperforms LRU. Using Adaptation in a cache replacement policy can produce considerable performance improvements in modern caches.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.