Exploiting the Commutativity Lattice Donald Nguyen, Dimitrios - - PowerPoint PPT Presentation

exploiting the commutativity lattice
SMART_READER_LITE
LIVE PREVIEW

Exploiting the Commutativity Lattice Donald Nguyen, Dimitrios - - PowerPoint PPT Presentation

Exploiting the Commutativity Lattice Donald Nguyen, Dimitrios Milind Kulkarni Prountzos, Xin Sui and Keshav Pingali Wednesday, July 20, 2011 Exploiting semantics in transactional execution Set S: X Y Z 2 Wednesday, July 20, 2011


slide-1
SLIDE 1

Exploiting the Commutativity Lattice

Milind Kulkarni Donald Nguyen, Dimitrios Prountzos, Xin Sui and Keshav Pingali

Wednesday, July 20, 2011

slide-2
SLIDE 2

Exploiting semantics in transactional execution

2

Set S:

X Y Z

Wednesday, July 20, 2011

slide-3
SLIDE 3

Exploiting semantics in transactional execution

2

atomic { ... S.add(a) ... }

Set S:

atomic { ... S.contains(b) ... }

X Y Z

Wednesday, July 20, 2011

slide-4
SLIDE 4

Exploiting semantics in transactional execution

2

atomic { ... S.add(a) ... }

Set S:

atomic { ... S.contains(b) ... }

X Y Z X Y Z A

Wednesday, July 20, 2011

slide-5
SLIDE 5

Exploiting semantics in transactional execution

2

atomic { ... S.add(a) ... }

Set S:

atomic { ... S.contains(b) ... }

X Y Z X Y Z A

X

Wednesday, July 20, 2011

slide-6
SLIDE 6

Exploiting semantics in transactional execution

2

atomic { ... S.add(a) ... }

Set S:

atomic { ... S.contains(b) ... }

X Y Z X Y Z A

Wednesday, July 20, 2011

slide-7
SLIDE 7

Exploiting semantics in transactional execution

2

atomic { ... S.add(a) ... }

Set S:

atomic { ... S.contains(b) ... }

X Y Z X Y Z A

Wednesday, July 20, 2011

slide-8
SLIDE 8

X Y Z A

atomic { ... S.add(a) ... } atomic { ... S.contains(b) ... }

Exploiting semantics in transactional execution

3

Set S:

Wednesday, July 20, 2011

slide-9
SLIDE 9

X Y Z A

atomic { ... S.add(a) ... } atomic { ... S.contains(b) ... }

Exploiting semantics in transactional execution

3

Set S:

Key insight: exploit commutativity properties to ensure transactional behavior

Wednesday, July 20, 2011

slide-10
SLIDE 10

X Y Z A

atomic { ... S.add(a) ... } atomic { ... S.contains(b) ... }

Exploiting semantics in transactional execution

3

Set S:

Key insight: exploit commutativity properties to ensure transactional behavior

[Herlihy & Koskinen PPoPP 08] [Ni et al. PPoPP 07] [Kulkarni et al. PLDI 07] [Kulkarni et al. ASPLOS 08] [Koskinen et al. POPL 10] [Carlstrom et al. PPoPP 07] [Weihl et al. IEEE ToC 88]

Wednesday, July 20, 2011

slide-11
SLIDE 11

How do we check commutativity?

  • Can specify conditions for commutativity:
  • How should a transactional run-time system

check these?

  • Prior work: ad hoc combinations of logging

and locking

4

add(a)/r commutes with contains(b)/r if

a ≠ b

Wednesday, July 20, 2011

slide-12
SLIDE 12

How do we check commutativity?

5

add(a)/r commutes with contains(b)/r if

a ≠ b

Wednesday, July 20, 2011

slide-13
SLIDE 13

How do we check commutativity?

5

add(a)/r commutes with contains(b)/r if

a ≠ b or r = false

Wednesday, July 20, 2011

slide-14
SLIDE 14

How do we check commutativity?

  • Commutativity can be more complex:
  • Prior work often did not fully check

commutativity to reduce overhead

  • How do we know this is correct?

5

add(a)/r commutes with contains(b)/r if

a ≠ b or r = false

Wednesday, July 20, 2011

slide-15
SLIDE 15

Contributions

  • Define a commutativity lattice for reasoning

about commutativity specifications

  • How do we check commutativity?
  • Provide systematic approaches for

implementing commutativity checks

  • How do we implement low overhead checks?
  • Show how to use commutativity lattice to

correctly construct lower-overhead checkers

6

Wednesday, July 20, 2011

slide-16
SLIDE 16

Commutativity

7

σ1

Wednesday, July 20, 2011

slide-17
SLIDE 17

Commutativity

7

m1

r1 σ1

Wednesday, July 20, 2011

slide-18
SLIDE 18

Commutativity

7

m1

r1 σ1 σ2

Wednesday, July 20, 2011

slide-19
SLIDE 19

Commutativity

7

m1 m2

r1 r2 σ1 σ2

Wednesday, July 20, 2011

slide-20
SLIDE 20

Commutativity

7

m1 m2

r1 r2 σ1 σ2 σ3

Wednesday, July 20, 2011

slide-21
SLIDE 21

Commutativity

7

m1 m2

r1 r2 σ1 σ2 σ3 m1, m2 commute in σ1

Wednesday, July 20, 2011

slide-22
SLIDE 22

Commutativity

8

m1 m2

r1 r2 σ1 σ’2 σ3 m1, m2 commute in σ1

Wednesday, July 20, 2011

slide-23
SLIDE 23

Using commutativity to guarantee serializability

9

B: A:

m1 m2 m3 m4 m1 m2 m3 m4

Wednesday, July 20, 2011

slide-24
SLIDE 24

Using commutativity to guarantee serializability

10

m1 m2 m3 m4 m1 m2 m3 m4

History :

Wednesday, July 20, 2011

slide-25
SLIDE 25

Using commutativity to guarantee serializability

10

m1 m2 m3 m4 m1 m2 m3 m4

History : σ1 σ2 σ3 σ4 σ5 σ6 σ7 σ8 σ9

Wednesday, July 20, 2011

slide-26
SLIDE 26

Using commutativity to guarantee serializability

11

m1 m2 m3 m4 m1 m2 m3 m4

History : σ1 σ2 σ3 σ’4 σ5 σ6 σ7 σ8 σ9

Wednesday, July 20, 2011

slide-27
SLIDE 27

Using commutativity to guarantee serializability

12

m1 m2 m3 m4 m1 m2 m3 m4

History : σ1 σ2 σ’3 σ’4 σ5 σ6 σ7 σ8 σ9

Wednesday, July 20, 2011

slide-28
SLIDE 28

Using commutativity to guarantee serializability

13

m1 m2 m3 m4 m1 m2 m3 m4

History : σ1 σ2 σ’3 σ”4 σ’5 σ’6 σ’7 σ8 σ9

Wednesday, July 20, 2011

slide-29
SLIDE 29

Runtime commutativity checks

  • For each method invocation by transaction B
  • Runtime checks commutativity with all

methods invoked by transaction A

  • If all checks succeed, execution continues
  • If any commutativity check fails, one

transaction rolled back

14

Wednesday, July 20, 2011

slide-30
SLIDE 30

φ(ma, mb)

Commutativity conditions

15

Commutativity condition:

Wednesday, July 20, 2011

slide-31
SLIDE 31

φ(ma, mb)

Commutativity conditions

15

Commutativity condition:

true only if ma and mb commute

Wednesday, July 20, 2011

slide-32
SLIDE 32

φ(ma, mb)

Commutativity conditions

15

Commutativity condition: Precise condition:

φ(ma, mb)

*

Wednesday, July 20, 2011

slide-33
SLIDE 33

φ(ma, mb)

Commutativity conditions

15

Commutativity condition: Precise condition:

φ(ma, mb)

*

true if and only if ma and mb commute

Wednesday, July 20, 2011

slide-34
SLIDE 34

φ(ma, mb)

Commutativity conditions

15

Commutativity condition: Precise condition:

φ(ma, mb)

*

φ(add(a)/r1, contains(b)/r2)

* a ≠ b or r1 = false

Wednesday, July 20, 2011

slide-35
SLIDE 35

Commutativity lattice

16

(add(a)/r1, contains(b)/r2) a ≠ b or r1 = false

Wednesday, July 20, 2011

slide-36
SLIDE 36

Commutativity lattice

16

(add(a)/r1, contains(b)/r2) a ≠ b or r1 = false false a ≠ b r1 = false

Wednesday, July 20, 2011

slide-37
SLIDE 37

Commutativity lattice

16

(add(a)/r1, contains(b)/r2) a ≠ b or r1 = false false a ≠ b r1 = false Allows most parallelism Allows no parallelism

Wednesday, July 20, 2011

slide-38
SLIDE 38

Implementing Commutativity

Wednesday, July 20, 2011

slide-39
SLIDE 39

Soundness and completeness

  • A conflict detection implementation is sound

if it claims methods commute only if they actually do according to the conditions

  • A conflict detection implementation is

complete if it claims methods commute if they do according to the conditions

18

Wednesday, July 20, 2011

slide-40
SLIDE 40

Running example

  • Set-like data structure
  • Supports add and contains

19

(add(a)/r1, contains(b)/r2) a ≠ b or r1 = false (add(a)/r1, add(b)/r2) a ≠ b or (r1 = false and r2 = false) (contains(a)/r1, contains(b)/r2) true

Wednesday, July 20, 2011

slide-41
SLIDE 41

Running example

  • Set-like data structure
  • Supports add and contains

20

(add(a)/r1, contains(b)/r2) a ≠ b (add(a)/r1, add(b)/r2) a ≠ b (contains(a)/r1, contains(b)/r2) true

Wednesday, July 20, 2011

slide-42
SLIDE 42

Implementing commutativity

  • Three schemes
  • Abstract locking
  • Forward gatekeeping
  • General gatekeeping

21

Wednesday, July 20, 2011

slide-43
SLIDE 43

Abstract locking

  • Sound and complete implementation when

commutativity condition is simple

  • Is either true, false, or a set of conjuncts
  • f the form “x ≠ y”

22

(add(a)/r1, contains(b)/r2) a ≠ b a ≠ b or r1 = false Not simple: Simple:

Wednesday, July 20, 2011

slide-44
SLIDE 44

Abstract locking

  • Basic skeleton
  • Associate an abstract lock with each object that

can be passed as an argument to a method

  • When a method is called, acquire locks on each

argument in appropriate mode

  • Object already locked → commutativity violation
  • All locks released when transaction ends
  • Key problem: building compatibility matrix

23

Wednesday, July 20, 2011

slide-45
SLIDE 45

Building compatibility matrix

  • One mode per argument of a method

24

add(a) → add:1 contains(b) → cont:1

Wednesday, July 20, 2011

slide-46
SLIDE 46

Building compatibility matrix

  • One mode per argument of a method

24

add(a) → add:1 contains(b) → cont:1

add:1 cont:1 add:1 cont:1

Wednesday, July 20, 2011

slide-47
SLIDE 47

Building compatibility matrix

  • Compatibility: If condition includes conjunct

“a ≠ b” then modes for a and b incompatible

25

add:1 cont:1 add:1 cont:1

φ(add(a)/r1, contains(b)/r2) :

a ≠ b

Wednesday, July 20, 2011

slide-48
SLIDE 48

Building compatibility matrix

  • Compatibility: If condition includes conjunct

“a ≠ b” then modes for a and b incompatible

25

add:1 cont:1 add:1 cont:1

φ(add(a)/r1, contains(b)/r2) :

a ≠ b

Wednesday, July 20, 2011

slide-49
SLIDE 49

Building compatibility matrix

  • Compatibility: modes for a and b

incompatible if condition includes conjunct “a ≠ b”

26

add:1 cont:1 add:1 cont:1

φ(add(a)/r1, add(b)/r2) :

a ≠ b

Wednesday, July 20, 2011

slide-50
SLIDE 50

Building compatibility matrix

  • Compatibility: modes for a and b

incompatible if condition includes conjunct “a ≠ b”

26

add:1 cont:1 add:1 cont:1

φ(add(a)/r1, add(b)/r2) :

a ≠ b

Wednesday, July 20, 2011

slide-51
SLIDE 51

Building the compatibility matrix

  • Compatibility: modes for a and b

incompatible if condition includes conjunct “a ≠ b”

27

add:1 cont:1 add:1 cont:1

φ(contains(a)/r1, contains(b)/r2) : true

Wednesday, July 20, 2011

slide-52
SLIDE 52

Building the compatibility matrix

  • Compatibility: modes for a and b

incompatible if condition includes conjunct “a ≠ b”

27

add:1 cont:1 add:1 cont:1

φ(contains(a)/r1, contains(b)/r2) : true

Wednesday, July 20, 2011

slide-53
SLIDE 53

Other conflict detection techniques

  • Forward gatekeeping: sound and complete

for more complex conditions

  • General gatekeeping: allows most flexibility

in commutativity conditions

  • Basic tradeoff: Increasing complexity = more

expressive, but more overhead

28

a ≠ b or r1 = false

Wednesday, July 20, 2011

slide-54
SLIDE 54

Trading off parallelism for overhead

Wednesday, July 20, 2011

slide-55
SLIDE 55
  • No prior work fully implemented

commutativity for sets

  • Used lower-overhead schemes instead

Set spec

Lowering overhead of conflict detection

30

Wednesday, July 20, 2011

slide-56
SLIDE 56
  • No prior work fully implemented

commutativity for sets

  • Used lower-overhead schemes instead

Set spec

Lowering overhead of conflict detection

30

Forward gatekeeper

Wednesday, July 20, 2011

slide-57
SLIDE 57
  • No prior work fully implemented

commutativity for sets

  • Used lower-overhead schemes instead

Set spec

Lowering overhead of conflict detection

30

Forward gatekeeper Abstract locks

Wednesday, July 20, 2011

slide-58
SLIDE 58
  • No prior work fully implemented

commutativity for sets

  • Used lower-overhead schemes instead

Set spec

Lowering overhead of conflict detection

30

Forward gatekeeper Abstract locks

??

Wednesday, July 20, 2011

slide-59
SLIDE 59
  • To lower overhead, build sound and

complete implementation of a different specification

Set spec’

Disciplined approach

31

Forward gatekeeper Abstract locks

Set spec

Wednesday, July 20, 2011

slide-60
SLIDE 60
  • To lower overhead, build sound and

complete implementation of a different specification

Set spec’

Disciplined approach

31

Forward gatekeeper Abstract locks

Set spec

Wednesday, July 20, 2011

slide-61
SLIDE 61
  • To lower overhead, build sound and

complete implementation of a different specification

Set spec’

Disciplined approach

31

Forward gatekeeper Abstract locks

Set spec

Wednesday, July 20, 2011

slide-62
SLIDE 62
  • Find simpler specifications from lower in the lattice

Exploiting the commutativity lattice

32

a ≠ b ⋁ r1 = false

Forward gatekeeper

true

φ(contains(a)/r1, contains(b)/r2) : φ(add(a)/r1, contains(b)/r2) :

(add(a)/r1, add(b)/r2)

φ

a ≠ b ⋁ (...)

Wednesday, July 20, 2011

slide-63
SLIDE 63
  • Find simpler specifications from lower in the lattice

Exploiting the commutativity lattice

33

true a ≠ b

Forward gatekeeper R/W locks

φ(contains(a)/r1, contains(b)/r2) : φ(add(a)/r1, contains(b)/r2) :

a ≠ b (add(a)/r1, add(b)/r2)

φ

Wednesday, July 20, 2011

slide-64
SLIDE 64

Exploiting the commutativity lattice

34

φ(contains(a)/r1, contains(b)/r2) : a ≠ b φ(add(a)/r1, contains(b)/r2) :

a ≠ b

Forward gatekeeper R/W locks Exclusive locks

(add(a)/r1, add(b)/r2)

φ

a ≠ b

  • Find simpler specifications from lower in the lattice

Wednesday, July 20, 2011

slide-65
SLIDE 65
  • Speedup

0.0 1.0 2.0 3.0 Threads 1 2 4 8

  • coarse

ex rw

Evaluation

  • Moving through commutativity lattice

effectively trades off parallelism and

  • verhead

35

Preflow push

Wednesday, July 20, 2011

slide-66
SLIDE 66

Evaluation

  • Showed that forward/general gatekeeping

can provide more parallelism and better performance than memory-level locking (e.g., STM)

  • Tradeoffs vary for different applications

➡ Ability to generate and reason about different implementations critical

36

Wednesday, July 20, 2011

slide-67
SLIDE 67

Conclusions

  • Commutativity conditions are an attractive

way to perform conflict detection for transactional execution

  • Commutativity checkers can be

systematically generated from specifications

  • Commutativity lattice provides disciplined

approach to producing checkers, reasoning about behavior

37

Wednesday, July 20, 2011