Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects Maged M. Michael Presented by Abdulai Sei.

Slides:



Advertisements
Similar presentations
Hazard Pointers: Safe Memory Reclamation of Lock-Free Objects
Advertisements

Wait-Free Queues with Multiple Enqueuers and Dequeuers
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects
CS510 – Advanced Operating Systems 1 The Synergy Between Non-blocking Synchronization and Operating System Structure By Michael Greenwald and David Cheriton.
Maged M. Michael, “Hazard Pointers: Safe Memory Reclamation for Lock- Free Objects” Presentation Robert T. Bauer.
Scalable and Lock-Free Concurrent Dictionaries
Wait-Free Reference Counting and Memory Management Håkan Sundell, Ph.D.
Performance Evaluation of Lock-free Data Structures on GPUs Performance Evaluation of Lock-free Data Structures on GPUs
A Lock-Free Multiprocessor OS Kernel1 Henry Massalin and Calton Pu Columbia University June 1991 Presented by: Kenny Graunke.
5. Memory Management From: Chapter 5, Modern Compiler Design, by Dick Grunt et al.
Locality-Conscious Lock-Free Linked Lists Anastasia Braginsky & Erez Petrank 1.
Lightweight Remote Procedure Call Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented by Alana Sweat.
Concurrent Data Structures in Architectures with Limited Shared Memory Support Ivan Walulya Yiannis Nikolakopoulos Marina Papatriantafilou Philippas Tsigas.
Multi-Object Synchronization. Main Points Problems with synchronizing multiple objects Definition of deadlock – Circular waiting for resources Conditions.
Progress Guarantee for Parallel Programs via Bounded Lock-Freedom Erez Petrank – Technion Madanlal Musuvathi- Microsoft Bjarne Steensgaard - Microsoft.
Lock-free Cuckoo Hashing Nhan Nguyen & Philippas Tsigas ICDCS 2014 Distributed Computing and Systems Chalmers University of Technology Gothenburg, Sweden.
Transactional Memory Yujia Jin. Lock and Problems Lock is commonly used with shared data Priority Inversion –Lower priority process hold a lock needed.
Introduction to Lock-free Data-structures and algorithms Micah J Best May 14/09.
Computer Laboratory Practical non-blocking data structures Tim Harris Computer Laboratory.
CS510 Advanced OS Seminar Class 10 A Methodology for Implementing Highly Concurrent Data Objects by Maurice Herlihy.
CS510 Concurrent Systems Class 2 A Lock-Free Multiprocessor OS Kernel.
CS510 Concurrent Systems Class 13 Software Transactional Memory Should Not be Obstruction-Free.
CS533 - Concepts of Operating Systems 1 Class Discussion.
User-Level Interprocess Communication for Shared Memory Multiprocessors Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented.
Simple, Fast and Practical Non- Blocking and Blocking Concurrent Queue Algorithms Maged M. Michael & Michael L. Scott Presented by Ahmed Badran.
B+ Review. B+ Tree: Most Widely Used Index Insert/delete at log F N cost; keep tree height- balanced. (F = fanout, N = # leaf pages) Minimum 50% occupancy.
SUPPORTING LOCK-FREE COMPOSITION OF CONCURRENT DATA OBJECTS Daniel Cederman and Philippas Tsigas.
Algorithms for Synchronization and Consistency in Concurrent System Services Anders Gidenstam Distributed Computing and Systems group, Department of Computer.
1 Lock-Free Linked Lists Using Compare-and-Swap by John Valois Speaker’s Name: Talk Title: Larry Bush.
Practical and Lock-Free Doubly Linked Lists Håkan Sundell Philippas Tsigas.
Tornado: Maximizing Locality and Concurrency in a Shared Memory Multiprocesor Operating System By: Ben Gamsa, Orran Krieger, Jonathan Appavoo, Michael.
CS510 Concurrent Systems Jonathan Walpole. A Lock-Free Multiprocessor OS Kernel.
A Two-Lock Concurrent Queue Algorithm Maged M. Michael, Michael L. Scott University of Rochester Presented by Hussain Tinwala.
Håkan Sundell, Chalmers University of Technology 1 NOBLE: A Non-Blocking Inter-Process Communication Library Håkan Sundell Philippas.
Eraser: A Dynamic Data Race Detector for Multithreaded Programs STEFAN SAVAGE, MICHAEL BURROWS, GREG NELSON, PATRICK SOBALVARRO, and THOMAS ANDERSON Ethan.
Scheduler Activations: Effective Kernel Support for the User- Level Management of Parallelism. Thomas E. Anderson, Brian N. Bershad, Edward D. Lazowska,
A Qualitative Survey of Modern Software Transactional Memory Systems Virendra J. Marathe Michael L. Scott.
Scheduler Activations: Effective Kernel Support for the User-level Management of Parallelism Thomas E. Anderson, Brian N. Bershad, Edward D. Lazowska,
November 15, 2007 A Java Implementation of a Lock- Free Concurrent Priority Queue Bart Verzijlenberg.
The Performance of Spin Lock Alternatives for Shared-Memory Multiprocessors THOMAS E. ANDERSON Presented by Daesung Park.
Challenges in Non-Blocking Synchronization Håkan Sundell, Ph.D. Guest seminar at Department of Computer Science, University of Tromsö, Norway, 8 Dec 2005.
Non-blocking Data Structures for High- Performance Computing Håkan Sundell, PhD.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
A Methodology for Creating Fast Wait-Free Data Structures Alex Koganand Erez Petrank Computer Science Technion, Israel.
DOUBLE INSTANCE LOCKING A concurrency pattern with Lock-Free read operations Pedro Ramalhete Andreia Correia November 2013.
Wait-Free Multi-Word Compare- And-Swap using Greedy Helping and Grabbing Håkan Sundell PDPTA 2009.
The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with Linux Guniguntala et al.
CS510 Concurrent Systems Jonathan Walpole. A Methodology for Implementing Highly Concurrent Data Objects.
Software Transactional Memory Should Not Be Obstruction-Free Robert Ennals Presented by Abdulai Sei.
CS510 Concurrent Systems Jonathan Walpole. RCU Usage in Linux.
A Methodology for Implementing Highly Concurrent Data Objects by Maurice Herlihy Slides by Vincent Rayappa.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
November 27, 2007 Verification of a Concurrent Priority Queue Bart Verzijlenberg.
An algorithm of Lock-free extensible hash table Yi Feng.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects MAGED M. MICHAEL PRESENTED BY NURIT MOSCOVICI ADVANCED TOPICS IN CONCURRENT PROGRAMMING,
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
MIT Lincoln Laboratory XYZ 3/11/2005 Introduction to a Wait-Free Hash Table Hash Table Key-Value pair stores and retrieves data Three Core Functions:
Garbage Collecting the World Presentation: Mark Mastroieni Authors: Bernard Lang, Christian Queinne, Jose Piquer.
Hazard Pointers C++ Memory Ordering Issues
By Michael Greenwald and David Cheriton Presented by Jonathan Walpole
Håkan Sundell Philippas Tsigas
Lock-Free Linked Lists Using Compare-and-Swap
CS510 Concurrent Systems Jonathan Walpole.
CS510 Concurrent Systems Jonathan Walpole.
CS510 - Portland State University
Software Transactional Memory Should Not be Obstruction-Free
CS510 Advanced Topics in Concurrency
CS510 Concurrent Systems Jonathan Walpole.
Dynamic Binary Translators and Instrumenters
Presentation transcript:

Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects Maged M. Michael Presented by Abdulai Sei

Recap So far we have seen many lock-free dynamic objects algorithms How many reclaim memory of reused nodes? How many of these return memory to the operating system? What happens if a thread frees a node and another thread has a pointer to that node?

Related paper - Type Stable Memory (TSM) Similar concept to HP, non-blocking Three basic extension to conventional type implementation type descriptor remains a valid instance of the type even when inactive (in the free list) allows multiple memory allocation for the same type type change over time (descriptor has to be inactive before reallocation) Guarantee a pointer to point to a descriptor of the type readers can continue reading but does not guarantee correct data

Hazard Pointers (HP) A memory management methodology that allows memory reclamation for arbitrary reuse Memory is finite and needs to be reused Thread failures and dead lock leave chunks of memory unclaimed for reuse by the operating system

HP Claims Suitable for user-level application as well as system level program without dependency on kernel or scheduler Very efficient algorithm for dynamic lock-free object Requires only single-word reads and writes Solves the ABA problem Wait-free

ABA Problem Common problem with CAS, CAS2, DCAS Affects almost all lock-free algorithms Thread A reads a value (XX) from a shared memory, then another thread B reads the same value XX, change it to XY and then back to XX. When thread A reads the value for the second time, it sees XX and assume it was not changed Must be prevented regardless of memory reclamation Applying HP to ABA-safe algorithm makes it safe

Methodology Based on the observation that A thread holds a small number of references References do not need further validation for accessing the content of dynamic nodes References are not ABA-prone Core ideas Single-writer multi-reader shared pointers called HP HP varies among threads – typically one to two Communicates with the algorithm through HP Consists of two parts One for processing retired nodes Memory reclamation and ABA prevention

Algorithm – (reader only) add1* READER add2 HP List (add2) – dereference add1

Algorithm – (reader + writer) add1* READER add2add3 add2 HP List WRITER (add2) – dereference add1 allocate add3 Deference add1 copy add2 to add3 modify add3

Algorithm (reader + writer) add1* READER add2add3 add2 HP List WRITER (add2) – reader has already deference add1* before writer start allocate add3 copy add2 to add3 modify add3 CAS retired add2

Questions for class Is the reader reading the right data after the writer perform CAS? See slide 13, the conditions Can the garbage collector free add2? Any new problems? yes, readers have to write to the HP list others?

Code

The Condition A thread announces to other threads when it assigns a reference to one of it HP Other threads refrain from reclaiming or reusing node At time t, each node n is in one of the states Allocated, reachable, removed, retired, free, unavailable, undefined A thread holds a reference to a node when it is safe Question: Can a thread create a new hazardous reference to a node when it is retired?

Applying HP Apply to existing lock-free algorithms based on conditions Examine the target algorithm Identify HP and hazard reference they use Determine where hazard reference is created and last hazard pointer that uses it Determine the max # that can be hazardous Insert the following in target algorithm Write the address of nodes that are target for reference to an unavailable hazard reference Validate the node is safe Example of existing algorithms to apply the use of HP FIFO Queues LIFO Stacks List-Based Sets and Hash Tables Single-Writer Multireader Dynamic Structures

Applications – FIFO queues

Applications – Lock-free stack using HP

Experiment Comparing performance of new methodology to lock-free memory management system FIFI queues, LIFO stacks, chaining hash table – all implemented using HP Comparison with commonly use locks Using test-and-test and set with exponential backoff Hash table with 100 separate locks IBM RS /6000 multiprocessor with 4 processors Align cache data structure Locks, single-word, double-word CAS implemented using LL/SC All implementation compiled at highest optimization Ran each experiment 5 times and reported the average

Performance Comparison

Conclusion HP provided unrestricted memory reclamation for dynamic lock- free objects Takes constant amortized time per retired node Uses only single-word instructions Comparable performance to that of lock-based implementation Both under no contention and no multiprogramming Outperform them significantly under moderate multiprogramming and/or contention Guarantee progress even if a thread fails or delays (prevent deadlock)