Transactional Memory for Smalltalk
Upcoming SlideShare
Loading in...5
×
 

Transactional Memory for Smalltalk

on

  • 3,217 views

Concurrency control is mostly based on locks and is therefore notoriously difficult to use. Even though some programming languages provide high-level constructs, these add complexity and potentially ...

Concurrency control is mostly based on locks and is therefore notoriously difficult to use. Even though some programming languages provide high-level constructs, these add complexity and potentially hard-to-detect bugs to the application. Transactional memory is an attractive mechanism that does not have the drawbacks of locks, however the underlying implementation is often difficult to integrate into an existing language. In this paper we show how we have introduced transactional semantics into Smalltalk by using the reflective facilities of the language. Our approach is based on method annotations, incremental parse tree transformations and an optimistic commit protocol. The implementation does not depend on modifications to the virtual machine and therefor can be changed at the language level. We report on a practical case study, benchmarks and further and on-going work.

Statistics

Views

Total Views
3,217
Views on SlideShare
3,210
Embed Views
7

Actions

Likes
2
Downloads
31
Comments
0

4 Embeds 7

http://www.slideshare.net 3
http://www.linkedin.com 2
http://localhost:8080 1
http://static.slidesharecdn.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Transactional Memory for Smalltalk Transactional Memory for Smalltalk Presentation Transcript

    • Transactional Memory for Smalltalk Software Composition Group University of Bern Lukas Renggli Oscar Nierstrasz
    • Concurrent Programming in Smalltalk Semaphore forMutualExclusion RecursionLock new Mutex new SharedQueue new
    • Problems Deadlocks Starvation Priority Inversion Complexity
    • Software Transactional Memory
    • Programming with Transactions
    • Lock Based tree := BTree new. lock := Semaphore forMutualExclusion. quot; writing quot; lock critical: [ tree at: #a put: 1 ]. quot; reading quot; lock critical: [ tree at: #a ].
    • Transactional tree := BTree new. quot; writing quot; [ tree at: #a put: 1 ] atomic. quot; reading quot; tree at: #a.
    • Inside Transactions
    • Our Approach Full implementation in Smalltalk Lazy code transformation Method annotations Context dependent code execution
    • Static Model
    • Class name CompiledMethod superclass * selector 1 selector subclasses methods parseTree method instanceVariables AtomicMethod /selector 1 /parseTree atomicMethod
    • Code Transformation Instance Variables Variable Bindings Message Sends
    • Original Source Code BTree>>at: aKey put: anObject | leaf | leaf := root leafForKey: aKey. leaf insertKey: aKey value: anObject. root := leaf root. ^ anObject
    • Transformed Source Code BTree>>__atomic__at: aKey put: anObject | leaf | leaf := (self atomicInstVarAt: 1) __atomic__leafForKey: aKey. leaf __atomic__insertKey: aKey value: anObject. self atomicInstVarAt: 1 put: leaf __atomic__root. ^ anObject
    • Transformed Source Code BTree>>__atomic__at: aKey put: anObject | leaf | leaf := (self atomicInstVarAt: 1) __atomic__leafForKey: aKey. leaf __atomic__insertKey: aKey value: anObject. self atomicInstVarAt: 1 put: leaf __atomic__root. ^ anObject
    • Transformed Source Code BTree>>__atomic__at: aKey put: anObject | leaf | leaf := (self atomicInstVarAt: 1) __atomic__leafForKey: aKey. leaf __atomic__insertKey: aKey value: anObject. self atomicInstVarAt: 1 put: leaf __atomic__root. ^ anObject
    • Annotate methods that need special treatment Infrastructural code Exception handling Execution contexts Many primitives Variable sized objects
    • Dynamic Model
    • Transaction Change escapeContext 0..1 do: aBlock * Process apply currentTransaction retry: aBlock changes hasChanged checkpoint object hasConflict abort: anObject * ObjectChange CustomChange previousCopy applyBlock workingCopy conflictTestBlock
    • Validation
    • Speed Comparison Method Invocation 1× Special Method Invocation 2× Instance Variable Read 20× Instance Variable Write 19× Indexed Variable Read 18× Indexed Variable Write 17× 5× 10× 15× 20× 25×
    • Performance of n concurrent t [ms] 800.0 edit operations in Pier 700.0 1 CPU 600.0 500.0 400.0 2 CPUs 300.0 200.0 4 CPUs 100.0 8 CPUs 0.0 n 0 10 20 30 40 50 60 70 80 90 100 non-synchronized lock-based transactional
    • Future Work
    • Implement within a multi-core environment
    • Improve speed
    • Applications Concurrency Contol Source Code Loading Context Oriented Programming