Why The Grass May Not Be Greener On The Other Side: A Comparison of Locking vs. Transactional Memory Written by: Paul E. McKenney Jonathan Walpole Maged.

Slides:



Advertisements
Similar presentations
Transactional Memory Parag Dixit Bruno Vavala Computer Architecture Course, 2012.
Advertisements

Concurrency: Mutual Exclusion and Synchronization Chapter 5.
CS510 – Advanced Operating Systems 1 The Synergy Between Non-blocking Synchronization and Operating System Structure By Michael Greenwald and David Cheriton.
Transactional Memory Supporting Large Transactions Anvesh Komuravelli Abe Othman Kanat Tangwongsan Hardware-based.
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Concurrency The need for speed. Why concurrency? Moore’s law: 1. The number of components on a chip doubles about every 18 months 2. The speed of computation.
Pessimistic Software Lock-Elision Nir Shavit (Joint work with Yehuda Afek Alexander Matveev)
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
Paul E. McKenney, IBM Linux Technology Center
PARALLEL PROGRAMMING with TRANSACTIONAL MEMORY Pratibha Kona.
“THREADS CANNOT BE IMPLEMENTED AS A LIBRARY” HANS-J. BOEHM, HP LABS Presented by Seema Saijpaul CS-510.
Concurrency: Mutual Exclusion and Synchronization Why we need Mutual Exclusion? Classical examples: Bank Transactions:Read Account (A); Compute A = A +
The Performance of Spin Lock Alternatives for Shared-Memory Microprocessors Thomas E. Anderson Presented by David Woodard.
1 MetaTM/TxLinux: Transactional Memory For An Operating System Hany E. Ramadan, Christopher J. Rossbach, Donald E. Porter and Owen S. Hofmann Presenter:
Lock vs. Lock-Free memory Fahad Alduraibi, Aws Ahmad, and Eman Elrifaei.
1 Concurrent and Distributed Systems Introduction 8 lectures on concurrency control in centralised systems - interaction of components in main memory -
1 Lecture 24: Transactional Memory Topics: transactional memory implementations.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
CS510 Concurrent Systems Class 13 Software Transactional Memory Should Not be Obstruction-Free.
TxLinux: Using and Managing Hardware Transactional Memory in an Operating System Christopher J. Rossbach, Owen S. Hofmann, Donald E. Porter, Hany E. Ramadan,
Christopher J. Rossbach, Owen S. Hofmann, Donald E. Porter, Hany E. Ramadan, Aditya Bhandari, and Emmett Witchel - Presentation By Sathish P.
1 Concurrency: Deadlock and Starvation Chapter 6.
PRASHANTHI NARAYAN NETTEM.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Highly Available ACID Memory Vijayshankar Raman. Introduction §Why ACID memory? l non-database apps: want updates to critical data to be atomic and persistent.
Concurrency: Deadlock and Starvation Chapter 6. Goal and approach Deadlock and starvation Underlying principles Solutions? –Prevention –Detection –Avoidance.
1 Concurrency: Deadlock and Starvation Chapter 6.
View-Oriented Parallel Programming for multi-core systems Dr Zhiyi Huang World 45 Univ of Otago.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Integrating and Optimizing Transactional Memory in a Data Mining Middleware Vignesh Ravi and Gagan Agrawal Department of ComputerScience and Engg. The.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
COMP 111 Threads and concurrency Sept 28, Tufts University Computer Science2 Who is this guy? I am not Prof. Couch Obvious? Sam Guyer New assistant.
WG5: Applications & Performance Evaluation Pascal Felber
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
CSE 451: Operating Systems Section 5 Midterm review.
Kernel Locking Techniques by Robert Love presented by Scott Price.
CS510 Concurrent Systems Why the Grass May Not Be Greener on the Other Side: A Comparison of Locking and Transactional Memory.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Debugging Threaded Applications By Andrew Binstock CMPS Parallel.
CS510 Concurrent Systems Jonathan Walpole. RCU Usage in Linux.
© 2008 Multifacet ProjectUniversity of Wisconsin-Madison Pathological Interaction of Locks with Transactional Memory Haris Volos, Neelam Goyal, Michael.
CS333 Intro to Operating Systems Jonathan Walpole.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
On Transactional Memory, Spinlocks and Database Transactions Khai Q. Tran Spyros Blanas Jeffrey F. Naughton (University of Wisconsin Madison)
CSC Multiprocessor Programming, Spring, 2012 Chapter 10 – Avoiding Liveness Hazards Dr. Dale E. Parson, week 11.
James Larus and Christos Kozyrakis
Sarah Diesburg Operating Systems COP 4610
Background on the need for Synchronization
Minh, Trautmann, Chung, McDonald, Bronson, Casper, Kozyrakis, Olukotun
PHyTM: Persistent Hybrid Transactional Memory
Why The Grass May Not Be Greener On The Other Side: A Comparison of Locking vs. Transactional Memory By McKenney, Michael, Triplett and Walpole.
Faster Data Structures in Transactional Memory using Three Paths
CSC Multiprocessor Programming, Spring, 2011
Changing thread semantics
Christopher J. Rossbach, Owen S. Hofmann, Donald E. Porter, Hany E
Lecture 2 Part 2 Process Synchronization
Hybrid Transactional Memory
Computer Science & Engineering Electrical Engineering
Software Transactional Memory Should Not be Obstruction-Free
CSCI1600: Embedded and Real Time Software
Why Threads Are A Bad Idea (for most purposes)
CS333 Intro to Operating Systems
CSCI1600: Embedded and Real Time Software
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Advanced Operating Systems (CS 202) Memory Consistency and Transactional Memory Feb. 6, 2019.
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Why The Grass May Not Be Greener On The Other Side: A Comparison of Locking vs. Transactional Memory Written by: Paul E. McKenney Jonathan Walpole Maged M. Michael Josh Triplett Presented by: Jacob Lear (Some slides borrowed from Dr. Walpole’s lectures)

Review: Why Do Concurrent Programming? Hardware has been forced down the path of concurrency: – Can’t make cores much faster – Can put more than one core on a chip Concurrent programming is required for scalable performance of software on multi- core systems – Synchronization performance and scalability has become a critical issue

Review: Lock-Based Synchronization Pessimistic concurrency control Simple approach – Identify shared data – Associate lock with data – Acquire lock before use – Release lock after use Enforces mutual exclusion

Locking’s Strengths Intuitive and relatively easy to use. Can be used on existing commodity hardware. Well-defined locking API’s are standardized. Widespread usage and experienced user base. Contention effects are concentrated within locking primitives, allowing critical sections to run at full speed. Waiting on a lock minimally degrades performance of the rest of the system. Can protect a wide range of operations, including non-idempotent operations. Interacts naturally with a large variety of synchronization mechanisms. Interacts naturally with debuggers and other software tools. Ability to support disjoint access parallelism (with sufficient effort). Power-friendly.

Locking’s Weaknesses Prone to deadlock among other threads and interrupt handlers. – Implies non-composability. Susceptible to priority inversion. High contention on non-partitionable data structures. Can block other threads on thread failure. High synchronization overhead even at low levels of contention. Non-deterministic lock-acquisition latency.

Improving Locking Avoiding deadlock – Use a clear locking hierarchy. – Use conditional lock acquisition primitives. – Use deadlock detection and recovery. – Mask signals or interrupts while locks are held. – Avoid lock acquisition in interrupt handlers.

Improving Locking Avoiding priority inversion – Use priority inheritance. – Temporarily raise lock holder’s priority to that of highest priority task that might acquire lock. – Disable preemption. – Use RCU for readers.

Improving Locking Lock contention – Partition data and redesign algorithms, if possible. – Non-partitionable data structures are a problem. Lock overhead – Use RCU for readers. – Update-heavy workloads are a problem.

Improving Locking Avoiding convoying – Use scheduler-conscious synchronization. Resolving thread failures – Abort and restart. – Death detection and cleanup state. Addressing non-determinism – Use RCU for readers. – Use FIFO lock-acquisition primitives with limited threads.

Remaining Locking Challenges Better software tools for static analysis of lock- based software. Better software tools to evaluate lock contention. Better design rules for use of locking in large software systems. More work using locking with other synchronization methodologies. Need good locking algorithms for large update- heavy non-partitionable data structures.

Review: Transactional Memory Transactional Memory (TM) is a lock-free, non- blocking concurrency control mechanism based on transactions. TM allows programmers to define customized atomic operations that apply to multiple, independently chosen memory locations

TM’s Strengths TM is simple and elegant. Any sequence of memory loads and stores may be composed into a single atomic operation. Not prone to deadlock. Easier to create and understand multi-threaded code. Many implementations of TM are composable, meaning transactions can be nested. TM attains many of the performance and scalability benefits of fine-grained locking. Some implementations of TM are non-blocking.

TM’s Weaknesses Issues with non-idempotent operations, which would be performed multiple times on transaction retry. Expensive interaction with other synchronization mechanisms. Issues transactionalizing existing sequential programs resulting in excessive conflicts. Starvation of large transactions by smaller ones. Delay of high-priority processes via rollback of transactions due to confliction with those of a lower-priority process. Lack of support for HTM (Hardware Transactional Memory). Portability problems. Poor performance of STM (Software Transactional Memory). Privatization invalidated in high-performance STM. Poor interaction with many existing software tools.

Improving TM Adding support for non-idempotent operations – Include buffering mechanism within transaction. – Use pessimistic concurrency control. – “Inevitable transactions” Improving contention management – Use a contention manager with a good policy. – Convert read-only transactions to non- transactions.

Improving TM Supporting HTM – Need to wait for hardware to be available. – Fallback to STM when hardware not available. Improving STM performance – Relax non-blocking property. Improving debugger usage – Debug HTM using STM. – Requires better integration between HTM and STM.

Improving TM Addressing high overhead – Use TM for heavy-weight operations.

Conclusion Use the right tool for the job. Understand all the techniques, their strengths and weaknesses, and potential interactions.