Deuce STM Painless Java concurrency - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Deuce STM Painless Java concurrency

Description:

Atomicity all or nothing. Consistency consistent state (after ... Torvald Riegel, Pascal Felber and Christof Fetzer [DISC 2006] ETL - Encounter-time locking ... – PowerPoint PPT presentation

Number of Views:165
Avg rating:3.0/5.0
Slides: 35
Provided by: grid5
Category:

less

Transcript and Presenter's Notes

Title: Deuce STM Painless Java concurrency


1
Deuce STM Painless Java concurrency
  • Guy Korland
  • TAU GigaSpaces

2
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

3
Motivation
4
Moores Law
Transistor count still rising
Clock speed flattening sharply
(hat tip Simon Peyton-Jones)
5
The Problem
  • Cannot exploit cheap threads
  • Todays Software
  • Non-scalable methodologies
  • Todays Hardware
  • Poor support for scalable synchronization

6
Why Locking Doesnt Scale?
  • Not Robust
  • Relies on conventions
  • Hard to Use
  • Conservative
  • Deadlocks
  • Lost wake-ups
  • Not Composable

7
The Brief History of STM
8
TM Overview
  • synchronized
  • ltsequence of instructionsgt
  • atomic
  • ltsequence of instructionsgt

9
What is a transaction?
  • Atomicity all or nothing
  • Consistency consistent state (after before)
  • Isolation Other cant see intermediate.
  • Durability - persistent

10
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

11
Deuce
  • Java STM framework
  • _at_Atomic methods
  • Field based access
  • More scalable than Object bases.
  • More efficient than word based.
  • Support external libraries
  • Can be part of a transaction
  • No reserved words
  • No need for new compilers (Existing IDEs can be
    used)
  • Research tool
  • API for developing and testing new algorithms.

12
Deuce - API
  • public class Bank
  • final private static double MAXIMUM_TRANSACTION
    1000
  • private double commission 0
  • _at_Atomic(retries64)
  • public void transaction( Account ac1, Account
    ac2, double amount)
  • if( amount lt 0 amount gt MAXIMUM_TRANSACTION
    )
  • throw new IllegalArgumentException(Illega
    l transaction)
  • ac1.balance - (amount commission)
  • ac2.balance amount
  • _at_Atomic
  • public void update( double value)
  • commission value

13
Deuce - Overview
14
Deuce - Running
  • javaagentdeuceAgent.jar
  • Dynamic bytecode manipulation.
  • -Xbootclasspath/prt.jar
  • Offline instrumentation to support boot
    classloader.
  • -Dorg.deuce.excludeorg.junit.,org.eclipse.
  • Exclude class from being instrumented.
  • _at_Exclude
  • java javaagentdeuceAgent.jar cp
    ex.jarmyjar.jar MyMain

15
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

16
Implementation
  • ASM Bytecode manipulation
  • Online Offline
  • Fields
  • private double commission
  • final static public long commission__ADDRESS...
  • Relative address (-1 if final).
  • final static public Object __CLASS_BASE__ ...
  • Mark the class base for static fields access.

17
Implementation
  • Method
  • _at_Atomic methods.
  • Replace the with a transaction retry loop.
  • Add another instrumented method.
  • Non-Atomic methods
  • Duplicate each with an instrumented version.

18
Implementation
_at_Atomic public void update ( double value)
commission value
_at_Atomic public void update ( double value)
double tmp commission commission tmp
value
19
Implementation
public void update( double value, Context c)
double tmp if( commission__ADDRESS lt 0 ) //
final field tmp commission else
c.beforeRead( this, commission__ADDRESS)
tmp c.onRead( this, commission,
commission__ADDRESS) if(
commission__ADDRESS lt 0 ) // final field
commission tmp value else
c.onWrite( this, tmp value, commission__ADDRESS)

20
Implementation
public void update( double value) Context
context ContextDelegetor.getContext() for(
int i retries i gt 0 --i)
context.init() try update(
value, context) if(
context.commit()) return
catch ( TransactionException e )
context.rollback() continue
catch ( Throwable t ) if(
context.commit()) throw t
throw new TransactionException()
21
Implementation
public interface Context void init ( int
atomicBlockId) boolean commit() void
rollback () void beforeReadAccess( Object
obj , long field ) Object onReadAccess(
Object obj, Object value , long field ) int
onReadAccess( Object obj, int value , long field
) long onReadAccess( Object obj, long value ,
long field ) void onWriteAccess( Object
obj , Object value , long field ) void
onWriteAccess( Object obj , int value , long
field ) void onWriteAccess( Object obj , long
value , long field )
22
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

23
TL2 (Transaction Locking II)Dave Dice, Ori
Shalev and Nir Shavit DISC 2006
  • CTL - Commit-time locking
  • Start
  • Sample global version-clock
  • Run through a speculative execution
  • Collect write-set read-set
  • End
  • Lock the write-set
  • Increment global version-clock
  • Validate the read-set
  • Commit and release the locks

24
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

25
LSA (Lazy Snapshot Algorithm)Torvald Riegel,
Pascal Felber and Christof Fetzer DISC 2006
  • ETL - Encounter-time locking
  • Start
  • Sample global version-clock
  • Run through a speculative execution
  • Lock on write access
  • Collect read-set write-set
  • End
  • Increment global version-clock
  • Validate the read-set
  • Commit and release the locks

26
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

27
Benchmarks (Azul Vega2 2 x 46)
28
Benchmarks (SuperMicro 2 x Quad Intel)
29
Benchmarks (Sun UltraSPARC T2 Plus 2 x Quad
x 8HT)
30
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

31
Summary
  • Simple API
  • _at_Atomic
  • No change to Java
  • No reserved word
  • OpenSource
  • On Google code
  • Shows nice scalabilty
  • Field based

32
Outline
  • Motivation
  • Deuce
  • Implementation
  • TL2
  • LSA
  • Benchmarks
  • Summary
  • References

33
References
  • Homepage - http//sites.google.com/site/deucestm/
  • Project - http//code.google.com/p/deuce/
  • Wikipedia -http//en.wikipedia.org/wiki/Software_t
    ransactional_memory
  • TL2 http//research.sun.com/scalable/
  • LSA-STM - http//tmware.org/lsastm

34
Appendix
  • Can you just replace synchronized blocks with
    _at_Atomic blocks?
  • Privatization
  • wait() (Message passing)
Write a Comment
User Comments (0)
About PowerShow.com