Yannis Smaragdakis / 11-Jun-14 General Adaptive Replacement Policies Yannis Smaragdakis Georgia Tech.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

9.4 Page Replacement What if there is no free frame?
Page Replacement Algorithms
Page Replacement Algorithms
Online Algorithm Huaping Wang Apr.21
Cache and Virtual Memory Replacement Algorithms
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.
Chapter 11 – Virtual Memory Management
The Performance Impact of Kernel Prefetching on Buffer Cache Replacement Algorithms (ACM SIGMETRIC 05 ) ACM International Conference on Measurement & Modeling.
Page-replacement policies On some standard algorithms for the management of resident virtual memory pages.
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Virtual Memory: Page Replacement
A Survey of Web Cache Replacement Strategies Stefan Podlipnig, Laszlo Boszormenyl University Klagenfurt ACM Computing Surveys, December 2003 Presenter:
VM Design Issues Vivek Pai / Kai Li Princeton University.
ARC: A SELF-TUNING, LOW OVERHEAD REPLACEMENT CACHE
1 Improving Direct-Mapped Cache Performance by the Addition of a Small Fully-Associative Cache and Prefetch Buffers By Sreemukha Kandlakunta Phani Shashank.
Outperforming LRU with an Adaptive Replacement Cache Algorithm Nimrod megiddo Dharmendra S. Modha IBM Almaden Research Center.
Application-Controlled File Caching Policies Pei Cao, Edward W. Felten and Kai Li Presented By: Mazen Daaibes Gurpreet Mavi ECE 7995 Presentation.
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
03/31/2004CSCI 315 Operating Systems Design1 Allocation of Frames & Thrashing (Virtual Memory)
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Competitive Analysis.
Online Algor ithm Paging and Caching. Caching (paging) Structure of data storage Cache memory : Static RAM Level 1 Cache Level 2 Cache Main memory Hard.
CSC1016 Coursework Clarification Derek Mortimer March 2010.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management – 4 Page Replacement Algorithms CS 342 – Operating Systems.
Review CPSC 321 Andreas Klappenecker Announcements Tuesday, November 30, midterm exam.
Paging Algorithms Vivek Pai / Kai Li Princeton University.
OS Spring’04 Virtual Memory: Page Replacement Operating Systems Spring 2004.
Page Replacement Algorithms
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
The Hardness of Cache Conscious Data Placement Erez Petrank, Technion Dror Rawitz, Caesarea Rothschild Institute Appeared in 29 th ACM Conference on Principles.
1 Last Time: Paging Motivation Page Tables Hardware Support Benefits.
Lecture 33: Chapter 5 Today’s topic –Cache Replacement Algorithms –Multi-level Caches –Virtual Memories 1.
1/24 Algorithms for Generalized Caching Nikhil Bansal IBM Research Niv Buchbinder Open Univ. Israel Seffi Naor Technion.
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
Memory Management Page replacement algorithms, segmentation Tanenbaum, ch. 3 p Silberschatz, ch. 8, 9 p
IT253: Computer Organization
Performance Prediction for Random Write Reductions: A Case Study in Modelling Shared Memory Programs Ruoming Jin Gagan Agrawal Department of Computer and.
10/18: Lecture topics Memory Hierarchy –Why it works: Locality –Levels in the hierarchy Cache access –Mapping strategies Cache performance Replacement.
3-May-2006cse cache © DW Johnson and University of Washington1 Cache Memory CSE 410, Spring 2006 Computer Systems
By Andrew Yee. Virtual Memory Memory Management What is Page Replacement?
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
CS 3204 Operating Systems Godmar Back Lecture 21.
Lecture Topics: 11/24 Sharing Pages Demand Paging (and alternative) Page Replacement –optimal algorithm –implementable algorithms.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Operating Systems: Wrap-Up Questions answered in this lecture: What is an Operating System? Why are operating systems so interesting? What techniques can.
1 Chapter 5-1 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 153 Design of Operating Systems Winter 2015 Lecture 12: Page Replacement.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Test Loads Andy Wang CIS Computer Systems Performance Analysis.
1.Why we need page replacement? 2.Basic page replacement technique. 3.Different type of page replacement algorithm and their examples.
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Jonathan Walpole Computer Science Portland State University
Chapter 21 Virtual Memoey: Policies
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Morgan Kaufmann Publishers
Adaptive Cache Replacement Policy
Page Replacement.
Distributed Systems CS
What Happens if There is no Free Frame?
Zipf-Distributions & Caching
Greedy Algorithms / Caching Problem Yin Tat Lee
There’s not always room for one more. Brian Bershad
Contents Memory types & memory hierarchy Virtual memory (VM)
CSC3050 – Computer Architecture
Lecture 9: Caching and Demand-Paged Virtual Memory
ARC (Adaptive Replacement Cache)
Virtual Memory CSE451 Andrew Whitaker.
Presentation transcript:

Yannis Smaragdakis / 11-Jun-14 General Adaptive Replacement Policies Yannis Smaragdakis Georgia Tech

Yannis Smaragdakis / 11-Jun-14 My Agenda Present a cool idea in replacement algorithms Argue that replacement algorithms (and especially VM) are as much a part of ISMM as allocation/GC –same locality principles

Yannis Smaragdakis / 11-Jun-14 Overview Background: theory of replacement algorithms How to make adaptive algorithms with good performance and theoretical guarantees Experimental methodologies in replacement algorithms and evaluation of the idea

Yannis Smaragdakis / 11-Jun-14 Overview Background: theory of replacement algorithms How to make adaptive algorithms with good performance and theoretical guarantees Experimental methodologies in replacement algorithms and evaluation of the idea

Yannis Smaragdakis / 11-Jun-14 Storage Hierarchies Storage hierarchies are common in systems memory hierarchy registersCPU cachemain memory (VM cache + file cache)disk (VM + files)

Yannis Smaragdakis / 11-Jun-14 Management of Storage Hierarchies One level of the hierarchy acts as a fast cache for elements of the next A replacement algorithm determines how the cache is updated when it is full –the most recently used page must always be in the fast cache for easy access hence, when the cache is full, references to pages not in the cache must cause a replacement: a page in the cache needs to be removed called a fault or a miss

Yannis Smaragdakis / 11-Jun-14 Replacement Schematically afbeichmzkgxqp a b c d e f g h i j k … yr all blocks: buffer:

Yannis Smaragdakis / 11-Jun-14 LRU Replacement The Least Recently Used (LRU) algorithm has been predominant for decades simple and effective –no general purpose algorithm has consistently outperformed LRU supported by numerous results (both theoretical and experimental) Under LRU a cache of size M always holds the M most recently used elements at replacement time, the least recently used element in the cache is removed (evicted)

Yannis Smaragdakis / 11-Jun-14 Main Theoretical Results Much major theory is based on competitive analysis –how many faults an algorithm incurs relative to the faults of another algorithm –beautiful results with potential functions

Yannis Smaragdakis / 11-Jun-14 Example Theorems (slightly simplified) LRU will not suffer more than M times as many faults as OPT –M: memory size in blocks. Large number –OPT: optimal (clairvoyant) algorithm No other algorithm can do better LRU with twice as much memory as OPT will suffer at most twice the faults of OPT

Yannis Smaragdakis / 11-Jun-14 Example Proof Technique Theorem: LRU with twice as much memory as OPT will suffer at most twice the faults of OPT (Sleator and Tarjan, 84) Proof idea: 2M pages need to be touched between successive LRU faults on the same page. OPT will suffer at least M faults.

Yannis Smaragdakis / 11-Jun-14 Overview Background: theory of replacement algorithms How to make adaptive algorithms with good performance and theoretical guarantees Experimental methodologies in replacement algorithms and evaluation of the idea

Yannis Smaragdakis / 11-Jun-14 This Paper Note that all previous theoretical results are negative results for practical applications –but we dont care about OPT! We care about how close we can get to algorithms that work well in well-known cases –use the force (competitive analysis) to do good!

Yannis Smaragdakis / 11-Jun-14 This Paper Main result: take any two replacement algorithms A and B, produce adaptive replacement algorithm AB that will never incur more than twice (or three times) the faults of either A or B –for any input! We get the best of both worlds –result applies to any caching domain –thrashing avoidance is important, 2x guarantee is strong –we cant avoid the negative theoretical results, but we can improve good practical algorithms indefinitely

Yannis Smaragdakis / 11-Jun-14 Robustness Definition: we say R1 is c-robust w.r.t. R2, iff R1 always incurs at most c times as many faults as R2

Yannis Smaragdakis / 11-Jun-14 A Flavor of the Results Given A, B, create AB such that it simulates what A and B do on the input. Then at fault time, AB does the following: –if A also faults but B doesnt, imitate B i.e., evict a block not in Bs memory (one must exist) –otherwise imitate A i.e., evict a block not in As memory if one exists, evict the block that A evicts otherwise

Yannis Smaragdakis / 11-Jun-14 Surprising Result This very simple policy AB is 2-robust w.r.t. A and B! Proof idea: to fool AB into bad behavior, say w.r.t. A, A needs to suffer a fault. For every wrong decision, AB takes two faults to correct it. –formalized with two potential functions that count the difference in cache contents between AB and A or B

Yannis Smaragdakis / 11-Jun-14 More Sophisticated Adaptation We can create a more sophisticated AB –remember the last k faults for either A or B –imitate the algorithm that incurs fewer This is 3-robust relative to A and B (but will do better in practice) –the proof is quite complex, requires modeling the memory of past faults in the potential function –the result can probably be made tighter, but Im not a theoretician

Yannis Smaragdakis / 11-Jun-14 Implementation AB needs to maintain three times the data structures in the worst case –one to reflect current memory contents, two for the memory contents of A and B –but in practice these three structures have a high content overlap AB only performs work at fault time of A, B, or AB –if A, B are realizable, AB is realizable

Yannis Smaragdakis / 11-Jun-14 Overview Background: theory of replacement algorithms How to make adaptive algorithms with good performance and theoretical guarantees Experimental methodologies in replacement algorithms and evaluation of the idea

Yannis Smaragdakis / 11-Jun-14 Experimental Evaluation We show results in virtual memory (VM) management –boring area: old and well-researched, with little fundamental progress in the past 20 years –strong programmatic regularities in behavior (e.g., regular loops) unlike, e.g., web caching –we have the luxury to implement smart memory management algorithms

Yannis Smaragdakis / 11-Jun-14 Trace-Driven Memory Simulation Trace-driven simulation is a common technique for evaluating systems policies How does it work? –the sequence of all memory references of a running program is captured to a file –this sequence is then used to simulate the system behavior under the proposed policy

Yannis Smaragdakis / 11-Jun-14 Simulation Experiments in VM Standard experimental evaluation practices: –one program at a time otherwise scheduler adds too much noise. In practice VM dictates scheduling, not the other way common cases include one large application that pages anyway –large range of memories good algorithms are versatile, behave well in unpredictable situations

Yannis Smaragdakis / 11-Jun-14 Simulation Experiments in VM Standard experimental evaluation practices: –simulate idealized policies the whole point is to see what policy captures locality simulating policies with realizable algorithms is generally possible (although often non-trivial)

Yannis Smaragdakis / 11-Jun-14 Results of Evaluating Adaptivity Adaptive replacement is very successful Almost always imitates the best algorithm it adapts over –apply the adaptivity scheme repeatedly Never tricked by much Occasionally better than all component algorithms

Yannis Smaragdakis / 11-Jun-14 Example Results

Yannis Smaragdakis / 11-Jun-14 Example Results

Yannis Smaragdakis / 11-Jun-14 Example Results

Yannis Smaragdakis / 11-Jun-14 Example Results

Yannis Smaragdakis / 11-Jun-14 Conclusions Adaptivity is cool –it is very simple –it works –it offers good theoretical guarantees