Algorithmics for Software Transactional Memory Hagit Attiya Technion.

Slides:



Advertisements
Similar presentations
Time-based Transactional Memory with Scalable Time Bases Torvald Riegel, Christof Fetzer, Pascal Felber Presented By: Michael Gendelman.
Advertisements

Wait-Free Linked-Lists Shahar Timnat, Anastasia Braginsky, Alex Kogan, Erez Petrank Technion, Israel Presented by Shahar Timnat 469-+
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]
1 Integrity Ioan Despi Transactions: transaction concept, transaction state implementation of atomicity and durability concurrent executions serializability,
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Enabling Speculative Parallelization via Merge Semantics in STMs Kaushik Ravichandran Santosh Pande College.
© 2005 P. Kouznetsov Computing with Reads and Writes in the Absence of Step Contention Hagit Attiya Rachid Guerraoui Petr Kouznetsov School of Computer.
Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Presented by: Dmitri Perelman.  Intro  “Don’t touch my read-set” approach  “Precedence graphs” approach  On avoiding spare aborts  Your questions.
Highly-Concurrent Data Structures Hagit Attiya and Eshcar Hillel Computer Science Department Technion.
Safety Definitions and Inherent Bounds of Transactional Memory Eshcar Hillel.
Inherent limitations on DAP TMs 1 Inherent Limitations on Disjoint-Access Parallel Transactional Memory Hagit Attiya, Eshcar Hillel, Alessia Milani Technion.
Pessimistic Software Lock-Elision Nir Shavit (Joint work with Yehuda Afek Alexander Matveev)
The Complexity of Transactional Memory & What to Do About It Hagit Attiya Technion & EPFL.
Transactional Contention Management as a Non-Clairvoyant Scheduling Problem Alessia Milani [Attiya et al. PODC 06] [Attiya and Milani OPODIS 09]
Two Techniques for Proving Lower Bounds Hagit Attiya Technion TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A.
Consistency Conditions for STM Sandeep Hans. Agenda Database Consistency Conditions STM Consistency Conditions A different perspective Consistency with.
A Programming Language View of Transactional Memory Hagit Attiya, Technion Joint work with Sandeep Hans, Alexey Gotsman and Noam Rinetzky Published in.
Concurrency Control Nate Nystrom CS 632 February 6, 2001.
A Mile-High View of Concurrent Algorithms Hagit Attiya Technion.
Transactions are back But are they the same? R. Guerraoui, EPFL.
We should define semantics for languages, not for TM Tim Harris (MSR Cambridge)
TOWARDS A SOFTWARE TRANSACTIONAL MEMORY FOR GRAPHICS PROCESSORS Daniel Cederman, Philippas Tsigas and Muhammad Tayyab Chaudhry.
Idit Keidar and Dmitri Perelman Technion 1 SPAA 2009.
Lock-free Cuckoo Hashing Nhan Nguyen & Philippas Tsigas ICDCS 2014 Distributed Computing and Systems Chalmers University of Technology Gothenburg, Sweden.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Distributed Systems Fall 2010 Transactions and concurrency control.
CS 582 / CMPE 481 Distributed Systems Concurrency Control.
CPSC 668Set 16: Distributed Shared Memory1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
Transaction Processing: Concurrency and Serializability 10/4/05.
Transaction Management
CS510 Concurrent Systems Class 13 Software Transactional Memory Should Not be Obstruction-Free.
Locality in Concurrent Data Structures Hagit Attiya Technion.
The Cost of Privatization Hagit Attiya Eshcar Hillel Technion & EPFLTechnion.
Database Management Systems I Alex Coman, Winter 2006
Hagit Attiya (CS, Technion) Joint work with Rachid Guerraoui (EPFL) Eric Ruppert (York University) Partial Snapshots.
TRANSACTIONS AND CONCURRENCY CONTROL Sadhna Kumari.
An Introduction to Software Transactional Memory
Parallel Programming Philippas Tsigas Chalmers University of Technology Computer Science and Engineering Department © Philippas Tsigas.
Simple Wait-Free Snapshots for Real-Time Systems with Sporadic Tasks Håkan Sundell Philippas Tsigas.
Software Transactional Memory for Dynamic-Sized Data Structures Maurice Herlihy, Victor Luchangco, Mark Moir, William Scherer Presented by: Gokul Soundararajan.
Reduced Hardware NOrec: A Safe and Scalable Hybrid Transactional Memory Alexander Matveev Nir Shavit MIT.
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 3 (26/01/2006) Instructor: Haifeng YU.
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.
Atomic Snapshots. Abstract Data Types Abstract representation of data & set of methods (operations) for accessing it Implement using primitives on base.
Transactions and Concurrency Control Distribuerade Informationssystem, 1DT060, HT 2013 Adapted from, Copyright, Frederik Hermans.
WG5: Applications & Performance Evaluation Pascal Felber
On the Performance of Window-Based Contention Managers for Transactional Memory Gokarna Sharma and Costas Busch Louisiana State University.
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Wait-Free Multi-Word Compare- And-Swap using Greedy Helping and Grabbing Håkan Sundell PDPTA 2009.
Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João.
Chapter 15: Transactions Loc Hoang CS 157B. Definition n A transaction is a discrete unit of work that must be completely processed or not processed at.
Chapter 10 Recovery System. ACID Properties  Atomicity. Either all operations of the transaction are properly reflected in the database or none are.
Software Transactional Memory Should Not Be Obstruction-Free Robert Ennals Presented by Abdulai Sei.
Alpine Verification Meeting 2008 Model Checking Transactional Memories Vasu Singh (Joint work with Rachid Guerraoui, Tom Henzinger, Barbara Jobstmann)
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Reduction Theorems for Proving Serializability with Application to RCU-Based Synchronization Hagit Attiya Technion Work with Ramalingam and Rinetzky (POPL.
Transactional Contention Management as a Non-Clairvoyant Scheduling Problem Hagit Attiya, Alessia Milani Technion, Haifa-LABRI, University of Bordeaux.
Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III
Part 2: Software-Based Approaches
Concurrency Control.
On disjoint access parallelism
Transactions.
Transactions are back But are they the same? R. Guerraoui , EPFL
Chapter 15 : Concurrency Control
Distributed Transactions
Transaction management
Presentation transcript:

Algorithmics for Software Transactional Memory Hagit Attiya Technion

2 Moore's Law is dead … says Gordon Moore (TechWorld, 4/2005) Intel announces a drastic change in its business strategy (San Francisco, 5/2004): «Multicore is the way to boost performance» Many applications will be concurrent Forking threads is easy, Handling the conflicts is hard!

3 Transactional Synchronization A transaction is a sequence of operations by a single process on a set of data items (data set) to be executed atomically We consider only read/write operations:  Read set: the items read by T  Write set: the items written by T Read X Write X Read Z Read Y Read X Write X Read Z Read Y

4 Transactional Synchronization A transaction is a sequence of operations by a single process on a set of data items (data set) to be executed atomically A transaction ends either by committing  all its updates take effect or by aborting  no update is effective Read X Write X Read Z Read Y Commit/ Abort Read X Write X Read Z Read Y Commit/ Abort

5 Software Implementation of TM Data representation for transactions & data Algorithms to execute transactions in terms of low-level primitives (read, write, CAS…) on base objects (memory locations) Must provide Opacity [Guerroui & Kapalka] or strict serializability [Papadimitriou] Obstruction freedom

Typical Implementation Scheme To write data item O, a transaction acquires O, possibly aborting the transaction that owns O (killer write) To read an object, a transaction takes a snapshot to see if the system hasn’t changed since its previous reads; else T is aborted (careful read) Or: validate the reads when the transaction asks to commit (optimistic read)

7 Algorithmics Acquiring several data items Validating that a set of values read is consistent Multi-location Synchronization Atomic Snapshot

8 (Full) Atomic Snapshot [Afek et al. 1990] n components Update a single component Scan all the components “at once” (atomically) Provides an instantaneous view of the whole memory update ok scan v 1,…,v n

9 Partial Snapshot [Attiya, Guerraoui, Ruppert, 2008] n components Update a single component Scan components “at once” (atomically) Allows to read parts of the memory Worthwhile if we can do it more efficiently than a (full) scan update ok scan v i1,…,v ir

10 Optimizing Partial Scans Transactions that only observe the data  Empty write set Be invisible (not write to base objects)  Avoid contention for the memory Always terminate successfully (wait-free)

11 DAP: Disjoint Access Parallelism T1T1 Read(Y) Write(X 1 ) T2T2 Write(X 2 ) T3T3 Read(X 2 ) Read(X 1 ) Disjoint data sets  no contention Data sets are connected  may contend Y X2X2 X1X1 T3T3 T1T1 Improves scalability for large data structures by reducing interference

12 DAP: More Formally An STM implementation is disjoint access parallel if two transactions T 1 and T 2 access the same base object ONLY IF the data sets of T 1 and T 2 are connected. The data sets of T 1 & T 2 either intersect or are connected via other transactions

13 State of the Art Read-only Tx termination Invisible read-only Tx DAPAlgorithm  [Herlihy, Luchangco, Moir & Scherer]  [Avni & Shavit]  [Riegel, Felber & Fetzer]  Harris, Fraser & Pratt]

14 Inherent Tradeoff Theorem. There is no TM implementation that is DAP and has invisible & wait-free read-only transactions [Attiya, Hillel & Milani] Proof utilizes the notion of a flippable execution, used to prove lower bounds for atomic snapshot objects [Israeli, Shirazi] [Attiya, Ellen & Fatourou]

15 Flippable Execution w/ 2 Updaters p1p1 p2p2 q s 1 … s l-1 s l … s k U 1 … U l … U 0 … U l-1 … U k A complete transaction in which p 1 writes l-1 to X 1 A read-only transaction by q that reads X 1, X 2 EkEk

16 Flippable Execution w/ 2 Updaters p1p1 p2p2 q s 1 … s l-1 s l … s k U 1 … U l … U 0 … U l-1 … U k EkEk Indistinguishable from executions where the order of (each pair of) updates is flipped… In one of two ways (forward and backward).

17 Flippable Execution: Backward Flip p1p1 p2p2 q s 1 … s l-1 s l … s k U 1 … U l … U 0 … U l-1 … U k EkEk p1p1 p2p2 q s 1 … s l-1 s l … s k U 1 … U l … U 0 … U l-1 … U k Backward Flip

18 Lemma 1. The read-only transaction of q cannot terminate successfully Relies on strict serializabitly (linearizability)  Any interleaving of the transactions yields a result that can be achieved in a sequential execution of the same set of transactions (a serialization)  The serialization must preserve the real-time order of (non-overlapping) transactions Why Flippable Executions?

19 Serialization of E k p1p1 p2p2 q s 1 … s l-1 s l … s k U 1 … U l … U 0 … U l-1 … U k EkEk U 1 … U l …U 0 U l-1 U k Serialization of E k : Possible serialization point Returns (l-1,l-2)

20 Nowhere to Serialize p1p1 p2p2 q s 1 … s l-1 s l … s k U 1 … U l … U 0 … U l-1 … U k EkEk U 1 … U l …U 0 U l-1 U k Serialization Returns (l-1,l-2) p1p1 p2p2 q s 1 … s l-1 s l … s k U 1 … U l … U 0 … U l-1 … U k BW Flip Still returns (l-1,l-2) U 1 … U l U l-1 … U k U0U0 Serialization x Indistinguishable from some flip (say, backward) X 1 = l-2 X 2 = l-3 X 1 = l X 2 = l-3 X 1 = l X 2 = l-1

21 Constructing a Flippable Execution Lemma 2. In a DAP TM, two consecutive transactions writing to different data items do not contend on the same base object. U1U1 U2U2

22 Proof of Lemma 2 Towards a contradiction, assumme U 1 and U 2 contend on a base object Let o be the last base object accessed by U 1 for which U 2 has a contending access U1U1 U2U2 Last contending access to o First contending access to o

23 Proof of Lemma 2 By contradictions, assumme U 1 and U 2 contend on a base object U1U1 U2U2 Last contending access to o First contending access to o U1U1 U2U2 U1 and U2 have disjoint data sets & contend on a base object Not DAP

24 Completing the Proof Show that a flippable execution exists  The steps of the read-only transaction can be removed (since it is invisible)  Since their data sets are disjoint, transactions U l & U l-1 do not “communicate” (by Lemma 2)  Can be flipped  By Lemma 1, the read-only transaction cannot terminate successfully  If aborts, can apply the same argument again…

25 Extensions… Also a Lower Bound: A transaction with a data set of size t must write to t-2 base objects The results hold also for weaker TM consistency conditions: Serializability Snapshot Isolation

26 Algorithmics Acquiring several locations Validating that a set of values read is consistent Multi-location Synchronization Atomic Snapshot

27 Multi-Location Synchronization Acquire nodes in the data set How to resolve conflicts with blocking operations (holding a required data item)?  To reduce delays

28 Multi-Location Synchronization Acquire nodes in the data set How to resolve conflicts with blocking operations (holding a required data item)?  To reduce delays  To avoid deadlock

29 Multi-Location Synchronization: Classical Solution E.g., [Touitou & Shavit] Acquired items by increasing order (e.g., of addresses) Avoids deadlocks But not delays Cannot be applied when data items are given in piecemeal…

30 Multi-Location Synchronization: Practical STM Implementations Use a contention manager to decide which transaction has the object (the other aborts)  The other operation aborts & restarts But this requires support from the operating system Does not have provable guarantees

31 Multi-Location Synchronization: More Concurrency [Attiya, Hillel] Acquire locks in arbitrary order  No need to know the data set in advance When there is a conflict between two transactions contending for a data item, either  Wait for the other operation  Abort & reset the other operation

32 Distributed Conflict Resolution Depends on the operations’ progress The more advanced operation wins 1.How to gauge progress? 2.What to do on a tie?

33 Who’s More Advanced? The operation that locked more data items If a less advanced operation needs an item  wait (blocking in a limited radius) or help the conflicting operation If a more advanced operation needs an item  abort the conflicting operation and claim the item

34 What about Ties? When two transactions locked the same number of items Each transaction has a descriptor with a lock Use DCAS to race for locking the two descriptors  Winner calls the shots… 22

35 Wrap-Up Can be shown to guarantee progress in small neighborhoods  If I take many steps, then a transaction within “short distance” completes  The distance depends on size of the data set. Can be made non-blocking / wait-free  By integrating a helping mechanism In a graph on the transactions defined by data conflicts

36 Measuring Concurrency: Spatial Relations between Operations A set of operations induces a conflict graph  Nodes represent items  Edges connect items of the same operation Chains of operations  Paths  Distance is length of path (here, 2)

37 Measuring Concurrency: Spatial Relations between Operations Disjoint access  Non adjacent edges  Distance is infinite Overlapping operations  Adjacent edges  Distance is 0 d-neighborhood of an operation: all operations at distance ≤ d

38 Formally: Interference between Operations Disjoint access Overlapping operations Non-overlapping operations Provides more concurrency & yields better throughput Interference inevitable no interference Should not interfere!

39 A Lot More to be Done Better algorithms for partial snapshots, incorporated into full-fledged STM Other lower bounds (w/ weaker notions of DAP or weaker consistency conditions) More precise definitions of concurrency (& their practical validation) Better and simpler algorithms Definitions of other STM properties (liveness, responsiveness)

Thank you!