Commutativity and Coarse-Grained Transactions Maurice Herlihy Brown University Joint work with Eric Koskinen and Matthew Parkinson (POPL 10)

Slides:



Advertisements
Similar presentations
Wait-die Transactions given a timestamp when they arrive …. ts(T i ) T i can only wait for T j if ts(T i )< ts(T j )...else die T 1 (ts =10) T 2 (ts =20)
Advertisements

Reduction, abstraction, and atomicity: How much can we prove about concurrent programs using them? Serdar Tasiran Koç University Istanbul, Turkey Tayfun.
D u k e S y s t e m s Time, clocks, and consistency and the JMM Jeff Chase Duke University.
Transactional Locking Nir Shavit Tel Aviv University (Joint work with Dave Dice and Ori Shalev)
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Rich Transactions on Reasonable Hardware J. Eliot B. Moss Univ. of Massachusetts,
Introduction Companion slides for
CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture X: Transactions.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
Chapter 6 Process Synchronization: Part 2. Problems with Semaphores Correct use of semaphore operations may not be easy: –Suppose semaphore variable called.
Transactional Memory Overview Olatunji Ruwase Fall 2007 Oct
Thread-Level Transactional Memory Decoupling Interface and Implementation UW Computer Architecture Affiliates Conference Kevin Moore October 21, 2004.
Coarse-Grained Transactions Maurice Herlihy Brown University Joint work with Eric Koskinen and Matthew Parkinson (POPL 10)
Transactional Memory (TM) Evan Jolley EE 6633 December 7, 2012.
The Future of Concurrency Theory Renaissance or Reformation? (Met dank aan Maurice Herlihy) Frits Vaandrager.
Nested Transactional Memory: Model and Preliminary Architecture Sketches J. Eliot B. Moss Antony L. Hosking.
CMPT Dr. Alexandra Fedorova Lecture X: Transactions.
Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty Checkpoints and Continuations instead of Nested Transactions (SPAA’08)
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Distributed Snapshots –Termination detection Election algorithms –Bully –Ring.
1 Lecture 7: Transactional Memory Intro Topics: introduction to transactional memory, “lazy” implementation.
CS 245Notes 101 CS 245: Database System Principles Notes 10: More TP Hector Garcia-Molina.
1 Lecture 24: Transactional Memory Topics: transactional memory implementations.
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.
Introduction Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified by Rajeev Alur for CIS 640 at Penn, Spring.
DTHREADS: Efficient Deterministic Multithreading
System Catalogue v Stores data that describes each database v meta-data: – conceptual, logical, physical schema – mapping between schemata – info for query.
CMPT Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
CMPT Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
A Transaction-Friendly Dynamic Memory Manager for Embedded Multicore Systems Maurice Herlihy Joint with Thomas Carle, Dimitra Papagiannopoulou Iris Bahar,
Relativistic Red Black Trees. Relativistic Programming Concurrent reading and writing improves performance and scalability – concurrent readers may disagree.
Data Concurrency Control And Data Recovery
Programming Paradigms for Concurrency Part 2: Transactional Memories Vasu Singh
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.
CS 245Notes 101 CS 245: Database System Principles Notes 10: More TP Hector Garcia-Molina.
SafetyNet: improving the availability of shared memory multiprocessors with global checkpoint/recovery Daniel J. Sorin, Milo M. K. Martin, Mark D. Hill,
SafetyNet Improving the Availability of Shared Memory Multiprocessors with Global Checkpoint/Recovery Daniel J. Sorin, Milo M. K. Martin, Mark D. Hill,
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.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Distributed synchronization and mutual exclusion Distributed Transactions.
On the Performance of Window-Based Contention Managers for Transactional Memory Gokarna Sharma and Costas Busch Louisiana State University.
CS162 Week 5 Kyle Dewey. Overview Announcements Reactive Imperative Programming Parallelism Software transactional memory.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
Software Transactional Memory Should Not Be Obstruction-Free Robert Ennals Presented by Abdulai Sei.
1 CSE232A: Database System Principles More Concurrency Control and Transaction Processing.
Parallel Data Structures. Story so far Wirth’s motto –Algorithm + Data structure = Program So far, we have studied –parallelism in regular and irregular.
On Transactional Memory, Spinlocks and Database Transactions Khai Q. Tran Spyros Blanas Jeffrey F. Naughton (University of Wisconsin Madison)
4 November 2005 CS 838 Presentation 1 Nested Transactional Memory: Model and Preliminary Sketches J. Eliot B. Moss and Antony L. Hosking Presented by:
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
Novel Paradigms of Parallel Programming Prof. Smruti R. Sarangi IIT Delhi.
Maurice Herlihy and J. Eliot B. Moss,  ISCA '93
Irina Calciu Justin Gottschlich Tatiana Shpeisman Gilles Pokam
Multiprocessor Programming
Minh, Trautmann, Chung, McDonald, Bronson, Casper, Kozyrakis, Olukotun
Virtualizing Transactional Memory
Håkan Sundell Philippas Tsigas
The University of Adelaide, School of Computer Science
Faster Data Structures in Transactional Memory using Three Paths
Challenges in Concurrent Computing
Changing thread semantics
Transactional Memory Semaphores, monitors, and conditional critical regions all suffer from limitations based on lock semantics Naïve synchronization may.
Lecture 6: Transactions
Chapter 10 Transaction Management and Concurrency Control
Lecture 21: Transactional Memory
Distributed Transactions
Software Transactional Memory Should Not be Obstruction-Free
Lecture 23: Transactional Memory
Lecture 21: Transactional Memory
Concurrency in Smart Contracts
Lecture: Transactional Memory
Parallel Data Structures
Presentation transcript:

Commutativity and Coarse-Grained Transactions Maurice Herlihy Brown University Joint work with Eric Koskinen and Matthew Parkinson (POPL 10)

CCDP February Moore’s Law (hat tip: Herb Sutter) Clock speed flattening sharply Transistor count still rising

CCDP February The Multicore Processor cache Bus shared memory cache More processors, Same clock Sun T2000 Niagara

CCDP February What Keeps Microsoft and Intel awake at Night? If more cores does not deliver more value … Then why upgrade? ?

CCDP February Washing Machine Science? Computers could become like washing machines You don’t trade it in every 2 years for a cooler model You keep it until it breaks.

CCDP February What could possibly go wrong? Concurrent programming is hard Locks, monitors, etc. do not scale –Confusing –Subject to deadlock –Relies on conventions –Not composable –…

CCDP February The Transactional Manifesto Threads + locking don’t scale Replace locking with a transactional API Promising … but not there yet

CCDP February Challenge Do transactions provide enough concurrency? –As implemented, arguably No. Does the transactional model provide enough concurrency? –Arguably, Yes.

TMW April 2010 Skew Heaps 0 1 Tree with “heap” property 2 4 3

TMW April 2010 Concurrent Skew Heap Insert me! 6

TMW April 2010 Concurrent Skew Heap Lock parent Swap R & L

TMW April 2010 Concurrent Skew Heap Lock right child Unlock parent 2

TMW April 2010 Concurrent Skew Heap No global rebalancing Good amortized performance Good concurrency

TMW April 2010 Transactional Skew Heap Insert me! 6

TMW April 2010 Transactional Skew Heap I wrote 0 Write-write conflict! Good concurrency with locking Not with transactions … Confusion between thread-level & transaction-level synchronization Confusion between thread-level & transaction-level synchronization

TMW April 2010 Coarse-Grained Synchronization Synchronize on high-level operations, Like add(), remove(), etc. … Not low-level reads and writes Synchronize on high-level operations, Like add(), remove(), etc. … Not low-level reads and writes Pessimistic: update in place, undo on abort Optimistic: update private copy, apply changes on commit But what is the meaning of conflict?

TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs

TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs add(x)

TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs add(x)

TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs add(x)

TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object rem(x) Undo Logs add(x) x

TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object rem(x) Undo Logs add(x) x add(y) y

TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object rem(x) Undo Logs add(x) x member(x)

TMW April 2010 Pessimistic Boosting Thread-safe base object Updated in place Log Inverses Conflicting operations blocked by abstract locks What does it mean for operations to conflict?

TMW April 2010 Optimistic Boosting Black-box linearizable data object

TMW April 2010 Optimistic Boosting private copies Black-box linearizable data object

TMW April 2010 Optimistic Boosting redo logs private copies Black-box linearizable data object

TMW April 2010 Optimistic Boosting redo logs private copies Black-box linearizable data object add(x)

TMW April 2010 Optimistic Boosting add(x) redo logs private copies Black-box linearizable data object add(x) x

TMW April 2010 Optimistic Boosting add(x) add(y) redo logs private copies Black-box linearizable data object add(x) x add(y) y

TMW April 2010 On Commit add(x) add(y) redo logs private copies Black-box linearizable data object x y add(x)

TMW April 2010 On Commit add(x) add(y) redo logs private copies Black-box linearizable data object x y add(x) No conflict, apply updates to my copy x x

TMW April 2010 On Commit add(x) add(y) x y add(x) x x Different physical values, Same logical values

TMW April 2010 On Commit add(x) rem(x) redo logs private copies Black-box linearizable data object x add(x) Conflict! Abort & restore my copy x

TMW April 2010 Optimistic Boosting Thread-local object copies Deferred operatons kept in redo log No inverses On commit, broadcast deferred operations To other transactions, public copy On commit, broadcast deferred operations To other transactions, public copy Transactions snoop on broadcast, Abort if conflict detected Transactions snoop on broadcast, Abort if conflict detected What does it mean for operations to conflict?

TMW April 2010 Left-Movers time legal history

TMW April 2010 Left-Movers time If and are adjacent, Ok to move earlier

Left-Mover Example: Semaphore time inc()dec() 1 010

Inc() is Left-mover WRT Dec() time inc()dec()

Same sequence of calls (results unaffected) Left-Mover Example: Semaphore time inc()dec()

Same final state Left-Mover Example: Semaphore time inc()dec()

Left-Mover Counter-example time 1 dec() 0 inc() 1 dec() 0

Dec() not Left-Mover WRT Inc() time 1 dec() 0 inc() 1 dec() 0

Right-Movers time legal history

Right-Movers time If and are adjacent, Ok to move later

Commutativity time If and are adjacent, Ok to swap

47 Pessimistic Semantics (modify shared state in place) time Txn B beg Txn A beg Pessimistic Commit: Move Left of pending cmt

48 Pessimistic Semantics (modify shared state in place) time Txn B beg Txn A beg abt

49 Pessimistic Semantics (modify shared state in place) time 3 Txn B beg Txn A beg Pessimistic Abort: Move Right of pending Pessimistic Abort: Pending ops move Left

50 Optimistic Semantics (modify local copies; merge) time Txn B Txn A beg Optimistic Commit: Move Right of committed cmt

51 Optimistic Semantics (modify local copies; merge) time Txn B Txn A beg Optimistic Abort: Discard Operations abt cmt

PessimisticOptimistic Two Execution Models 52 Left-MovernessRight-Moverness Algebraic Abstract Properties

53 But … Are commutativity+inverses the limit? –Other algebraic properties? Abstract locks are blocking –may cause multiple transactions –may block on same lock

54 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } Lock key 3

55 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } Add value 3

56 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } If set modified, Log inverse

57 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } Do something long, Not involving skiplist

58 Conflicting Operations remove(3) insert(3) no conflict

59 Conflicting Locks remove(3) insert(3) (3) No concurrency

60 Conflicting Locks insert(3) (3) remove(3) (3)

61 Conflicting Locks insert(3) (3) remove(3) (3)

62 Conflicting Locks insert(3) (3) remove(3) (3) Lock handoff

63 Lock Handoff dependence

64 Lock Handoff dependence Lock handoff

65 Key Ideas Handing off Abstract lock Allows concurrent non-commuting boosted transactions! Novel ideas –Mechanism for passing abstract lock –Thread-local cyclic dependency check –Lazy recovery

66 Deadlock?

67 Detection Dreadlocks –[Herlihy & Koskinen, SPAA 2008] Fast, incremental deadlock detection Low overhead Cache-friendly

68 Waits-For Graph waiting owned

69 Digest

70 Digest

71 Digest Uh-oh!

72 Details Can represent digest as –Bit map (small population) –Bloom filter (larger population) [Herlihy & Koskinen, SPAA 2008]

Challenges Automation? –Theorem proving –Model checking Compiler & Language support? Implementation …