Software Transactional Memory Kevin Boos. Two Papers Software Transactional Memory for Dynamic-Sized Data Structures (DSTM) – Maurice Herlihy et al –

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

Time-based Transactional Memory with Scalable Time Bases Torvald Riegel, Christof Fetzer, Pascal Felber Presented By: Michael Gendelman.
Optimistic Methods for Concurrency Control By : H.T. Kung & John T. Robinson Presenters: Munawer Saeed.
Impossibilities for Disjoint-Access Parallel Transactional Memory : Alessia Milani [Guerraoui & Kapalka, SPAA 08] [Attiya, Hillel & Milani, SPAA 09]
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Transactional Locking Nir Shavit Tel Aviv University (Joint work with Dave Dice and Ori Shalev)
Lock-Based Concurrency Control
Virendra J. Marathe, William N. Scherer III, and Michael L. Scott Department of Computer Science University of Rochester Presented by: Armand R. Burks.
Toward High Performance Nonblocking Software Transactional Memory Virendra J. Marathe University of Rochester Mark Moir Sun Microsystems Labs.
Hybrid Transactional Memory Nir Shavit MIT and Tel-Aviv University Joint work with Alex Matveev (and describing the work of many in this summer school)
Ali Saoud Object Based Transactional Memory. Introduction Resent trends go towards object based SMT because it’s dynamic Word-based STM systems are more.
Advanced Topics in Computing Winter 2009: Reliable Distributed Systems Oved Itzhak
Threading Part 4 CS221 – 4/27/09. The Final Date: 5/7 Time: 6pm Duration: 1hr 50mins Location: EPS 103 Bring: 1 sheet of paper, filled both sides with.
TOWARDS A SOFTWARE TRANSACTIONAL MEMORY FOR GRAPHICS PROCESSORS Daniel Cederman, Philippas Tsigas and Muhammad Tayyab Chaudhry.
DMITRI PERELMAN IDIT KEIDAR TRANSACT 2010 SMV: Selective Multi-Versioning STM 1.
1 Lecture 10: TM Pathologies Topics: scalable lazy implementation, paper on TM performance pathologies.
1 MetaTM/TxLinux: Transactional Memory For An Operating System Hany E. Ramadan, Christopher J. Rossbach, Donald E. Porter and Owen S. Hofmann Presenter:
Distributed Systems Fall 2010 Transactions and concurrency control.
1 Lecture 8: Eager Transactional Memory Topics: implementation details of eager TM, various TM pathologies.
CS510 Advanced OS Seminar Class 10 A Methodology for Implementing Highly Concurrent Data Objects by Maurice Herlihy.
1 Lecture 24: Transactional Memory Topics: transactional memory implementations.
Software Transactional Memory for Dynamic-sized Data Structures Maurice Herlihy, Victor Luchango, Mark Moir, William N. Scherer III Presented by: Irina.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
Transaction Processing: Concurrency and Serializability 10/4/05.
1 Lecture 6: TM – Eager Implementations Topics: Eager conflict detection (LogTM), TM pathologies.
CS510 Concurrent Systems Class 13 Software Transactional Memory Should Not be Obstruction-Free.
Language Support for Lightweight transactions Tim Harris & Keir Fraser Presented by Narayanan Sundaram 04/28/2008.
The Cost of Privatization Hagit Attiya Eshcar Hillel Technion & EPFLTechnion.
1 Lecture 9: TM Implementations Topics: wrap-up of “lazy” implementation (TCC), eager implementation (LogTM)
Software Transaction Memory for Dynamic-Sized Data Structures presented by: Mark Schall.
1 Lecture 7: Lazy & Eager Transactional Memory Topics: details of “lazy” TM, scalable lazy TM, implementation details of eager TM.
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.
An Introduction to Software Transactional Memory
Software Transactional Memory for Dynamic-Sized Data Structures Maurice Herlihy, Victor Luchangco, Mark Moir, William Scherer Presented by: Gokul Soundararajan.
Copyright 2007 Sun Microsystems, Inc SNZI: Scalable Non-Zero Indicator Yossi Lev (Brown University & Sun Microsystems Laboratories) Joint work with: Faith.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Software Transactional Memory Yoav Cohen Seminar in Distributed Computing Spring 2007 Yoav Cohen Seminar in Distributed Computing Spring 2007.
A Qualitative Survey of Modern Software Transactional Memory Systems Virendra J. Marathe Michael L. Scott.
Transactional Memory Lecturer: Danny Hendler.  Speeding up uni-processors is harder and harder  Intel, Sun (RIP), AMD, IBM now focusing on “multi-core”
CS5204 – Operating Systems Transactional Memory Part 2: Software-Based Approaches.
Optimistic Design 1. Guarded Methods Do something based on the fact that one or more objects have particular states  Make a set of purchases assuming.
Lowering the Overhead of Software Transactional Memory Virendra J. Marathe, Michael F. Spear, Christopher Heriot, Athul Acharya, David Eisenstat, William.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
Low-Overhead Software Transactional Memory with Progress Guarantees and Strong Semantics Minjia Zhang, 1 Jipeng Huang, Man Cao, Michael D. Bond.
On the Performance of Window-Based Contention Managers for Transactional Memory Gokarna Sharma and Costas Busch Louisiana State University.
Transactional Memory Lecturer: Danny Hendler. 2 2 From the New York Times…
Non-Blocking Concurrent Data Objects With Abstract Concurrency By Jack Pribble Based on, “A Methodology for Implementing Highly Concurrent Data Objects,”
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Transactional Locking Nir Shavit Tel Aviv University Joint work with Dave Dice and Ori Shalev.
Chapter 10 Recovery System. ACID Properties  Atomicity. Either all operations of the transaction are properly reflected in the database or none are.
The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with Linux Guniguntala et al.
Monitors and Blocking Synchronization Dalia Cohn Alperovich Based on “The Art of Multiprocessor Programming” by Herlihy & Shavit, chapter 8.
Software Transactional Memory Should Not Be Obstruction-Free Robert Ennals Presented by Abdulai Sei.
© 2008 Multifacet ProjectUniversity of Wisconsin-Madison Pathological Interaction of Locks with Transactional Memory Haris Volos, Neelam Goyal, Michael.
MULTIVIE W Slide 1 (of 21) Software Transactional Memory Should Not Be Obstruction Free Paper: Robert Ennals Presenter: Emerson Murphy-Hill.
Transactional Memory Student Presentation: Stuart Montgomery CS5204 – Operating Systems 1.
Adaptive Software Lock Elision
Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III
Minh, Trautmann, Chung, McDonald, Bronson, Casper, Kozyrakis, Olukotun
Part 2: Software-Based Approaches
Concurrency Control Techniques
Challenges in Concurrent Computing
Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III
A Qualitative Survey of Modern Software Transactional Memory Systems
Hybrid Transactional Memory
Software Transactional Memory Should Not be Obstruction-Free
Locking Protocols & Software Transactional Memory
Lecturer: Danny Hendler
Lecture 23: Transactional Memory
CSE 542: Operating Systems
Presentation transcript:

Software Transactional Memory Kevin Boos

Two Papers Software Transactional Memory for Dynamic-Sized Data Structures (DSTM) – Maurice Herlihy et al – Brown University & Sun Microsystems – 2003 Understanding Tradeoffs in Software Transactional Memory – Dave Dice and Nir Shavit – Sun Microsystems –

Outline  Dynamic Software Transactional Memory (DSTM)  Fundamental concepts  Java implementation + examples  Contention management  Performance evaluation  Understanding Tradeoffs in STM  Prior STM Work  Transaction Locking  Analysis and Observations 3

Software Transactional Memory Fundamental Concepts 4

Overview of STM  Synchronize shared data without locks  Why are locks bad?  Poor scalability, challenging, vulnerable  Transaction – a sequence of steps executed by a thread  Occurs atomically: commit or abort  Is linearizable: appears one-at-a-time  Slower than HTM  But more flexible 5

Dynamic STM  Prior STM designs were static  Transactions and memory usage must be pre-declared  DSTM allows dynamic creation of transactions  Transactions are self-aware and introspective  Creation of transactional objects is not a transaction  Perfect for dynamic data structures: trees, lists, sets  Deferred Update over Direct Update 6

Obstruction Freedom  Non-blocking progress condition  Stalling of one thread cannot inhibit others  Any thread running by itself eventually makes progress  Guarantees freedom from deadlock, not livelock  “Contention Managers” must ensure this  Allows for notion of priority  High-priority thread can either wait for a low-priority thread to finish, or simply abort it  Not possible with locks 7

Progress Conditions 8 wait free Lock-freeObstruction-free Some process makes progress in a finite number of steps Every process makes progress in a finite number of steps Some process makes progress, guaranteed if running in isolation

Implementation in Java 9

Transactional Objects  Transactional object: container for Java Object Counter c = new Counter(0); TMObject tm = new TMObject(c);  Classes that are wrapped in a TMObject must implement the TMCloneable interface  Logically-disjoint clone is needed for new transactions  Similar to copy-on-write 10

Using Transactions  TMThread is basic unit of parallel computation  Extends Java Thread, has standard run() method  For transactions: start, commit, abort, get status  Start a transaction with begin_transaction()  Transaction status is now Active  Transactions have read/write access to objects Counter counter = (Counter)tm0bject.open(WRITE); counter.inc(); // increment the counter  open() returns a cloned copy of counter 11

Committing Transactions  Commit will cause the transaction to “take effect”  Incremented value of counter will be fully written  But wait! Transactions can be inconsistent … 1. Transaction A is active, has modified object X and is about to modify object Y 2. Transaction B modifies both X and Y 3. Transaction A sees the “partial effect” of Transaction B  Old value of X, new value of Y 12

Validating Transactions  Avoid inconsistency: validate the transaction  When a transaction attempts to open() a TMObject, check if other active transactions have already opened it  If so, open() throws a DENIED exception  Avoids wasted work, the transaction can try again later  Could solve this with nested transactions… 13

Managing Transactional Objects 14

TMObject Details  Transactional Object ( TMObject ) has three fields  newObject  oldObject  transaction – reference to the last transaction to open the TMObject in WRITE mode  Transaction status – Active, Committed, or Aborted  All three fields must be updated atomically  Used for opening a transactional object without modifying the current version (along with clone() )  Most architectures do not provide such a function 15

Locators  Solution: add a level of indirection  Can atomically “swing” the start reference to a different Locator object with CAS 16

Open Committed TMObject 17

Open Aborted TMObject 18

Multi-Object Atomicity 19 transaction new object old object transaction new object old object transaction new object old object transaction status Data ACTIVE COMMITTED ABORTED

Open TMObject Read-Only  Does not create new Locator object, no cloning  Each thread keeps a read-only table  Key: (object, version) – (o, v)  Value: reference count  open(READ) increments reference count  release() decrements reference count 20

Commit TMObject  First, validate the transaction 1. For each (o, v) pair in the thread’s read-only table, check that v is still the most recently committed version of o 2. Check that the Transaction’s status is Active  Then call CAS to change Transaction status  Active  Committed 21

Conflict Reduction 22

Search in READ Mode  Useful for concurrent access to large data structures  Trees – walking nodes always starts from root  Multiple readers is okay, reduces contention  Fewer DENIED transactions, less wasted effort  Found the proper node?  Upgrade to WRITE mode for atomic access 23

Pre-commit release()  Transaction A can release an Object X opened for reading before committing the entire transaction  Other transactions will no longer conflict with X  Also useful for traversing shared data structures  Allows transactions to observe inconsistent state  Validations of that transaction will ignore Object X  The inconsistent transaction can actually commit!  Programmer is responsible – use with care! 24

Contention Management 25

Basic Principles  Obstruction freedom does not ensure progress  Must explicitly avoid livelock, starvation, etc.  Separation between correctness and progress  Mechanisms are cleanly modular 26

Contention Manager (CM)  Each thread has a Contention Manager  Consulted on whether to abort another transaction  Consult each other to compare priorities, etc.  Correctness requirement is weak  Any active transaction is eventually permitted to abort other conflicting transactions  Required for obstruction freedom  If a transaction is continually denied abort permissions, it will never commit even if it runs “by itself” (deadlock)  If transactions conflict, progress is not guaranteed 27

ContentionManager Interface  Should a Contention Manager guarantee progress?  That is a question of policy, delegate it …  DSTM requires implementation of CM interface  Notification methods  Deliver relevant events/information to CM  Feedback methods  Polls CM to determine decision points  CM implementation is open research problem 28

CM Examples  Aggressive  Always grants permission to abort conflicting transactions immediately  Polite  Backs off from conflict adaptively  Increasingly delays aborting a conflicting transaction  Sleeps twice as long at each attempt until some threshold  No silver bullet – CMs are application-specific 29

Results 30

DSTM with many threads 31

DSTM with 1 thread per processor 32

Overview of DSTM 33

DSTM Recap  DSTM allows simple concurrent programming with complex shared data structures  Pre-detect and decide on aborting upcoming transactions  Release objects before committing transaction  Obstruction freedom: weaker, non-blocking progress  Define policy with modular Contention Managers  Avoid livelock for correctness 34

35 Tradeoffs in STM

Outline  Prior STM Approaches  Transactional Locking Algorithm  Non-blocking vs. Blocking (locks)  Analysis of Performance Factors 36

Prior STM Work  Shavit & Touitou – First STM  Non-blocking, static  Herlihy – Dynamic STM  Indirection is costly  Fraser & Harris – Object STM  Manually open/close objects  Faster, less indirection  Marathe – Adaptive STM 37 ASTM DSTM OSTM obstruction-freelock-free eager lazy eager per-transaction per-object indirect direct indirect

Blocking STMs with Locks  Ennals – STM Should Not Be Obstruction-Free  Only useful for deadlock avoidance  Use locks instead – no indirection!  Encounter-order for acquiring write locks  Good performance  Read-set vs. Write-set vs. Undo-set 38

Transactional Locking 39

TL Concept  STM with a Collection of Locks  High performance with “mechanical” approach  Versioned lock-word  Simple spinlock + version number (# releases)  Various granularities:  Per Object – one lock per shared object, best performance  Per Stripe – lock array is separate, hash-mapped to stripes  Per Word – lock is adjacent to word 40

TL Write Modes Encounter Mode 1. Keep read & undo sets 2. Temporarily acquire lock for write location 3. Write value directly to original location 4. Keep log of operation in undo-set Commit Mode 1. Keep read & write sets 2. Add writes to write set 3. Reads/writes check write set for latest value 4. Acquire all write locks when trying to commit Validate locks in read set 6. Commit & release all locks Increment lock-word version #

Contention Management  Contention can cause deadlock  Mutual aborts can cause livelock  Livelock prevention  Bounded spin  Randomized back-off 42

Performance Analysis 43

Analysis of Findings  Deadlock-free, lock-based STMs > non-blocking  Enalls was correct  Encounter-order transactions are a mixed bag  Bad performance on contended data structures  Commit-order + write-set is most scalable  Mechanism to abort another transaction is unnecessary  use time-outs instead  Single-thread overhead is best indicator of performance, not superior hand-crafted CMs 44

TL Performance 45

Final Thoughts 46

Conclusion  Transactional Locking minimizes overhead costs  Lock-word: spinlock with versions  Encounter-order vs. Commit-order  Per-Stripe, Per-Order, Per-Word  Non-blocking (DSTM) vs. blocking (TM with locks) 47