Data-Race Exceptions Have Benefits Beyond the Memory Model Benjamin - - PowerPoint PPT Presentation

data race exceptions have benefits beyond the memory model
SMART_READER_LITE
LIVE PREVIEW

Data-Race Exceptions Have Benefits Beyond the Memory Model Benjamin - - PowerPoint PPT Presentation

Data-Race Exceptions Have Benefits Beyond the Memory Model Benjamin P . Wood , Luis Ceze, Dan Grossman University of Washington 1 Why data-race exceptions? [Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010;


slide-1
SLIDE 1

Data-Race Exceptions Have Benefits Beyond the Memory Model

Benjamin P . Wood, Luis Ceze, Dan Grossman University of Washington

1

slide-2
SLIDE 2

Why data-race exceptions?

[Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...]

2

slide-3
SLIDE 3

Why data-race exceptions?

Find bugs.

[Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...]

2

slide-4
SLIDE 4

Why data-race exceptions?

Find bugs. Simplify memory models. (DRF ⇒ SC)

[Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...]

2

slide-5
SLIDE 5

Why data-race exceptions?

Find bugs. Simplify memory models. Avoid reasoning about memory reorderings. (DRF ⇒ SC)

[Elmas et al., PLDI 2007; Adve and Boehm, CACM Aug. 2010; Marino et al., PLDI 2010; Lucia et al., ISCA 2010; ...]

2

slide-6
SLIDE 6

Why not data-race exceptions?

3

slide-7
SLIDE 7

Why not data-race exceptions?

Lock-free algorithms

3

slide-8
SLIDE 8

Why not data-race exceptions?

“Benign” races Lock-free algorithms

3

slide-9
SLIDE 9

Why not data-race exceptions?

“Benign” races Lock-free algorithms unchecked annotations

3

slide-10
SLIDE 10

Why not data-race exceptions?

“Benign” races Lock-free algorithms

Performance overheads

unchecked annotations

  • ngoing research

3

slide-11
SLIDE 11

Overheads memory models. Find bugs.

costs benefits

Simplify

4

slide-12
SLIDE 12

Overheads memory models. Find bugs.

costs benefits

Simplify

4

slide-13
SLIDE 13

Overheads memory models. Find bugs.

costs benefits

Simplify

4

slide-14
SLIDE 14

Overheads memory models. Find bugs.

costs benefits

Simplify

?

4

This talk explores hidden benefits (and costs)

  • f data-race exceptions in runtime systems.
slide-15
SLIDE 15

Overheads memory models. Find bugs.

costs benefits

Simplify

?

?

4

This talk explores hidden benefits (and costs)

  • f data-race exceptions in runtime systems.
slide-16
SLIDE 16

costs benefits This talk explores hidden benefits (and costs)

  • f data-race exceptions in runtime systems.

Overheads

?

memory models. Find bugs. Simplify

?

5

slide-17
SLIDE 17

All races are inherently wrong.

6

slide-18
SLIDE 18

u n a n n

  • t

a t e d

All races are inherently wrong.

6

^

slide-19
SLIDE 19

u n a n n

  • t

a t e d

Attempts at racy accesses are exceptional, but legal. All races are inherently wrong.

6

^

Exceptions ensure all races are impossible.

u n a n n

  • t

a t e d

^

u n a n n

  • t

a t e d

^

slide-20
SLIDE 20

Contributions

Review data races, exceptions, and sequential consistency. Properties of data-race exceptions enable conflict detection. Exploit data-race exceptions in concurrent garbage collection. Low-level data-race exceptions have subtle implications. Conclusions

contributions

7

slide-21
SLIDE 21

Outline

Review data races, exceptions, and sequential consistency. Properties of data-race exceptions enable conflict detection. Exploit data-race exceptions in concurrent garbage collection. Low-level data-race exceptions have subtle implications. Conclusions

  • utline

8

slide-22
SLIDE 22

data race

a pair of concurrent, conflicting accesses

x := 1 r1 := y y := 1 Thread 1 Thread 2

time

data race r2 := x release(m) acquire(m)

synchronization

9

slide-23
SLIDE 23

x := 1 r1 := y y := 1 Thread 1 Thread 2

time

data race r2 := x release(m) acquire(m)

synchronization

10

exception on second access

slide-24
SLIDE 24

data-race exceptions

guarantee either data-race-free or exception

x := 1 r1 := y y := 1 Thread 1 Thread 2

time

data race r2 := x release(m) acquire(m)

synchronization

10

exception on second access

slide-25
SLIDE 25

data-race exceptions

guarantee either data-race-free or exception

x := 1 r1 := y y := 1 Thread 1 Thread 2

time

data race r2 := x release(m) acquire(m)

synchronization

exception

10

exception on second access

slide-26
SLIDE 26

Java/C++

DRF ⇒ SC

Data-race exceptions

DRF ⊕ exception and SC or exception

11

slide-27
SLIDE 27

data-race exceptions in HW

precise Suspend the thread just before its racy access. Respect program order. handleable Deliver a trap with information about the race. y := 1 ... race r2 := x acquire(m) r3 := z

exception delivery time

12

slide-28
SLIDE 28

Concurrent Garbage Collection

Concurrent mark-sweep: atomic/consistent heap traversal tri-color marking and write barriers Concurrent copying/moving: atomic object copying Piggyback on STM runtime [McGachey et al., PPoPP 2008] Lock-free algorithms [Pizlo et al., ISMM 2007, PLDI 2008]

concurrent GC

13

slide-29
SLIDE 29

Heap

reachable, refs visited reachable, refs unvisited unreachable/unknown

mark-sweep

14

GC thread

next next next

a b c gray(a) Mutator

slide-30
SLIDE 30

Heap

reachable, refs visited reachable, refs unvisited unreachable/unknown

mark-sweep

14

GC thread

next next next

a b c gray(a) gray(a.next) Mutator

slide-31
SLIDE 31

Heap

mark-sweep

15

GC thread

next next next

a b c gray(a) gray(a.next)

reachable, refs visited reachable, refs unvisited unreachable/unknown

Mutator

slide-32
SLIDE 32

Heap

mark-sweep

15

GC thread

next next next

a b c gray(a) gray(a.next)

reachable, refs visited reachable, refs unvisited unreachable/unknown

black(a) Mutator

slide-33
SLIDE 33

Heap

mark-sweep

16

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a)

reachable, refs visited reachable, refs unvisited unreachable/unknown

slide-34
SLIDE 34

Heap

mark-sweep

16

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

slide-35
SLIDE 35

Heap

mark-sweep

16

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b)

slide-36
SLIDE 36

Heap

mark-sweep

17

GC thread Mutator

next next

a b

next

c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null gray(b.next) black(b)

reachable, refs visited reachable, refs unvisited unreachable/unknown

slide-37
SLIDE 37

Heap

mark-sweep

17

GC thread Mutator

next next

a b gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null gray(b.next) black(b) collect(c)

reachable, refs visited reachable, refs unvisited unreachable/unknown

slide-38
SLIDE 38

Heap

mark-sweep

17

GC thread Mutator

next next

a b gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null gray(b.next) black(b) collect(c)

reachable, refs visited reachable, refs unvisited unreachable/unknown

slide-39
SLIDE 39

Heap

mark-sweep

18

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

reachable, refs visited reachable, refs unvisited unreachable/unknown

slide-40
SLIDE 40

Heap

mark-sweep

18

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(c)

slide-41
SLIDE 41

Heap

mark-sweep

19

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(c)

slide-42
SLIDE 42

Heap

mark-sweep

19

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b) gray(c)

slide-43
SLIDE 43

Heap

mark-sweep

20

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b) gray(c)

slide-44
SLIDE 44

Heap

mark-sweep

20

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b) gray(c.next) black(c) gray(c)

slide-45
SLIDE 45

Heap

mark-sweep

21

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b) gray(c.next) black(c) gray(c)

slide-46
SLIDE 46

Heap

mark-sweep

21

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b) gray(c.next) black(c) gray(c)

slide-47
SLIDE 47

Heap

mark-sweep

21

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b) gray(c.next) black(c)

exception: gray(c)

gray(c)

slide-48
SLIDE 48

Heap

mark-sweep

21

GC thread Mutator

next next next

a b c gray(a) gray(a.next) black(a) n := a.next

a.next := a.next.next

n.next := null

reachable, refs visited reachable, refs unvisited unreachable/unknown

gray(b.next) black(b) gray(c.next) black(c)

exception: gray(c)

gray(c)

exception: ???

slide-49
SLIDE 49

Extensions for implementing GC with DREs

Erase tracks Remove and replace last reads and last writes. Racy read Record and execute a read even if it races. Data-carrying exceptions Deliver a racing write value to a racing read. ...

extensions for GC

22

slide-50
SLIDE 50

23

Use HW data-race exceptions in runtime systems.

SO FAR

slide-51
SLIDE 51

23

Use HW data-race exceptions in runtime systems. Do guarantees from HW data-race exceptions apply at the program level?

SO FAR NOW

slide-52
SLIDE 52

hardware hypervisor source program compiler garbage collector

  • perating system

24

high-level support

slide-53
SLIDE 53

hardware hypervisor source program compiler garbage collector

  • perating system

24

slide-54
SLIDE 54

hardware hypervisor source program compiler garbage collector

  • perating system

25

slide-55
SLIDE 55

hardware hypervisor source program compiler garbage collector

  • perating system

25

non-program accesses and sync.{

slide-56
SLIDE 56

Running GC on top of DRE

Movement Race-detector state must follow moved objects atomically. Invisibility Only program heap writes should be seen by the race detector. GC writes to the heap should be ignored. No transitive ordering GC must not induce ordering between mutators.

caveats for any GC

26

slide-57
SLIDE 57

hardware hypervisor source program compiler garbage collector

  • perating system

data-race exceptions

27

cooperation vs. abstraction

slide-58
SLIDE 58

Luis said I should have this slide.

More details on concurrent GC using data-race exceptions Lock elision with no rollback support Conflict races and conflict-race exceptions

also in the paper...

28

slide-59
SLIDE 59

Conclusions

Data-race exceptions have benefits beyond the memory model. Exceptions make races impossible. Attempted races are exceptional, but legal. Data-race exceptions enable general conflict detection for runtime systems like concurrent GC. Low-level data-race detection has subtle implications.

conclusions

29

slide-60
SLIDE 60

30

This slide intentionally not left blank.

slide-61
SLIDE 61

conflict race

data race across synchronization-free regions running concurrently in real time

time

Thread 1 Thread 2 wr y conflict race wr x rd y rd x ... rd x data race, no conflict race

31

slide-62
SLIDE 62

time

Thread 1 Thread 2 wr y conflict race wr x rd y rd x ... rd x data race, no conflict race

32

slide-63
SLIDE 63

conflict-race exceptions

guarantee sequential consistency or exception

time

Thread 1 Thread 2 wr y conflict race wr x rd y rd x ... rd x data race, no conflict race

32

slide-64
SLIDE 64

conflict-race exceptions

guarantee sequential consistency or exception

time

Thread 1 Thread 2 wr y conflict race wr x rd y rd x ... rd x data race, no conflict race

exception

32

slide-65
SLIDE 65

Best-effort automatic recovery from conflict races

Thread 1 Thread 2 rd x conflict race wr x wr y rd x rd y ... 1 2 [delay] ! "

time

33

slide-66
SLIDE 66

Best-effort automatic recovery from conflict races

Thread 1 Thread 2 rd x conflict race wr x wr y rd x rd y ... 1 2 [delay] ! "

exception time

33

slide-67
SLIDE 67

Best-effort automatic recovery from conflict races

Thread 1 Thread 2 rd x conflict race wr x wr y rd x rd y ... 1 2 [delay] ! "

exception success time

33

slide-68
SLIDE 68

GC Thread Mutator Resulting Heap tmp = o.x

  • '.x = tmp
  • .forward = o'

p = o.forward p.x = 2 p = o.forward p.x = 1 forward

  • x

1 forward

  • x

1 forward

  • x

2 forward

  • x

2 forward

  • '

x 1 forward

  • '

x 1 forward

  • '

x 1 2 3 4 R-W race

  • ' = malloc(...)
  • '.forward = o'

forward

  • '

x 1 forward

  • x

1

moving/copying

34

slide-69
SLIDE 69

GC Thread Mutator Resulting Heap tmp = o.x

  • '.x = tmp
  • .forward = o'

p = o.forward p.x = 2 p = o.forward p.x = 1 forward

  • x

1 forward

  • x

1 forward

  • x

2 forward

  • x

2 forward

  • '

x 1 forward

  • '

x 1 forward

  • '

x 1 2 3 4 R-W race

  • ' = malloc(...)
  • '.forward = o'

forward

  • '

x 1 forward

  • x

1

moving/copying

34

slide-70
SLIDE 70

GC Thread Mutator Resulting Heap tmp = o.x

  • '.x = tmp
  • .forward = o'

p = o.forward p.x = 2 p = o.forward p.x = 1 forward

  • x

1 forward

  • x

1 forward

  • x

2 forward

  • x

2 forward

  • '

x 1 forward

  • '

x 1 forward

  • '

x 1 2 3 4 R-W race

  • ' = malloc(...)
  • '.forward = o'

forward

  • '

x 1 forward

  • x

1

moving/copying

34

slide-71
SLIDE 71

GC Thread Mutator Resulting Heap tmp = o.x

  • '.x = tmp
  • .forward = o'

p = o.forward p.x = 2 p = o.forward p.x = 1 forward

  • x

1 forward

  • x

1 forward

  • x

2 forward

  • x

2 forward

  • '

x 1 forward

  • '

x 1 forward

  • '

x 1 2 3 4 R-W race

  • ' = malloc(...)
  • '.forward = o'

forward

  • '

x 1 forward

  • x

1

moving/copying

34

slide-72
SLIDE 72

GC Thread Mutator Resulting Heap tmp = o.x

  • '.x = tmp
  • .forward = o'

p = o.forward p.x = 2 p = o.forward p.x = 1 forward

  • x

1 forward

  • x

1 forward

  • x

2 forward

  • x

2 forward

  • '

x 1 forward

  • '

x 1 forward

  • '

x 1 2 3 4 R-W race

  • ' = malloc(...)
  • '.forward = o'

forward

  • '

x 1 forward

  • x

1

moving/copying

34