Download presentation
Presentation is loading. Please wait.
Published byKatherine Scott Modified over 8 years ago
1
Commutativity and Coarse-Grained Transactions Maurice Herlihy Brown University Joint work with Eric Koskinen and Matthew Parkinson (POPL 10)
2
CCDP February 2011 2 Moore’s Law (hat tip: Herb Sutter) Clock speed flattening sharply Transistor count still rising
3
CCDP February 2011 3 3 The Multicore Processor cache Bus shared memory cache More processors, Same clock Sun T2000 Niagara
4
CCDP February 2011 4 What Keeps Microsoft and Intel awake at Night? If more cores does not deliver more value … Then why upgrade? ?
5
CCDP February 2011 5 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.
6
CCDP February 2011 6 What could possibly go wrong? Concurrent programming is hard Locks, monitors, etc. do not scale –Confusing –Subject to deadlock –Relies on conventions –Not composable –…
7
CCDP February 2011 7 The Transactional Manifesto Threads + locking don’t scale Replace locking with a transactional API Promising … but not there yet
8
CCDP February 2011 8 Challenge Do transactions provide enough concurrency? –As implemented, arguably No. Does the transactional model provide enough concurrency? –Arguably, Yes.
9
TMW April 2010 Skew Heaps 0 1 Tree with “heap” property 2 4 3
10
TMW April 2010 Concurrent Skew Heap 0 1 3 5 4 2 Insert me! 6
11
TMW April 2010 Concurrent Skew Heap 0 1 3 5 4 2 6 Lock parent Swap R & L
12
TMW April 2010 Concurrent Skew Heap 0 1 3 5 4 6 Lock right child Unlock parent 2
13
TMW April 2010 Concurrent Skew Heap 0 1 3 5 4 6 2 No global rebalancing Good amortized performance Good concurrency
14
TMW April 2010 Transactional Skew Heap 0 1 3 5 4 2 Insert me! 6
15
TMW April 2010 Transactional Skew Heap 0 1 3 5 4 2 6 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
16
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?
17
TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs
18
TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs add(x)
19
TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs add(x)
20
TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object Undo Logs add(x)
21
TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object rem(x) Undo Logs add(x) x
22
TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object rem(x) Undo Logs add(x) x add(y) y
23
TMW April 2010 Pessimistic Boosting transactions Abstract locks Black-box linearizable data object rem(x) Undo Logs add(x) x member(x)
24
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?
25
TMW April 2010 Optimistic Boosting Black-box linearizable data object
26
TMW April 2010 Optimistic Boosting private copies Black-box linearizable data object
27
TMW April 2010 Optimistic Boosting redo logs private copies Black-box linearizable data object
28
TMW April 2010 Optimistic Boosting redo logs private copies Black-box linearizable data object add(x)
29
TMW April 2010 Optimistic Boosting add(x) redo logs private copies Black-box linearizable data object add(x) x
30
TMW April 2010 Optimistic Boosting add(x) add(y) redo logs private copies Black-box linearizable data object add(x) x add(y) y
31
TMW April 2010 On Commit add(x) add(y) redo logs private copies Black-box linearizable data object x y add(x)
32
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
33
TMW April 2010 On Commit add(x) add(y) x y add(x) x x Different physical values, Same logical values
34
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
35
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?
36
TMW April 2010 Left-Movers time legal history
37
TMW April 2010 Left-Movers time If and are adjacent, Ok to move earlier
38
Left-Mover Example: Semaphore time inc()dec() 1 010
39
Inc() is Left-mover WRT Dec() time inc()dec() 1 100 102 1 1
40
Same sequence of calls (results unaffected) Left-Mover Example: Semaphore time inc()dec() 1 100 102 1 1
41
Same final state Left-Mover Example: Semaphore time inc()dec() 3 232 324 3 3
42
Left-Mover Counter-example time 1 dec() 0 inc() 1 dec() 0
43
Dec() not Left-Mover WRT Inc() time 1 dec() 0 inc() 1 dec() 0
44
Right-Movers time legal history
45
Right-Movers time If and are adjacent, Ok to move later
46
Commutativity time If and are adjacent, Ok to swap
47
47 Pessimistic Semantics (modify shared state in place) time Txn B beg Txn A beg Pessimistic Commit: Move Left of pending cmt
48
48 Pessimistic Semantics (modify shared state in place) time Txn B beg Txn A beg abt
49
49 Pessimistic Semantics (modify shared state in place) time 3 Txn B beg Txn A beg 1 2 4 Pessimistic Abort: Move Right of pending 2 4 3 1 Pessimistic Abort: Pending ops move Left
50
50 Optimistic Semantics (modify local copies; merge) time Txn B Txn A beg Optimistic Commit: Move Right of committed cmt
51
51 Optimistic Semantics (modify local copies; merge) time Txn B Txn A beg Optimistic Abort: Discard Operations abt cmt
52
PessimisticOptimistic Two Execution Models 52 Left-MovernessRight-Moverness Algebraic Abstract Properties
53
53 But … Are commutativity+inverses the limit? –Other algebraic properties? Abstract locks are blocking –may cause multiple transactions –may block on same lock
54
54 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } Lock key 3
55
55 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } Add value 3
56
56 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } If set modified, Log inverse
57
57 Example atomic { with (abstractLock(3)){ if (skiplist.insert(3)) { self.onAbort.add( (λ() skiplist.remove(3))) } bigComputation(); } Do something long, Not involving skiplist
58
58 Conflicting Operations remove(3) insert(3) no conflict
59
59 Conflicting Locks remove(3) insert(3) (3) No concurrency
60
60 Conflicting Locks insert(3) (3) remove(3) (3)
61
61 Conflicting Locks insert(3) (3) remove(3) (3)
62
62 Conflicting Locks insert(3) (3) remove(3) (3) Lock handoff
63
63 Lock Handoff dependence
64
64 Lock Handoff dependence Lock handoff
65
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
66 Deadlock?
67
67 Detection Dreadlocks –[Herlihy & Koskinen, SPAA 2008] Fast, incremental deadlock detection Low overhead Cache-friendly
68
68 Waits-For Graph waiting owned
69
69 Digest
70
70 Digest
71
71 Digest Uh-oh!
72
72 Details Can represent digest as –Bit map (small population) –Bloom filter (larger population) [Herlihy & Koskinen, SPAA 2008]
73
Challenges Automation? –Theorem proving –Model checking Compiler & Language support? Implementation …
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.