60
JVSTM and its applications João Cachopo @ Software Engineering Group

JVSTM and its applications

  • Upload
    nuncio

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

JVSTM and its applications. João Cachopo @ Software Engineering Group. J ava V ersioned S oftware T ransactional M emory. First developed in 2005. (web page not update since 2006). Outline. Original design of the JVSTM Recent changes to the JVSTM What we have been doing with it. - PowerPoint PPT Presentation

Citation preview

Page 1: JVSTM and its applications

JVSTMand its

applicationsJoão Cachopo @ Software Engineering Group

Page 2: JVSTM and its applications

Java Versioned Software Transactional Memory

Page 3: JVSTM and its applications

First developed in 2005

(web page not update since 2006)

Page 4: JVSTM and its applications

Outline

•Original design of the JVSTM•Recent changes to the JVSTM•What we have been doing with it

Page 5: JVSTM and its applications

First multi-version STM

Designed for very large transactionsand high read/write ratio

Page 6: JVSTM and its applications

The goal:ease of programming

(without incurring into too much overhead)

Page 7: JVSTM and its applications

It is not a transparent STM

Page 8: JVSTM and its applications

Versioned BoxesBbody:

previous:value: 2version: 13

previous:value: 1version: 8

previous: nullvalue: 0version: 4

VBox<T>

+ T get()+ put(T value)

Page 9: JVSTM and its applications

Versioned BoxesBbody:

previous:value: 2version: 13

previous:value: 1version: 8

previous: nullvalue: 0version: 4

GCed when no longer needed

Page 10: JVSTM and its applications

Versioned BoxesBbody:

previous: nullvalue: 2version: 13

Reading a box: - follow body - compare version - return value

- wait-free - no sync actions - no allocation

Page 11: JVSTM and its applications

No inconsistent reads(JVSTM ensures opacity)

Page 12: JVSTM and its applications

Read-only txs

•Begin Tx (lock-free)•Read boxes (wait-free)•Commit / abort Tx (lock-free)

Entire TX lock-free

Because

of GC

Page 13: JVSTM and its applications

Read-only transactionsnever conflict

(MV-permissiveness)

Page 14: JVSTM and its applications

Read-write txs

•Begin Tx (lock-free)•Read / write boxes (wait-free)•Abort Tx (lock-free)•Commit Tx (global lock)

Page 15: JVSTM and its applications

Lock-based commit

commit() { GLOBAL_LOCK.lock(); try {

} finally { GLOBAL_LOCK.unlock(); }}

Page 16: JVSTM and its applications

Lock-based commit

commit() { GLOBAL_LOCK.lock(); try { if (validate()) {

} } finally { GLOBAL_LOCK.unlock(); }}

Page 17: JVSTM and its applications

Lock-based commit

commit() { GLOBAL_LOCK.lock(); try { if (validate()) { int newTxNumber = globalCounter + 1; writeBack(newTxNumber); globalCounter = newTxNumber; } } finally { GLOBAL_LOCK.unlock(); }}

Page 18: JVSTM and its applications

Very simple design...

Page 19: JVSTM and its applications

Works really well in practice

Page 20: JVSTM and its applications

Lock-based commit

commit() { GLOBAL_LOCK.lock(); try {

} finally { GLOBAL_LOCK.unlock(); }}

If uncontended, this is quite fast!

Page 21: JVSTM and its applications

Good when few read-write txsor txs long enough so that

commits do not overlap often

Page 22: JVSTM and its applications

(machine with 196 physical cores)

Page 23: JVSTM and its applications

Lock-based commit

commit() { GLOBAL_LOCK.lock(); try { if (validate()) {

} } finally { GLOBAL_LOCK.unlock(); }}

We may do other things here...

Page 24: JVSTM and its applications

Delay computations untilcommit time, if they cause

many conflicts

Page 25: JVSTM and its applications

STMBench7

Page 26: JVSTM and its applications

STMBench7

Page 27: JVSTM and its applications

STMBench7

Page 28: JVSTM and its applications

What about small transactions?

Page 29: JVSTM and its applications

Read-write txs

•Begin Tx (lock-free)•Read / write boxes (wait-free)•Abort Tx (lock-free)•Commit Tx (global lock)

Can we make it better?

Page 30: JVSTM and its applications

Read-write txs

•Begin Tx (lock-free)•Read / write boxes (wait-free)•Abort Tx (wait-free)•Commit Tx (lock-free)

Page 31: JVSTM and its applications

JVSTM completely lock-free

Page 32: JVSTM and its applications

Lock-free isn’t that hard...

Page 33: JVSTM and its applications

Efficient and lock-free is!

Page 34: JVSTM and its applications
Page 35: JVSTM and its applications
Page 36: JVSTM and its applications

JVSTM still not optimizedfor tiny transactions

Page 37: JVSTM and its applications

We’re working on it•Eliminate memory allocation•Stealth transactions•Make beginTx wait-free•Optimize fast path of read/write•Versioned arrays•...

Page 38: JVSTM and its applications

JVSTM applications?

Page 39: JVSTM and its applications

More recently

•STM-based Thread Level Speculation

•Dynamic Software Updates•Automatic memoization of

functions with side-effects

Page 40: JVSTM and its applications

This led to•Transactional•collections (queues, maps, sets,

etc)•I/O streams

•Inevitable transactions•Exploring failure atomicity•...

Page 41: JVSTM and its applications

But it all started with theFénixEDU system

(> 1 million LOCs)

Page 42: JVSTM and its applications

First real-world application of STMs

Page 43: JVSTM and its applications

The Fénix Framework

Page 44: JVSTM and its applications

Simplify the development of applications with

a transactional and persistentrich domain model(AKA enterprise applications)

Page 45: JVSTM and its applications
Page 46: JVSTM and its applications
Page 47: JVSTM and its applications
Page 48: JVSTM and its applications
Page 49: JVSTM and its applications

Simpler programming model

Better performance*

Explores multicores

Page 50: JVSTM and its applications

Original JDBC-based (1000 items)

Page 51: JVSTM and its applications

FF-based (1000 items)

Page 52: JVSTM and its applications

Original JDBC-based (10000 items)

Page 53: JVSTM and its applications

FF-based (10000 items)

Page 54: JVSTM and its applications

Some Fénix statistics

Page 55: JVSTM and its applications

Normal week

Page 56: JVSTM and its applications

February 2010

Page 57: JVSTM and its applications

17th to 19th

No way we couldget this before

Page 58: JVSTM and its applications
Page 59: JVSTM and its applications

Reads Writes Conflicts

Normalday 898 802 15 330 9

17thFebruary 3 306 600 116 651 745

Page 60: JVSTM and its applications