Transactional Memory for Smalltalk

100 %
0 %
Information about Transactional Memory for Smalltalk

Published on January 28, 2008

Author: renggli

Source: slideshare.net

Description

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.

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

Add a comment

Related presentations

Related pages

Transactional memory for smalltalk - doi.acm.org

Concurrency control in Smalltalk is based on locks and is therefore notoriously difficult to use. Even though some implementations provide high-level ...
Read more

Transactional Memory for Smalltalk - researchgate.net

Transactional Memory for Smalltalk 3 { The implementation of transactional semantics in Smalltalk, using the re-ective capabilities of the language.
Read more

Transactional memory for Smalltalk (PDF Download Available)

Official Full-Text Publication: Transactional memory for Smalltalk on ResearchGate, the professional network for scientists.
Read more

CiteSeerX — Transactional memory for Smalltalk

scg.unibe.ch Abstract. Concurrency control in Smalltalk is based on locks and is therefore notoriously difficult to use. Even though some implementations ...
Read more

Software transactional memory - Wikipedia

In computer science, software transactional memory (STM) ... Smalltalk. GemStone/S A Transactional Memory Object Server for Smalltalk.
Read more

Figure 4 from Transactional memory for smalltalk ...

Concurrency control in Smalltalk is based on locks and is therefore notoriously difficult to use. Even though some implementations provide high-level ...
Read more

Transactional memory for smalltalk | DeepDyve

Read "Transactional memory for smalltalk" on DeepDyve - Instant access to the journals you need!
Read more

Transactional Memory for Smalltalk_文库下载

提供Transactional Memory for Smalltalk文档免费下载,摘要:scg.unibe.chAbstract ...
Read more

Transactional Memory in a Dynamic Language

Transactional Memory in a Dynamic Language? Lukas Renggli , Oscar Nierstrasz Software Composition Group University of Berne, Switzerland Abstract ...
Read more