Safety of Transactions in Transactional Memory: TMS is Necessary and - - PowerPoint PPT Presentation

safety of transactions
SMART_READER_LITE
LIVE PREVIEW

Safety of Transactions in Transactional Memory: TMS is Necessary and - - PowerPoint PPT Presentation

Safety of Transactions in Transactional Memory: TMS is Necessary and Sufficient Hagit Attiya, Technion Sandeep Hans, Technion Alexey Gotsman, IMDEA Noam Rinetzky, Tel-Aviv University TM Consistency Conditions VWC TMS1 Opacity [Guerraoui


slide-1
SLIDE 1

Safety of Transactions in Transactional Memory: TMS is Necessary and Sufficient

Hagit Attiya, Technion Sandeep Hans, Technion Alexey Gotsman, IMDEA Noam Rinetzky, Tel-Aviv University

slide-2
SLIDE 2

TM Consistency Conditions

Opacity [Guerraoui & Kapalka 08]

  • Validity of all transactions (included aborted
  • nes) is checked together

Transactional Memory Specification (TMS1/2) [Doherty, Groves, Luchangco, Moir 09]

  • In TMS1, validity of each response is checked

against a coherent subset of the transactions

– May even include aborted transactions

Virtual World Consistency [Imbs & Raynal 09]

VW C Opacity VWC VWC Opacity TMS1 TMS2

WTTM 2014 2

slide-3
SLIDE 3

Comparing TM Consistency Conditions

Does the TM consistency condition allows to program with a simpler (i.e., atomic) TM in mind?

  • If local variables are rolled back after a transaction

aborts, TMS(1) is sufficient and necessary for programming with an atomic TM in mind

  • If local variables are not rolled back on an abort (e.g.,

ScalaTM), the stronger Opacity condition is necessary

[Attiya, Gotsman, H, Rinetzky 13]

WTTM 2014 3

What is the “right” consistency condition?

slide-4
SLIDE 4
  • What is guaranteed for client programs, when an

implementation is replaced with a simpler one?

TMA TMC

Observational Refinement

WTTM 2014

[He, Hoare, Sanders 86] Client Program

4

slide-5
SLIDE 5
  • Local actions: access only the local variables
  • Global actions: interact with other client programs
  • Interface actions: interact with TM

TM

x:=0;y:=0;z:=0; result := abort; while(result == abort){ result := atomic{ x = X.read(); y = Y.read(); z = 42 / (x-y); Z.write(z); } } g := z;

Interactions of a Program using TM

WTTM 2014

g

Client Program

5

slide-6
SLIDE 6

History: Finite sequence of interface actions Well-formed: Threads are sequential

Histories

Transactional Memory (TM): set of histories

– well-formed, prefix-closed

WTTM 2014

res res res res req req req req req req req

TM

g

Client Program

6

x:=0;y:=0;z:=0; result := abort; while(result == abort){ result := atomic{ x = X.read(); y = Y.read(); z = 42 / (x-y); Z.write(z); } } g := z;

slide-7
SLIDE 7

Trace Equivalence

Trace: includes also local and global actions Two traces are observationally equivalent  ~ ’ if threads have the same sequence of local values, except for local values inside aborted transactions

WTTM 2014

val:=9 g:=7 val:=8 val:=3

TMC observationally refines TMA if every trace  with history in TMC has a trace ’ ~  with history in TMA

7

slide-8
SLIDE 8

Why Observational Refinement?

Prove properties for TMA and deduce the same for TMC

WTTM 2014

Traces with history in TMC Traces with history in TMA

 ’

~

TMC observationally refines TMA if every trace  with history in TMC has a trace ’ ~  with history in TMA

8

slide-9
SLIDE 9

T1

TMS: By Example

WTTM 2014

T4 T5 T3

T2

C A C A

g’==1 g’:=1 g:=1 g==1

  • transaction of  is included
  • some visible transactions are included
  • for every included transaction, exactly all past

committed transactions are included

9

slide-10
SLIDE 10

T1

TMS: By Example

WTTM 2014

T4 T5 T3

T2

C A C A

g’==1 g’:=1 g:=1 g==1

C

  • Commit included aborted transactions (by replacing

abort with commit)

  • Commit included commit-pending transactions
  • Remove all other transactions

10

slide-11
SLIDE 11

TMS: The Past of an Action 

H’  TMSPast(H1)

  • H’ is a subsequence of H
  • H’ contains transaction of  and some visible transactions in H
  • for every included transaction T in H’, exactly all past committed

transactions are included Hc  cTMSPast(H1)

  • commit all commit-pending transactions
  • replace aborted actions by committed actions

WTTM 2014

H1

history  TMC

HC

HCcTMSPast(H1)

H’

H’TMSPast(H1)

11

slide-12
SLIDE 12

Definition of TMS

HC ⊑ S

  • S preserves the per-thread and real-time order of HC

H ⊑ 𝐮𝐧𝐭 TMA

  • all committed transactions have a serialization
  • for every response action , there is a complete past Hc and

a history S TMA such that Hc ⊑ S

WTTM 2014

H1

history  TMC

S

history  TMA

⊑ HC

HCcTMSPast(H1)

H’

H’TMSPast(H1)

TMC is TMS ≜ for every HTMC , H ⊑ tms TMATOMIC

12

slide-13
SLIDE 13

Main Result

  • no nesting of atomic blocks
  • no access to global variables in atomic blocks

WTTM 2014

TMC ⊑tms TMA  TMC observationally refines TMA

13

slide-14
SLIDE 14

Every trace  observed when running with TMC has an equivalent trace ’ observed when running with TMA

  • Consider a trace  whose history H is in TMC
  • TMC ⊑ tmsTMA  HC  cTMSPast(H) and HC ⊑ S  TMA
  • From  and S, get a trace ’ ~  of TMA whose history is S

⊑ 𝐮𝐧𝐭 is Sufficient

WTTM 2014

trace

H

history  TMC

S

history  TMA

⊑ ~ ’

trace

HC

HC  cTMSPast(H) HC = history(c)

c~ ’ [AGHR13] c~ 

14

slide-15
SLIDE 15

WTTM 2014

T1 T4 T5 T3

T2

C A C A

g’==1 g’:=1 g:=1

  • Let X be the beginning of the last included transaction
  • For every thread t, take the trace until the latest of:
  • The last non-transactional action before X
  • The last transactional action of t in H’

g==1

Constructing c ~ 

15

X

slide-16
SLIDE 16

What’s Next?

  • Extend the results to handle nesting and access

to global variables in atomic blocks

  • Weaker observations are preserved by VWC?
  • Stronger observations (e.g., global accesses in

a transaction) are preserved by deferred update opacity or TMS2?

WTTM 2014 16