ARC (Adaptive Replacement Cache)

Slides:



Advertisements
Similar presentations
ARC: A self-tuning, low overhead Replacement Cache
Advertisements

Chapter 4 Memory Management Basic memory management Swapping
9.4 Page Replacement What if there is no free frame?
4.4 Page replacement algorithms
Song Jiang1 and Xiaodong Zhang1,2 1College of William and Mary
Page Replacement Algorithms
Seoul National University Archi & Network LAB LRFU (Least Recently/Frequently Used) Block Replacement Policy Sang Lyul Min Dept. of Computer Engineering.
Chapter 101 The LRU Policy Replaces the page that has not been referenced for the longest time in the past By the principle of locality, this would be.
Yannis Smaragdakis / 11-Jun-14 General Adaptive Replacement Policies Yannis Smaragdakis Georgia Tech.
The Performance Impact of Kernel Prefetching on Buffer Cache Replacement Algorithms (ACM SIGMETRIC 05 ) ACM International Conference on Measurement & Modeling.
ARC: A SELF-TUNING, LOW OVERHEAD REPLACEMENT CACHE
1 Cache and Caching David Sands CS 147 Spring 08 Dr. Sin-Min Lee.
Outperforming LRU with an Adaptive Replacement Cache Algorithm Nimrod megiddo Dharmendra S. Modha IBM Almaden Research Center.
CS4432: Database Systems II Buffer Manager 1. 2 Covered in week 1.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Module 9: Virtual Memory
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Cache Memory By JIA HUANG. "Computer Science has only three ideas: cache, hash, trash.“ - Greg Ganger, CMU.
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management – 4 Page Replacement Algorithms CS 342 – Operating Systems.
Memory Management Virtual Memory Page replacement algorithms
1 Virtual Memory Sample Questions Project 3 – Build Pthread Lib Extra Office Hour: Wed 4pm-5pm HILL 367 Recitation 6.
Lecture 33: Chapter 5 Today’s topic –Cache Replacement Algorithms –Multi-level Caches –Virtual Memories 1.
Virtual Memory.
O RERATıNG S YSTEM LESSON 10 MEMORY MANAGEMENT II 1.
Memory Management Page replacement algorithms, segmentation Tanenbaum, ch. 3 p Silberschatz, ch. 8, 9 p
Page 19/17/2015 CSE 30341: Operating Systems Principles Optimal Algorithm  Replace page that will not be used for longest period of time  Used for measuring.
Page Replacement in Real Systems Questions answered in this lecture: How can the LRU page be approximated efficiently? How can users discover the page.
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
Chapter Twelve Memory Organization
Chapter 21 Virtual Memoey: Policies Chien-Chung Shen CIS, UD
Page Replacement Algorithms Memory Management. Optimal Page Replacement ▪The label for each page in memory is labeled with the number of instructions.
10/18: Lecture topics Memory Hierarchy –Why it works: Locality –Levels in the hierarchy Cache access –Mapping strategies Cache performance Replacement.
CSIT 301 (Blum)1 Cache Based in part on Chapter 9 in Computer Architecture (Nicholas Carter)
3-May-2006cse cache © DW Johnson and University of Washington1 Cache Memory CSE 410, Spring 2006 Computer Systems
Operating Systems CMPSC 473 Virtual Memory Management (3) November – Lecture 20 Instructor: Bhuvan Urgaonkar.
Clock-Pro: An Effective Replacement in OS Kernel Xiaodong Zhang College of William and Mary.
Demand Paging Reference Reference on UNIX memory management
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
CS 149: Operating Systems March 5 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
1 Page Replacement Algorithms. 2 Virtual Memory Management Fundamental issues : A Recap Key concept: Demand paging  Load pages into memory only when.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
PAGE REPLACEMNT ALGORITHMS FUNDAMENTAL OF ALGORITHMS.
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Logistics Homework 5 will be out this evening, due 3:09pm 4/14
Chapter 9: Virtual Memory – Part I
LRFU (Least Recently/Frequently Used) Block Replacement Policy
Chapter 21 Virtual Memoey: Policies
Demand Paging Reference Reference on UNIX memory management
Module 9: Virtual Memory
Lecture 10: Buffer Manager and File Organization
Demand Paging Reference Reference on UNIX memory management
Page Replacement.
5: Virtual Memory Background Demand Paging
Clock-Pro: An Effective Replacement in OS Kernel
Practical Session 8, Memory Management 2
CSC3050 – Computer Architecture
Computer Architecture
Page Replacement FIFO, LIFO, LRU, NUR, Second chance
Operating Systems CMPSC 473
Module IV Memory Organization.
Module 9: Virtual Memory
Chapter 9: Virtual Memory CSS503 Systems Programming
Andy Wang Operating Systems COP 4610 / CGS 5765
Virtual Memory CSE451 Andrew Whitaker.
Practical Session 9, Memory Management continues
Virtual Memory.
Presentation transcript:

ARC (Adaptive Replacement Cache) "We are therefore forced to recognize the possibility of constructing a hierarchy of memories, each of which has great capacity than the preceding but which is less quickly accessible." Von-Neumann, 1946. The selecting of the "victim" to be taken out of the faster memory has been traditionally done for decades by the LRU algorithm. The LRU is fast and easy for implementation, but can there be a better algorithm? 2.1 Advanced Operating Systems

2.2 Advanced Operating Systems Motivation The LRU is employed by: RAM/Cache Management Paging/Segmenting systems Web browsers and Web Proxies Middleware RAID Controller and regular Disk Drivers Databases Data Compression (e.g. LZW) Many other applications ARC was suggested by N. Megiddo and D. Modha of IBM Almaden Research center, San Jose, CA on 2003 and is better than LRU. 2.2 Advanced Operating Systems

2.3 Advanced Operating Systems LRU complexity LRU is implemented by a double linked list. When a page in the list is accessed, it will be moved from its place to the end of the list. When a new page is accessed, it will be put in the end of the list and the oldest page is taken out of the list. Both of the operation are of an O(1) complexity. removing pointer adding pointer oldest newest 2.3 Advanced Operating Systems

2.4 Advanced Operating Systems LRU disadvantages The fundamental locality principle claims that if a process visits a location in the memory, it will probably revisit the location and its neighborhood soon. The advanced locality principle claims that the probability of a revisiting will be increased if the number of the visits is bigger. LRU supports just the fundamental locality principle. What will happen if a process scans a huge database? 2.4 Advanced Operating Systems

2.5 Advanced Operating Systems LFU LFU replaces the least frequently used pages. LFU takes into account the advanced locality principle and a scan of a huge database will not be a trouble, HOWEVER… LFU is implemented by a heap; hence it has a logarithmic complexity for adding or removing a page from the heap and also for updating a place of a page in the heap. Stale pages can remain a long time in the memory, while "hot" pages can be mistakenly taken out. 2.5 Advanced Operating Systems

2.6 Advanced Operating Systems LRU vs. LFU LRU was suggested on 1965 and LFU on 1971. The logarithmic complexity of LFU was the main reason for its impracticability. LFU had a periodic check for the stale pages. This solved the stale pages problem. But, it made the performance even worse. LRU beat LFU; thus, LFU has been pushed into a corner, until 1993, when O'Neil revisits LFU in order to develop the LRU-K technique. 2.6 Advanced Operating Systems

2.7 Advanced Operating Systems LRU-K LRU-K memorizes the times for each cache page's k most recent references and replaces the page with the least kth most recent references. If there is no kth reference, LRU-K will consider the reference to be infinite (The oldest). LRU-K retains a history of references for pages that are not currently present in the memory. 2.7 Advanced Operating Systems

2.8 Advanced Operating Systems LRU-K Pro. & Con. When a page is referenced, it will typically not be moved to the end of the list; hence a linked list cannot be good for the implementation and a heap is needed  logarithmic complexity. Scanning a huge database will not be a trouble like with LFU, but LRU-K outperforms LFU, because stale pages are handled better. LRU-K maintains the advanced locality model, but did not succeed to beat LRU because of the complexity. 2.8 Advanced Operating Systems

2.9 Advanced Operating Systems 2Q On 1994 Johnson & Shasha suggested an improvement to LRU-2. 2Q has two queues A1 and Am: On the first reference to a page, 2Q places the page in the A1 queue. If a page is accessed again when it is in A1 or Am queues, the page will be moved to the end of Am queue. The sizes of A1 and Am are constants (e.g. 20% of the cache for A1 and 80% for Am). When a new page is added to one of the queues, an old page from the same queue will be removed if need. 2.9 Advanced Operating Systems

2.10 Advanced Operating Systems 2Q Pro. & Con. 2Q is implemented by linked lists  O(1) complexity. 2Q has just two queues; thus it just partially adapts the advanced locality model. The execution time of 2Q is about 25% longer than LRU, but it gives 5%-10% better hit ratio. These results were not convincing enough. 2.10 Advanced Operating Systems

2.11 Advanced Operating Systems The Clock Algorithm The memory spaces holding the pages can be regarded as a circular buffer and the replacement algorithm cycles through the pages in the circular buffer, like the hand of a clock. Each page is associated with a bit, called reference bit, which is set by hardware whenever the page is accessed. 2.11 Advanced Operating Systems

Choosing victims by Clock When it is necessary to replace a page to service a page fault, the page pointed to by the hand is checked. If its reference bit is unset, the page is replaced. Otherwise, the algorithm resets its reference bit and keeps moving the hand to the next page. Linux and Windows employ Clock. 2.12 Advanced Operating Systems

2.13 Advanced Operating Systems LRFU On 2001 Lee at el. suggested a combined algorithm of LRU and LFU named LRFU. LRFU can be tuned to be close to LRU or be close to LFU. LRFU's clock is expressed by the number of the pages that have been accessed. I.e. the time is incremented by one on each page reference. 2.13 Advanced Operating Systems

Combined Recency and Frequency Let us define Combined Recency and Frequency (CRF) as: where tc is the current time. b is the block id. tbi is the ith time that block b has been referenced. F(x) is the function 2-x. k is the number of the times that the block has been referenced. 2.14 Advanced Operating Systems

2.15 Advanced Operating Systems The F(x) function When LRFU has to take a page out of the memory, it will choose the page with the minimal CRF. If F(x) is a constant for any x, LRFU will exactly act like LFU; hence if  is set to 0, LRFU will be LFU. If F(x) holds for any i and any k where ki+1, LRFU will exactly act like LRU; hence if  is set to 1, LRFU will be LRU. 2.15 Advanced Operating Systems

2.16 Advanced Operating Systems LRFU Performance According to experimental results,  is usually set to a very small numbers less than 0.001. This means LRFU is LFU with a slight touch of LRU. LRFU outperforms LRU, LFU, LRU-K and 2Q in hit rate. The pages are kept in a heap; hence the complexity of LRFU is O(log(n)). 2.16 Advanced Operating Systems

2.17 Advanced Operating Systems ARC Definitions Let c be the number of pages in the memory. L1 and L2 are two linked lists. L1 contains the pages that have been accessed just once, while L2 contains the pages that have been accessed at least twice. The allowed operations on L1 and L2 are the same operations that are allowed on an LRU linked list. 2.17 Advanced Operating Systems

2.18 Advanced Operating Systems ARC Policy 0|L1|+|L2| 2c 0|L1|c , L2 can be bigger than c. When a page is accessed; if the page is in L1L2, move it to the MRU of L2; otherwise move it to the MRU of L1. If adding the new page makes |L1|+|L2| >2c or |L1|>c; if L1 (before the addition) contains less than c pages, take out the LRU of L2; otherwise take out the LRU of L1. 2.18 Advanced Operating Systems

2.19 Advanced Operating Systems Lists' Partitions |L1|+|L2| 2c, but the size of the memory is just c. Let T1 be the most recent pages in the memory and B1 be the least recent pages in the memory. Similarly, L2 is partitioned into T2 and B2. T1T2 contains the pages that are actually in the memory. 2.19 Advanced Operating Systems

2.20 Advanced Operating Systems Which page is taken out When a page is moved from a "T" list to a "B" list, it will be taken out of the memory. Let p be the current target size for the list T1. If |T1|>p, move the LRU of T1 to be the MRU of B1. If |T1|<p, move the LRU of T2 to be the MRU of B2 . If |T1|=p, If the accessed page has been in B2, move the LRU of T1 to be the MRU of B1. (Because p is going to be decremented). If the accessed page has been in B1 or has not been in the memory, move the LRU of T2 to be the MRU of B2. 2.20 Advanced Operating Systems

2.21 Advanced Operating Systems Setting P If there is a hit in T1 or T2, do nothing. If there is a hit in B1 If the size of B1 is at least the size of B2, increment p by 1; otherwise, increment p by |B2|/|B1|. If there is a hit in B2 If the size of B2 is at least the size of B1, decrement p by 1; otherwise, decrement p by |B1|/|B2|. The increments and the decrements are subject to the stipulation 0pc The idea is to "invest" in the list that is performing the best. 2.21 Advanced Operating Systems

2.22 Advanced Operating Systems ARC Advantages When scanning a huge database, there are no hits; hence p will not be modified and the pages in T2, will remain in the memory  Better than LRU. Stale pages do not remain in the memory  Better than LFU. ARC is about 10%-15% more time consuming than LRU, but the hit ratio is in average about as twice as LRU. Low space overhead for the "B" lists. 2.22 Advanced Operating Systems

2.23 Advanced Operating Systems Conclusions ARC captures both "recency" and "frequency". ARC was first introduced at 2003, but the journal paper was published at 2004. Folklore holds that Operating Systems has 3 principles: Hash, Cache and Trash. ARC improves the caching; hence so significant. 2.23 Advanced Operating Systems