+ All Categories
Home > Documents > Guy Korland Tel Aviv University CRAFTING A READY-TO-GO STM.

Guy Korland Tel Aviv University CRAFTING A READY-TO-GO STM.

Date post: 18-Dec-2015
Category:
Upload: jesse-lester
View: 214 times
Download: 0 times
Share this document with a friend
25
Guy Korland Tel Aviv University CRAFTING A READY-TO-GO STM
Transcript

Guy KorlandTel Aviv University

CRAFTING A READY-TO-GO STM

@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]

• Limited to Objects.

• Very intrusive.

• Doesn’t support libraries.

• Bad performance (fork).

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]

• Doesn’t support libraries.

• Less intrusive.

• Need to “Announce” shared fields

@TransactionalObject

public class Stack<E>{

private Node<E> head; @TransactionalMethod

public void push(E item) { head = new Node(item, head); } }

MULTIVERSEPETER VEENTJER, SINCE 2009

  public static class Node<E> {        private Ref<E> value;        final Node parent;

        Node(E value, Node prev) {            this.value = value;            this.parent = prev;        }    }

• Doesn’t support libraries.

• Need to “Announce” shared things.

• But, used commercially (AKKA).

public void update ( double value) {

Atomic {

commission += value;

}

}

ATOM-JAVAB. HINDMAN AND D. GROSSMAN. ATOMICITY VIA SOURCE-TOSOURCETRANSLATION. [MSPC06]

• Add a reserved word.

• Need pre-compilation.

• Doesn’t support libraries.

• Even Less intrusive.

• Annotation based --> @Atomic methods

• Field based access• More scalable than Object bases.• More efficient than word based.

• No reserved words• No need for new compilers (Existing IDEs can be used)

DEUCE STMGuy Korland, Nir Shavit and Pascal Felber, “Noninvasive Java Concurrency with Deuce STM”, [MultiProg '10]

• Supports external libraries• Can be part of a transaction

• Research tool• API for developing and testing new algorithms.

• Real life feedback.

DEUCE STM

public class Bank{ private double commission = 10;

@Atomic(retries=64)

public void transaction( Account ac1, Account ac2, double amount){ ac1.balance -= (amount + commission); ac2.balance += amount; } @Atomic

public void update( double value){ commission += value; }}

DEUCE STM - API

DEUCE STM - OVERVIEW

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 );…}

RESEARCH TOOL (CONTEXT- INTERFACE)

BENCHMARKS (SUPERMICRO – 2 X QUAD INTEL)

BENCHMARKS (SUN ULTRASPARC T2 PLUS – 2 X QUAD X 8HT)

BENCHMARKS (AZUL – VEGA2 – 2 X 48)

BENCHMARKS (SUN ULTRASPARC T2 PLUS – 2 X QUAD X 8HT)

BENCHMARK - THE DARK SIDE

1 2 3 4 5 6 7 8 9 100

0.2

0.4

0.6

0.8

1

1.2

LockDeuce

• 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

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.

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

1. LOAD ELIMINATION IN ATOMIC BLOCKS

• for (int j = 0; j < nfeatures; j++) {

newCenters[index][j] = newCenters[index][j] + feature[i][j];

}

• if (0 < nfeatures) {

nci = new_centers[index];

fi = feature[i];

for (j = 0; j < nfeatures; j++)

nci[j] = nci[j] + fi[j];

}

5 instrumented memory reads per loop iteration

2 instrumented memory reads per loop iteration

BENCHMARKS – K-MEANS

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

SUMMARY WWW.DEUCESTM.ORG


Recommended