commutativity and coarse grained transactions l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Commutativity and Coarse-Grained Transactions PowerPoint Presentation
Download Presentation
Commutativity and Coarse-Grained Transactions

Loading in 2 Seconds...

play fullscreen
1 / 73

Commutativity and Coarse-Grained Transactions - PowerPoint PPT Presentation


  • 251 Views
  • Uploaded on

Commutativity and Coarse-Grained Transactions. Maurice Herlihy Brown University Joint work with Eric Koskinen and Matthew Parkinson   (POPL 10). Moore’s Law. Transistor count still rising. Clock speed flattening sharply. (hat tip: Herb Sutter). The Multicore Processor. More processors,

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Commutativity and Coarse-Grained Transactions' - Audrey


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
commutativity and coarse grained transactions

Commutativity andCoarse-Grained Transactions

Maurice Herlihy

Brown University

Joint work with Eric Koskinen and Matthew Parkinson  (POPL 10)

moore s law
Moore’s Law

Transistor count still rising

Clock speed flattening sharply

(hat tip: Herb Sutter)

CCDP February 2011

the multicore processor
The Multicore Processor

More processors,

Same clock

Sun T2000

Niagara

cache

cache

cache

Bus

Bus

shared memory

CCDP February 2011

3

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.

Washing Machine Science?

CCDP February 2011

what could possibly go wrong
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 2011

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

CCDP February 2011

challenge
Challenge
  • Do transactions provide enough concurrency?
    • As implemented, arguably No.
  • Does the transactional model provide enough concurrency?
    • Arguably, Yes.

CCDP February 2011

skew heaps
Skew Heaps

Tree with “heap” property

0

1

2

3

4

TMW April 2010

concurrent skew heap
Concurrent Skew Heap

Insert me!

Insert me!

6

0

2

1

3

4

5

TMW April 2010

concurrent skew heap11
Concurrent Skew Heap

2

6

0

Lock parent

Swap R & L

1

3

4

5

TMW April 2010

concurrent skew heap12
Concurrent Skew Heap

2

6

0

Unlock parent

1

3

4

5

Lock right child

TMW April 2010

concurrent skew heap13
Concurrent Skew Heap

No global rebalancing

6

0

1

3

Good amortized performance

4

5

2

Good concurrency

TMW April 2010

transactional skew heap
Transactional Skew Heap

Insert me!

Insert me!

6

0

2

1

3

4

5

TMW April 2010

transactional skew heap15
Transactional Skew Heap

Good concurrency with locking

2

6

0

Write-write conflict!

I wrote

Not with transactions …

1

3

0

4

5

Confusion between

thread-level & transaction-level synchronization

TMW April 2010

coarse grained synchronization
Coarse-Grained Synchronization

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 ofconflict?

TMW April 2010

pessimistic boosting
Pessimistic Boosting

Undo Logs

transactions

Abstract locks

Black-box linearizable data object

TMW April 2010

pessimistic boosting18
Pessimistic Boosting

add(x)

Undo Logs

transactions

Abstract locks

Black-box linearizable data object

TMW April 2010

pessimistic boosting19
Pessimistic Boosting

add(x)

Undo Logs

transactions

Abstract locks

Black-box linearizable data object

TMW April 2010

pessimistic boosting20
Pessimistic Boosting

add(x)

Undo Logs

transactions

Abstract locks

Black-box linearizable data object

TMW April 2010

pessimistic boosting21
Pessimistic Boosting

add(x)

rem(x)

x

Undo Logs

transactions

Abstract locks

Black-box linearizable data object

TMW April 2010

pessimistic boosting22
Pessimistic Boosting

add(x)

rem(x)

add(y)

x

y

Undo Logs

transactions

Abstract locks

Black-box linearizable data object

TMW April 2010

pessimistic boosting23
Pessimistic Boosting

add(x)

rem(x)

member(x)

x

Undo Logs

transactions

Abstract locks

Black-box linearizable data object

TMW April 2010

pessimistic boosting24
Pessimistic Boosting

Thread-safe base object

Log Inverses

Updated in place

Conflicting operations blocked by abstract locks

What does it mean for operations to conflict?

TMW April 2010

optimistic boosting
Optimistic Boosting

Black-box linearizable data object

TMW April 2010

optimistic boosting26
Optimistic Boosting

private copies

Black-box linearizable data object

TMW April 2010

optimistic boosting27
Optimistic Boosting

redo logs

private copies

Black-box linearizable data object

TMW April 2010

optimistic boosting28
Optimistic Boosting

add(x)

redo logs

private copies

Black-box linearizable data object

TMW April 2010

optimistic boosting29
Optimistic Boosting

add(x)

redo logs

add(x)

private copies

x

Black-box linearizable data object

TMW April 2010

optimistic boosting30
Optimistic Boosting

add(y)

add(x)

redo logs

add(x)

add(y)

private copies

x

y

Black-box linearizable data object

TMW April 2010

on commit
On Commit

redo logs

add(x)

add(y)

add(x)

private copies

x

y

add(x)

Black-box linearizable data object

TMW April 2010

on commit32

No conflict, apply updates to my copy

On Commit

redo logs

add(x)

add(y)

add(x)

private copies

x

x

y

add(x)

x

Black-box linearizable data object

TMW April 2010

on commit33
On Commit

Different physical values,

Same logical values

add(x)

add(y)

add(x)

x

x

y

add(x)

x

TMW April 2010

on commit34

Conflict! Abort & restore my copy

On Commit

redo logs

add(x)

rem(x)

add(x)

private copies

x

add(x)

x

Black-box linearizable data object

TMW April 2010

optimistic boosting35
Optimistic Boosting

Thread-local object copies

Deferred operatons kept in redo log

No inverses

On commit, broadcast deferred operations

To other transactions, public copy

Transactions snoop on broadcast,

Abort if conflict detected

What does it mean for operations to conflict?

TMW April 2010

left movers

time

Left-Movers

legal history

TMW April 2010

left movers37

time

Left-Movers

If and are adjacent,

Ok to move earlier

TMW April 2010

inc is left mover wrt dec

time

Inc() is Left-mover WRT Dec()

inc()

dec()

dec()

1

0

1

1

0

2

1

1

0

left mover example semaphore40

time

Left-Mover Example: Semaphore

Same sequence of calls

(results unaffected)

inc()

dec()

dec()

1

0

1

1

0

2

1

1

0

left mover example semaphore41

time

Left-Mover Example: Semaphore

inc()

dec()

dec()

3

3

2

3

2

4

3

3

2

Same final state

right movers

time

Right-Movers

legal history

right movers45

time

Right-Movers

If and are adjacent,

Ok to move later

commutativity

time

Commutativity

If and are adjacent,

Ok to swap

pessimistic semantics modify shared state in place

time

Pessimistic Semantics(modify shared state in place)

Txn A

beg

cmt

Txn B

beg

Pessimistic Commit: Move Left of pending

pessimistic semantics modify shared state in place49

time

Pessimistic Semantics(modify shared state in place)

Txn A

beg

2

3

1

3

2

4

4

1

Txn B

beg

Pessimistic Abort: Move Right of pending

Pessimistic Abort: Pending ops move Left

optimistic semantics modify local copies merge

time

Optimistic Semantics(modify local copies; merge)

Txn A

beg

cmt

Txn B

cmt

Optimistic Commit: Move Right of committed

optimistic semantics modify local copies merge51

time

Optimistic Semantics(modify local copies; merge)

Txn A

beg

abt

Txn B

cmt

Optimistic Abort: Discard Operations

two execution models
Two Execution Models

Algebraic Abstract Properties

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

atomic {

with (abstractLock(3)){

if (skiplist.insert(3)) {

self.onAbort.add(

(λ() skiplist.remove(3)))

}

}

bigComputation();

}

Lock key 3

example55
Example

atomic {

with (abstractLock(3)){

if (skiplist.insert(3)) {

self.onAbort.add(

(λ() skiplist.remove(3)))

}

}

bigComputation();

}

Add value 3

example56
Example

atomic {

with (abstractLock(3)){

if (skiplist.insert(3)) {

self.onAbort.add(

(λ() skiplist.remove(3)))

}

}

bigComputation();

}

If set modified,

Log inverse

example57
Example

atomic {

with (abstractLock(3)){

if (skiplist.insert(3)) {

self.onAbort.add(

(λ() skiplist.remove(3)))

}

}

bigComputation();

}

Do something long,

Not involving skiplist

conflicting operations
Conflicting Operations

remove(3)

insert(3)

no conflict

conflicting locks

(3)

Conflicting Locks

remove(3)

insert(3)

No concurrency

(3)

conflicting locks62

remove(3)

(3)

(3)

Conflicting Locks

insert(3)

Lock handoff

lock handoff
Lock Handoff

dependence

lock handoff64
Lock Handoff

dependence

Lock handoff

key ideas
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
detection
Detection
  • Dreadlocks
    • [Herlihy & Koskinen, SPAA 2008]
  • Fast, incremental deadlock detection
  • Low overhead
  • Cache-friendly
waits for graph
Waits-For Graph

waiting

owned

digest71
Digest

Uh-oh!

details
Details
  • Can represent digest as
    • Bit map (small population)
    • Bloom filter (larger population)
  • [Herlihy & Koskinen, SPAA 2008]
challenges
Challenges
  • Automation?
    • Theorem proving
    • Model checking
  • Compiler & Language support?
  • Implementation …