Fm wtm12-v2

43
Objects with adaptive accessors to avoid STM barriers F. Miguel Carvalho and João Cachopo 1 WTM-2012 oftware Engineering Group Bern, Switzerland, April 10, 2012

Transcript of Fm wtm12-v2

Page 1: Fm wtm12-v2

1

Objects with adaptive accessors to avoid STM barriers

F. Miguel Carvalho and João Cachopo

WTM-2012

Software Engineering Group

Bern, Switzerland, April 10, 2012

Page 2: Fm wtm12-v2

2

General Goal

Page 3: Fm wtm12-v2

3

Shared data

Page 4: Fm wtm12-v2

4

atomic

Page 5: Fm wtm12-v2

5

Overheads?

Page 6: Fm wtm12-v2

6

STM Barriers

Page 7: Fm wtm12-v2

Reduce Runtime Overheads

• Redo-log <vs> undo-log• Eager <vs> lazy ownership acquisition• Transactional versioning• No ownership records• Metatada in place• Multi-versioning (e.g. JVSTM)• …

7

Page 8: Fm wtm12-v2

8

Good for read-only

Page 9: Fm wtm12-v2

9

Memory overheads

Page 10: Fm wtm12-v2

10

Winding path

Page 11: Fm wtm12-v2

11

Can we suppress these overheads?

Page 12: Fm wtm12-v2

12

AOMAdaptive Object Metadata

…implemented in the JVSTM

Page 13: Fm wtm12-v2

13

box

:VBox

body:

:Counter

current:

Page 14: Fm wtm12-v2

14

versions’ history

:VBoxBody

next:

value: 2

version: 19

:VBoxBody

next:

value: 1

version: 17

:VBoxBody

next: null

value: 0

version: 13

:VBox

body:

:Counter

current:

The most recent committed value.

Page 15: Fm wtm12-v2

15

Transaction

:VBoxBody

next:

value: 2

version: 19

:VBoxBody

next:

value: 1

version: 17

:VBoxBody

next: null

value: 0

version: 13

:VBox

body:

:Counter

current:

:Transaction

version: 18

…lastCommitted 23

Page 16: Fm wtm12-v2

16

Transaction

:VBoxBody

next:

value: 2

version: 19

:VBoxBody

next:

value: 1

version: 17

:VBoxBody

next: null

value: 0

version: 13

:VBox

body:

:Counter

current:

:Transaction

version: 18

…lastCommitted 23

Transaction 18 reads the version 17

Page 17: Fm wtm12-v2

17

Shared Data

Page 18: Fm wtm12-v2

No contention

18

Page 19: Fm wtm12-v2

19

AOMCompact Extended

Page 20: Fm wtm12-v2

AOM

:SomeType32767

2147483647

34.7

field x

field y

field z

Compact Extended

Page 21: Fm wtm12-v2

AOM

:Something32767

2147483647

34.7

field x

field y

field z

Compact Extended

nullHeader

Page 22: Fm wtm12-v2

AOM

Header32767

2147483647

34.7

Header32767

214748364734.7

value of x

value of y

value of z

version

values

next

:VBoxBody

23

field x

field y

field z

version

values

next

:VBoxBody

19

null

value of x

value of y

value of z

22

Compact Extended

Page 23: Fm wtm12-v2

AOM

Headerx of version 23

z of version 23

y of version 23

Header32767

214748364734.7

value of x

value of y

value of z

version

values

next

:VBoxBody

23

field x

field y

field z

version

values

next

:VBoxBody

19

null

value of x

value of y

value of z

23

Compact Extended1.

2.

Page 24: Fm wtm12-v2

24

1. Extending

header:

x: 3

y: 7

null

Page 25: Fm wtm12-v2

25

:VBoxBody

next:

version: 0

value:

header:

x: 3

y: 7

null

null

:Integer

value: 7

:Integer

value: 3

1

1. Extending

replicate()

Page 26: Fm wtm12-v2

26

:VBoxBody

next:

version: 17

value:

:VBoxBody

next:

version: 0

value:

header:

x: 3

y: 7

null

null

:Integer

value: 7

:Integer

value:11

:Integer

value: 7

:Integer

value: 3

12

1. Extending

replicate()

Page 27: Fm wtm12-v2

27

:VBoxBody

next:

version: 17

value:

:VBoxBody

next:

version: 0

value:

header:

x: 3

y: 7

null

null

:Integer

value: 13

:Integer

value: 11

:Integer

value: 7

:Integer

value: 3

13 2

1. Extending

casHeader()

Page 28: Fm wtm12-v2

2. Reverting

:VBoxBody

next:

version: 17

value:

header:

x: 3

y: 7

:Integer

value: 13

:Integer

value: 11

null

null

2

1

3cas

put

read 28

boolean tryRevert (AdaptiveObject o , VBoxBody body){ if(o.readHeader() == body){ o.toCompactLayout(body.value); return o.casHeaderWithNull(body); } return false;}

1

2

3

Page 29: Fm wtm12-v2

29

AdaptiveObjectabstract class AdaptiveObject <T extends AdaptiveObject{

private VBoxBody<T> header;

public abstract void toCompactLayout(T from); public VBoxBody<T> readHeader(){

return header; } public boolean casHeaderWithNull(VBoxBody<T> expected){

return UtilUnsafe.UNSAFE.compareAndSwapObject(this,header__ADDRESS__, expected, null); }

}

29

boolean tryRevert (AdaptiveObject o , VBoxBody body){ if(o.readHeader() == body){ o.toCompactLayout(body.value); return o.casHeaderWithNull(body); } return false;}

1

2

3

Page 30: Fm wtm12-v2

30

AdaptiveObjectabstract class AdaptiveObject <T extends AdaptiveObject{

private static final long header__ADDRESS__;

private VBoxBody<T> header;

public abstract T replicate();

public abstract void toCompactLayout(T from); public VBoxBody<T> readHeader(){

return header; } public boolean casHeaderWithNull(VBoxBody<T> expected){

return UtilUnsafe.UNSAFE.compareAndSwapObject(this,header__ADDRESS__, expected, null); }

public boolean casHeader(VBoxBody<T> expected, VBoxBody<T> newBody){return UtilUnsafe.UNSAFE.compareAndSwapObject(this, header__ADDRESS__, expected,

newBody); }

}

Page 31: Fm wtm12-v2

31

hierarchy

Object

…… …

… …

… …

… …

… …

Page 32: Fm wtm12-v2

32

hierarchy

AdaptiveObject

…… …

… …

… …

… …

… …

Object

Page 33: Fm wtm12-v2

33

AOM

• 1st release (Multiprog 12)– implemented with the JVSTM lock based– reversion and extension operations specified by an AdaptiveObject interface

• 2nd release:– Implemented with the JVSTM lock free – AdaptiveObject as the root base class– provides a Transparent API (like Deuce STM)

Page 34: Fm wtm12-v2

34

• increases the speedup between 13% and 35%(* Multiprog12)

AOM with JVSTM lock based

0,00

0,50

1,00

1,50

2,00

2,50

3,00

3,50

1 2 4 8 10 12 14 16

Spee

dup

Threads

Circuit Main

0,00

0,50

1,00

1,50

2,00

2,50

3,00

1 2 4 8 10 12 14 16Threads

Circuit Mem

LeeTM

Page 35: Fm wtm12-v2

35

• increases the speedup between 5% and 36%

new AOM with JVSTM lock freeLeeTM

0,00

1,00

2,00

3,00

4,00

5,00

6,00

1 2 4 8 12 16 20 24 28 32 36 40 44 48

Spee

dup

Threads

Circuit Main

JVSTM

AOM

0,00

1,00

2,00

3,00

4,00

5,00

1 2 4 8 12 16 20 24 28 32 36 40 44 48

Spee

dup

Threads

Circuit Mem

Page 36: Fm wtm12-v2

36

STAMP Vacation, low++ & long trxs & RO

• Low contention• ++, large data sets• -n = 256, longer transactions, instead of the

recommendation 2 or 4• 3 kinds of transactions:– Delete and create items: car, flight or room– Remove defaulter clients (bill > 0)– Query and reserve an item: car, flight or room

Splitted in 2 transactions: RO + RW

Page 37: Fm wtm12-v2

STAMP Vacation, low++ & long trxs & RO

• increases the speedup between 18% and 37%• Maximum speedup = 4,32

0,00

0,50

1,00

1,50

2,00

2,50

3,00

3,50

4,00

4,50

5,00

1 2 4 8 12 16 20 24 28 32 36 40 44 48

Spee

dup

Threads

JVSTM

AOM

Page 38: Fm wtm12-v2

38

Comparing with the Deuce STM…

and enhancing the AOM with a transparent API

Turning all objects transactional

Page 39: Fm wtm12-v2

STAMP Vacation, low++ & long trxs & RO

• Maximum speedup = 3,83 (< 4,32 with a non-transparent API)• Still better than the Deuce STM with TL2

0,00

0,50

1,00

1,50

2,00

2,50

3,00

3,50

4,00

4,50

1 2 4 8 12 16 20 24 28 32 36 40 44 48

Spee

dup

Threads

JVSTM

AOM

Deuce TL2

Page 40: Fm wtm12-v2

STAMP Vacation, low++ & long trxs & RO

• Maximum speedup = 1,92• Still better than JVSTM and the Deuce TL2

0,00

0,50

1,00

1,50

2,00

2,50

1 2 4 8 12 16 20 24 28 32 36 40 44 48

Spee

dup

Threads

JVSTM

AOM

Deuce TL2

Page 41: Fm wtm12-v2

41

Future Work

Page 42: Fm wtm12-v2

42

Future Work• An improved reversion algorithm

• New design for AOM that keeps the contention-free execution path without any barrier or validation

• Integrate the AOM compiler in the implementation of the Deuce STM

Page 43: Fm wtm12-v2

43/42