crafting a ready-to-go stm
DESCRIPTION
Crafting a Ready-to-Go Java STMTRANSCRIPT
![Page 1: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/1.jpg)
Guy KorlandTel Aviv University
CRAFTINGA READY-TO-GO STM
![Page 2: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/2.jpg)
![Page 3: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/3.jpg)
![Page 4: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/4.jpg)
Process 1 Process 2
a = acc.get()a = a + 100 b = acc.get()
b = b + 50acc.set(b)
acc.set(a)
... Lost Update! ...
![Page 5: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/5.jpg)
Process 1 Process 2
lock(A) lock(B)
lock(B) lock(A)
... Deadlock! ...
![Page 6: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/6.jpg)
![Page 7: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/7.jpg)
Process 1 Process 2
atomic{ atomic{a = acc.get() b = acc.get()a = a + 100 b = b + 50 acc.set(a) acc.set(b)
} }
... WIIIII ...
![Page 8: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/8.jpg)
![Page 9: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/9.jpg)
@atomic public interface INode{
int getValue ();
void setValue (int value );
}
Factory<INode> factory = Thread.makeFactory(INode.class );
final INode node = factory.create();
factory result = Thread.doIt(new Callable<Boolean>() {
public Boolean call () {
return node.setValue(value);
} });
DSTM2MAURICE HERLIHY ET AL, A FLEXIBLE FRAMEWORK … [OOPSLA06]
![Page 10: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/10.jpg)
public class Account{
private VBox<Long> balance = new VBox<Long>();
public @Atomic void withdraw(long amount) {
balance.put (balance.get() - amount);
}
}
JVSTMJOÃO CACHOPO AND ANTÓNIO RITO-SILVA, VERSIONED BOXES AS THE BASIS FOR MEMORY TRANSACTIONS [SCOOL05]
![Page 11: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/11.jpg)
public class Bank{
private double commission = 10;
@Atomic
public void transaction( Account ac1, Account ac2, double amount){
ac1.balance -= (amount + commission);
ac2.balance += amount;
}
}
DEUCE STM - APIGuy Korland, Nir Shavit and Pascal Felber, “Noninvasive Java Concurrency with Deuce STM”, [MultiProg '10]
![Page 12: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/12.jpg)
DEUCE STM - OVERVIEW
![Page 13: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/13.jpg)
BENCHMARKS (SUN ULTRASPARC T2 PLUS – 2 X QUAD X 8HT)
![Page 14: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/14.jpg)
BENCHMARKS (AZUL – VEGA2 – 2 X 48)
![Page 15: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/15.jpg)
![Page 16: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/16.jpg)
![Page 17: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/17.jpg)
BENCHMARK - THE DARK SIDE
0
0.2
0.4
0.6
0.8
1
1.2
1 2 3 4 5 6 7 8 9 10
Lock
Deuce
![Page 18: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/18.jpg)
![Page 19: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/19.jpg)
• Contention – Retries, Aborts, Contention Manager …
• STM Algorithm – Data structures, optimistic, pessimistic…
• Semantic – Consistency model, Privatization…
• Instrumented Memory access – Linear overhead on every
read/write
OVERHEAD
![Page 20: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/20.jpg)
STATIC ANALYSIS OPTIMIZATIONS
1. Avoiding instrumentation of accesses to
immutable and transaction-local memory.
2. Avoiding lock acquisition and releases for
thread-local memory.
3. Avoiding readset population in
read-only transactions.
![Page 21: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/21.jpg)
NEW STATIC ANALYSIS OPTIMIZATIONS
1. Reduce amount of instrumented memory reads using
load elimination.
2. Reduce amount of instrumented memory writes using
scalar promotion.
3. Avoid writeset lookups for memory
not yet written to.
4. Avoid writeset record keeping for memory that
will not be read.
5. Reduce false conflicts by Transaction re-scoping.
6. …
Yehuda Afek, Guy Korland, and Arie Zilberstein, “Lowering STM Overhead with Static Analysis”, LCPC'10
![Page 22: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/22.jpg)
BENCHMARKS – K-MEANS
![Page 23: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/23.jpg)
STM FRIENDLY LIBRARIES
• Most of the developers/application only use Data Structures.
@Atomic(retries=64)
public void transaction( Map map1, Map map2, String key){
map2.put(key, map1.remove(key));
}
We should build a set of “STM Friendly” libraries.
Maurice Herlihy, Eric Koskinen: Transactional boosting: a methodology for highly-concurrent transactional objects. PPOPP’08
![Page 24: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/24.jpg)
![Page 25: Crafting a Ready-to-Go STM](https://reader035.vdocument.in/reader035/viewer/2022081603/559c1e5c1a28abce298b46b5/html5/thumbnails/25.jpg)
WWW.DEUCESTM.ORG