Software Transactional Memory for Dynamic-sized Data Structures Maurice Herlihy, Victor Luchango, Mark Moir, William N. Scherer III Presented by: Irina.

Slides:



Advertisements
Similar presentations
Software Transactional Objects Guy Eddon Maurice Herlihy TRAMP 2007.
Advertisements

Time-based Transactional Memory with Scalable Time Bases Torvald Riegel, Christof Fetzer, Pascal Felber Presented By: Michael Gendelman.
Concurrent programming for dummies (and smart people too) Tim Harris & Keir Fraser.
Enabling Speculative Parallelization via Merge Semantics in STMs Kaushik Ravichandran Santosh Pande College.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Transactional Locking Nir Shavit Tel Aviv University (Joint work with Dave Dice and Ori Shalev)
Virendra J. Marathe, William N. Scherer III, and Michael L. Scott Department of Computer Science University of Rochester Presented by: Armand R. Burks.
Software Transactional Memory Kevin Boos. Two Papers Software Transactional Memory for Dynamic-Sized Data Structures (DSTM) – Maurice Herlihy et al –
Parallel Processing (CS526) Spring 2012(Week 6).  A parallel algorithm is a group of partitioned tasks that work with each other to solve a large problem.
Ali Saoud Object Based Transactional Memory. Introduction Resent trends go towards object based SMT because it’s dynamic Word-based STM systems are more.
Transactional Memory (TM) Evan Jolley EE 6633 December 7, 2012.
Resource Allocation, Deadlock and Banker’s Algorithm Supplementary Notes Dr. R. D. Kent Last modified: Dec. 11, 2006.
PARALLEL PROGRAMMING with TRANSACTIONAL MEMORY Pratibha Kona.
1 Johannes Schneider Transactional Memory: How to Perform Load Adaption in a Simple And Distributed Manner Johannes Schneider David Hasenfratz Roger Wattenhofer.
1 MetaTM/TxLinux: Transactional Memory For An Operating System Hany E. Ramadan, Christopher J. Rossbach, Donald E. Porter and Owen S. Hofmann Presenter:
EPFL - March 7th, 2008 Interfacing Software Transactional Memory Simplicity vs. Flexibility Vincent Gramoli.
Transaction Management and Concurrency Control
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.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Supporting Nested Transactional Memory in LogTM Authors Michelle J Moravan Mark Hill Jayaram Bobba Ben Liblit Kevin Moore Michael Swift Luke Yen David.
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.
1 Sharing Objects – Ch. 3 Visibility What is the source of the issue? Volatile Dekker’s algorithm Publication and Escape Thread Confinement Immutability.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Software Transaction Memory for Dynamic-Sized Data Structures presented by: Mark Schall.
/ PSWLAB Eraser: A Dynamic Data Race Detector for Multithreaded Programs By Stefan Savage et al 5 th Mar 2008 presented by Hong,Shin Eraser:
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.
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.
Use of Coverity & Valgrind in Geant4 Gabriele Cosmo.
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
SXM: Software Transactional Memory in C# Maurice Herlihy.
A Consistency Framework for Iteration Operations in Concurrent Data Structures Yiannis Nikolakopoulos A. Gidenstam M. Papatriantafilou P. Tsigas Distributed.
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.
1 File Systems: Consistency Issues. 2 File Systems: Consistency Issues File systems maintains many data structures  Free list/bit vector  Directories.
Lowering the Overhead of Software Transactional Memory Virendra J. Marathe, Michael F. Spear, Christopher Heriot, Athul Acharya, David Eisenstat, William.
Robustness in the Salus scalable block store Yang Wang, Manos Kapritsos, Zuocheng Ren, Prince Mahajan, Jeevitha Kirubanandam, Lorenzo Alvisi, and Mike.
Transactional Memory Lecturer: Danny Hendler. 2 2 From the New York Times…
Transactional Coherence and Consistency Presenters: Muhammad Mohsin Butt. (g ) Coe-502 paper presentation 2.
DOUBLE INSTANCE LOCKING A concurrency pattern with Lock-Free read operations Pedro Ramalhete Andreia Correia November 2013.
Practical concurrent algorithms Mihai Letia Concurrent Algorithms 2012 Distributed Programming Laboratory Slides by Aleksandar Dragojevic.
CS510 Concurrent Systems Why the Grass May Not Be Greener on the Other Side: A Comparison of Locking and Transactional Memory.
A Simple Optimistic skip-list Algorithm Maurice Herlihy Brown University & Sun Microsystems Laboratories Yossi Lev Brown University & Sun Microsystems.
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.
© 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.
Optimistic Design CDP 1. Guarded Methods Do something based on the fact that one or more objects have particular states Make a set of purchases assuming.
Agenda  Quick Review  Finish Introduction  Java Threads.
Concurrency (Threads) Threads allow you to do tasks in parallel. In an unthreaded program, you code is executed procedurally from start to finish. In a.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III
Part 2: Software-Based Approaches
Transaction Management and Concurrency Control
Faster Data Structures in Transactional Memory using Three Paths
Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III
A Qualitative Survey of Modern Software Transactional Memory Systems
Designing Parallel Algorithms (Synchronization)
Hybrid Transactional Memory
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Software Transactional Memory Should Not be Obstruction-Free
Lecturer: Danny Hendler
Controlled Interleaving for Transactions
Presentation transcript:

Software Transactional Memory for Dynamic-sized Data Structures Maurice Herlihy, Victor Luchango, Mark Moir, William N. Scherer III Presented by: Irina Botan

Outline Introduction Dynamic Software Transactional Memory (DSTM) DSTM Implementation – Transactions and Transactional Objects – Contention Management DSTM performance DSTM2 DSTM2 performance 2

Parallel Computing Moore’s law => chip multiprocessing (CMP) => Increased Parallelism Complex problems can be divided into smaller ones which can be then executed in parallel 3 Sequential ComputingParallel Computing

Concurrent Access to Shared Data 4 int x[N]; i := N-1;… … if (i < N){ i := i+1; x[i] := i; } T1 T2

Locking Coarse-grained or fine- grained locking Locking conventions Vulnerability to thread failures and delays Poor support for code composition and reuse => too difficult to develop, debug, understand and maintain programs 5 lock() i := N-1; … if ( i<N ) x[i]:=i; unlock() lock() i := i + 1; unlock() T1 T2 Coarse-grained locking

Software Transactional Memory (STM) Low-level API for synchronizing access to shared data without using locks – Alleviates the difficulty of programming – Maintains performance Transactional Model – Transaction = atomic sequence of steps executed by a single thread (process); protects access to shared (transactional) objects Only for static data structures – Transactional objects and transactions defined apriori 6

From STM to D(ynamic)STM Transactions and transactional objects can be created dynamically if (object1.value == 1) object2.value = 2; else object3.value = 2; Well suited for dynamic-sized data structures, like linked lists and trees 7

Outline Introduction Dynamic Software Transactional Memory (DSTM) DSTM Implementation – Transactions and Transactional Objects – Contention Management DSTM performance DSTM2 DSTM2 performance 8

Transactional Object Container for a shared object Creation List newNode = new List(v); TMObject newTMNode = new TMObject(newNode); Access List current = (List)newTMNode.open(WRITE); current.value = 1; 9

Transaction Short-lived single-threaded computation that either commits (the changes take effect) or aborts (the changes are discarded) Linearizability = transactions appear as if they were executed one-at-a-time 10

Linked List Example public boolean insert (int v){ List newList = new List(v); TMObject newNode = new TMObject(newList); TMThread thread = (TMThread)thread.currentThread(); while(true){ thread.beginTransaction(); boolean result = true; try{ List prevList = (List)this.first.open(WRITE); List currList = (List)prevList.next.open(WRITE); while (currList.value < v){…} } catch (Denied d){} if ( thread.commitTransaction ()) return result; } 11

Synchronization Conflict Two transactions attempting to access the same object and at least one of them wants to write it 12

Check Synchronization Conflicts If a conflict occurs, open() throws a Denied exception – The transaction knows it will not commit successfully and will retry execution 13 public boolean insert (int v){ … while(true){ thread.beginTransaction(); try{ List prevList = (List)this.first. open (READ); … } catch (Denied d){} if (thread.commitTransaction()) return result; }

Conflict Reduction = Early Release Release an object opened in READ mode before commit Useful for shared pointer- based data structures (e.g., lists, trees) Programmer’s job to ensure correctness (linearizability) 14 open(i, READ) … … release(i) open(i,WRITE) open(j,READ) … commit A B

Progress Guarantee Wait-freedom – Every thread makes progress Lock-freedom – At least one thread makes progress Obstruction-freedom – Any thread that runs by itself for long enough makes progress 15

Obstruction-Freedom A transaction can abort any other transaction + Simpler and more efficient (in absence synchronization conflicts) than lock-freedom - Livelocks possible 16

Livelock Two competing processes constantly change state with respect to one another, none making progress E.g., two people meeting in a narrow corridor, each trying to be polite by moving aside to let the other pass* * 17

Outline Introduction Dynamic Software Transactional Memory (DSTM) DSTM Implementation – Transactions and Transactional Objects – Contention Management DSTM performance DSTM2 DSTM2 performance 18

Transactional Object Implementation Transaction StateOld ObjectNew Object CommittedMeaninglessCurrent object AbortedCurrent ObjectMeaningless ActiveCurrent ObjectTentative new current object 19 Data old object new object transaction State Transactional Object “transaction” points to the transaction that most recently opened the object in WRITE mode

Transactional Object Access Avoid generating inconsistencies How to atomically access all three fields? 20 old object new object transaction Transactional Object Data State

Atomically Access the Transactional Object’s Fields Introduce another level of indirection – CAS (Compare and Swap) to swing the Start object from one locator object to the other 21 Start TMObject newLocator oldLocator old object new object transaction old object new object transaction Data State Data State

Open Transactional Object in WRITE Mode (Previous Transaction Committed) 22 Data Start newLocator oldLocator old object new object transaction old object new object transaction B(commit) A copy

Open Transactional Object in WRITE Mode (Previous Transaction Aborted) 23 Data Start newLocator oldLocator old object new object transaction old object new object transaction B(abort) A copy

Open Transactional Object in WRITE Mode (Previous Transaction Active) 24 Data Start newLocator oldLocator old object new object transaction old object new object transaction B(active) A ABORT

Open Transactional Object in READ Mode 25 Data Start oldLocator old object new object transaction B(commit) ObjectVersionOpen O1V12 O2V21 O3V1 1.Identify the last committed version of the transactional object (exactly as for WRITE) 2.Add the pair (O,V) to a thread-local read-only table Read-only table

Transaction Validation Ensure that the user never sees an inconsistent state After open() determined the version 1.For each pair (O, V) verify that V is still the most recently committed version of the object O 2.Check that status field of transaction still ACTIVE 26 ObjectVersionOpen O1V12 O2V21 O3V1 Data old object new object transaction State Transactional Object Start

Transaction Commit 1.Validate entries in the read-only table 2.Change the status field of the transaction from ACTIVE to COMMITTED 27 ObjectVersionOpen O1V12 O2V21 O3V1 Data old object new object transaction Active Transactional Object Start Committed CAS

Contention Management Ensures progress Each thread has a Contention Manager – Consults it to decide whether to force another conflicting thread to abort Correctness requirement for contention managers – Any active transaction can eventually abort another transaction (“obstruction-freedom”) – Should avoid livelock 28

Contention Manager Policies Examples Aggressive – Always and immediately grants permission to abort any conflicting transaction Polite – In case of a conflict, sleep for a time interval t * Idea: wait for the other transaction to finish – Retry and increase waiting time with each attempt – After a fixed number of tries, immediately abort the other transaction 29

Costs W – number of objects opened in WRITE mode R – number of objects opened in READ mode In the absence of conflicts – (W+1) CAS operations (for each open() call and one commit) Synchronization conflicts – More CAS operations to abort other transactions Costs of copying objects (uses simple load and store operations) Validating a transaction – Requires O(R) work Total overhead due to DSTM implementation – O((R+W)R) + clone each object opened for writing once 30

Outline Introduction Dynamic Software Transactional Memory (DSTM) DSTM Implementation – Transactions and Transactional Objects – Contention Management DSTM performance DSTM2 DSTM2 performance 31

Experimental Setup Integer Set and Red-black tree Measure: how many operations completed in 20 seconds, varying the number of threads Goal: compare performance of different implementation approaches 32

Experimental Results 33

Outline Introduction Dynamic Software Transactional Memory (DSTM) DSTM Implementation – Transactions and Transactional Objects – Contention Management DSTM performance DSTM2 DSTM2 performance 34

Lessons Learned from DSTM TMObject tmNode= new TMObject (new Node()); Node rNode = tmNode.open(READ); Node wNode = tmNode.open(WRITE); The programmer must not modify the object referenced by rNode If wNode is opened before rNode, changes to wNode are visible through rNode, but not if they are opened in the opposite order rNode and wNode references must not linger (programmer’s job) The Node class must provide a clone() method Programmers must be aware of the container based implementation: Class Node{ Int value; TMObject next; //not Node } 35

DSTM2 Software transactional memory library (a collection of Java packages that supports transactional API) Safe, convenient and flexible API for application programmers Allows users to plug-in their own synchronization and recovery mechanisms (transactional factories) 36

Atomic Classes Comparison DSTM TMObject newNode= new TMObject (new Node()); Node rNode = newNode.open(READ); Node wNode = newNode.open(WRITE); Class Node{ Int value; TMObject next; //not Node } public interface INode{ int getValue(); void setValue(int value); INode getNext(); void setNext(INode value); … } Factory factory = dstm2.Thread.makeFactory(INode. class); INode newNode = factory.create(); 37

Atomic – Objects satisfying this interface should be safe to share Defines one or more properties (pairs of get and set) of certain type Property type: either scalar interface May define other specialized public interface INode{ int getValue(); void setValue(int value); INode getNext(); void setNext(INode value); … } 38

Transactional Factory Atomic interface is passed to a transactional factory constructor Use specific methods to create class implementing the interface The factory then creates instances of the class Factory factory = dstm2.Thread.makeFactory (INode.class); INode newNode = factory.create(); 39

Atomic Interface and Transactional Factory Semantics of get and set is clear Each factory is free to provide its own implementation for the methods public interface INode{ int getValue(); void setValue(int value); INode getNext(); void setNext(INode value); … } Factory factory = dstm2.Thread.makeFactory (INode.class); INode newNode = factory.create(); 40

Obstruction-Free Factory 41 Data Start newLocator oldLocator old object new object transaction old object new object transaction B(commit) A copy

Obstruction-Free Factory Variants Invisible reads – At commit time, a transaction must validate itself Checks that the versions read are still current Visible reads – Each object maintains a list of reader transactions descriptors – A transaction intending to modify the object must first abort them 42

Shadow Factory 43 field2 new object field1 field3 transaction shadow3 shadow2 shadow1 committed field2 new object field1 field3 transaction shadow3 shadow2 shadow1 aborted backup restore

Transactions DSTM public boolean insert (int v){ … TMThread thread = (TMThread)thread.currentThread(); while(true){ thread. beginTransaction (); try{ … } catch (Denied d){} if (thread. commitTransaction ()) return result; } DSTM2 result = Thread.doIt ( new Callable (){ public boolean call(){ return intSet.insert(v); } public static T doIt(Callable xaction){ while (! Thread.stop ){ beginTransaction (); try{ result=xaction.call(); }catch (AbortedException d){} if ( commitTransaction ()){ return result; } 44

Outline Introduction Dynamic Software Transactional Memory (DSTM) DSTM Implementation – Transactions and Transactional Objects – Contention Management DSTM performance DSTM2 DSTM2 performance 45

DSTM2 Experimental Setup Linked-list and Skip List Configurations: obstruction-free factory (visible reads), obstruction-free factory with invisible reads, shadow factory 0%, 50%, 100% updates out of all operations Measure: transactions/second in a 20 second period Goal: show how DSTM2 can be used experimentally to evaluate the relative performance of different factories 46

DSTM2 Performance Linked List – The shadow factory 3-5 times higher throughput than the obstruction-free factories Slightly higher when the percentage of updates decreases – Obstruction-free factories roughly the same results Skip List – Shadow factory better for high percentage of updates 47

Conclusions STM – API for low-level synchronized access to shared data without using locks DSTM – dynamic STM – Dynamic creation of transactions and transactional objects – Detect and reduce synchronization conflicts – Contention Manager (obstruction-freedom) DSTM2 – Flexible API for application programmers 48