authors eric koskinen maurice herlihy brown university presented by – nagashri setty
DESCRIPTION
Checkpoints and Continuations instead of Nested Transactions (SPAA’08). Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty. Overview. Pros and Cons - Nested transaction Transactional Boosting Mechanism for Partially aborting transactions Examples - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/1.jpg)
Authors
Eric KoskinenMaurice HerlihyBrown University
Presented by – Nagashri Setty
Checkpoints and Continuationsinstead ofNested Transactions (SPAA’08)
![Page 2: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/2.jpg)
Overview
Pros and Cons - Nested transaction Transactional Boosting Mechanism for Partially aborting
transactions Examples Conclusion
![Page 3: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/3.jpg)
Partial Aborts
Early TMs aborted entire transactions Useful to partially abort
Performance: resolve conflict, without unnecessary rollback
Semantic constructs: conditional and orelse synchronization, priority
![Page 4: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/4.jpg)
But what about Nesting?
TM literature is a nest of nested transactions
Claim that nesting gives you partial abort
Let’s take a closer look ...
![Page 5: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/5.jpg)
Example 1
Object swap(HashTable ht, int key , Object newVal) {atomic { Object r = HashTable Remove(ht,key); HashTable Insert ( ht , key , newVal); return r ;}
}
atomic { Object x = swap(htA, key, y); HashTable.Insert(htB, key, x);}
Nesting for Modularity!
![Page 6: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/6.jpg)
Example 2
global int list[10];atomic {
int x = list[0];list[1] = x + 1;atomic {
list[2] = x + 3;}
...}
Conflict ?
Defend against abort !
![Page 7: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/7.jpg)
Two Reasons for Nesting
Code Modularity (sub-routines) Defend against aborts (emulate partial
abort)
![Page 8: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/8.jpg)
The Problem
Nesting is too coarse-grained On abort, return to start of (a nested) txn To defend, must nest! Complex implementation : Layers of activation records
(read/write sets) Partial abort by poppIinfg y roeuc ohrdasve a
mechanism If you have a mechanism for partial aborts, nesting is unneeded
![Page 9: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/9.jpg)
Transactional Boosting (PPoPP’08)
Solve synchronization and recovery without tracking read/write sets and relying on data structure semantics.
Built upon Black box Linearizable base object.
Given Semantics – commutative methods and inverse methods Relies on commutativity to define and detect
conflicts. Recovery via inverses
Synchronize with abstract locks Safe alternative to Open Nesting
![Page 10: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/10.jpg)
Two methods X and Y are commutative, if • Response of X is independent from Y and vice
versa• The state of object O after applying X than Y is
equal to one after applying Y then X Method X-1 is inverse of X if object’s state after
applying X then X-1 is equal to state before X’s call
Definitions (Informal)
![Page 11: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/11.jpg)
Simple Example : A Set
![Page 12: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/12.jpg)
Outline
Ensure that only commutative methods may be called concurrently during transaction.
If no, to abort the transaction For every successful method call, to
push its inverse into transaction’s local stack
In case of abort, “rewind” inverses stack (in parallel with write set recovery)
![Page 13: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/13.jpg)
Transactions and objects interact with each other thru an abstract locks
Locks “on object semantic” rather then memory place
Prevents two non-commutative methods to be applied on object during transaction
If can not be acquired (timeout), aborts transaction
The transaction stores all acquired locks. Locks are released by commit or abort
Abstract locks
![Page 14: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/14.jpg)
Transactional Boosting
Concurrent Data Structure
![Page 15: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/15.jpg)
BoostingTraditional Log
◆ ctx0read(list[0])write(list[1])
◆ ctx1write(list[2])read(list[9])...
Thread
Boosting Log
◆ ctx0lock(w)foo-1(w)
◆ ctx1lock(x)bar-1(x)….
Threadw
Y
Z
X
![Page 16: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/16.jpg)
The Key Idea
Partial Aborts . . . without nested transactions Simpler syntax: new keyword checkpoint
Definition- A new program location where control may be
returned in the event of an abort. Place a checkpoint anywhere in a transaction
(atomic block) Don’t have to make everything “nested” Fine-grained rollback Simpler implementation (no r/w act. records)
![Page 17: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/17.jpg)
Syntax
Checkpoints in useful locations Doesn’t have to be nested
Example
atomic { ... if ( decision ()) checkpoint; DataStructureOperation(); ...}
Example
atomic { int x = list[0]; list[1] = x + 1; checkpoint; list[2] = x + 3; ...}
![Page 18: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/18.jpg)
Observations
Checkpoints are simpler no need to rewrite the block. nested equivalent would have added layers
of depth. semantically rich locations in the program’s
control flow graph. best suited to operationally meaningful
program locations rather than after each write operation.
![Page 19: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/19.jpg)
Mechanism
To return to a checkpoint, we must: Capture continuation
Save/restore program counter Save/restore stack Save/restore thread-local heap
Mark in the log Save/restore shared heap
Non local control flow is accomplished with two steps Continuation storage Continuation invocation
![Page 20: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/20.jpg)
Mechanism
atomic {int x = list[0];list[1] = x + 1;checkpoint;list[2] = x + 3;int y = list[9];...
}
Example
ctxi = (pc_A,s_A,h_A)
Thread A
Partial abort full
abort
![Page 21: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/21.jpg)
Continuations
Most languages have facilities to capture PC and stack
Prototype implementation built on TL2 which is written is in C
Could also work in Java getcontext and setcontext – capture the
continuation of multiple checkpoints. setjmp and longjmp for capturing single
point in the control flow(stack)
![Page 22: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/22.jpg)
Conclusion A
Partially abort a transaction No nesting needed
Next: Applications.
![Page 23: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/23.jpg)
Application: Priority
Preferred threads take priority How: “high” threads abort “low”
threads May harm low priority throughput Partially abort low priority threads
Roll back just far enough Let high priority threads commit
![Page 24: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/24.jpg)
Application: Priority
Concurrent Data Structure
![Page 25: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/25.jpg)
![Page 26: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/26.jpg)
Conditional Sync.
List inbound, outbound;AbstractLock inL, outL;Object in = NULL;
atomic {with(inL.lock()) { Prepare(inbound); }checkpoint;in = with(inL.lock()) { Dequeue(inbound); }if ( !in.isSpecial() )
retry;
with(outL.lock()) { Enqueue(outbound. in); }}
retry
![Page 27: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/27.jpg)
Conditional Sync.
HashTable htA, htB, htC;AbstractLock alA, alB, alC;atomic { Object result = with(alA.lock(key)) { Remove(htA, key);} checkpoint; { with(alB.lock(key)) { Remove(htB, key); } with(alB.lock(key)) { Add(htB, key, result); } } orElse{ with(alC.lock(key)) { Remove(htC, key); } with(alC.lock(key)) { Add(htC, key, result); } }}
orElse
![Page 28: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/28.jpg)
Implementation(checkpoint and continuation)
Implemented on top of Transactional Boosting implementation in TL2 [9].
Checkpoints are stored in a runtime computation log. At each checkpoint, the continuation is captured and
appended to the log. Checkpoints (“Context”) precede operations on shared data
structures, which involves acquiring an abstract lock (“Lck”), performing the operation, and then recording the inverse operation (“Inv”) in the log.
When a transaction is aborted, log is traversed in the reverse direction As a context is passed it is de-allocated inverses are invoked to revert data structure operations and abstract locks are released allowing other threads to acquire
them.
![Page 29: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/29.jpg)
Runtime Computation log
Diagram of the runtime computation log captured continuations (“Context”) abstract locks (“Lck”), and inverse methods (“Inv”).
Context Lck(56) Inv(…) Context Lck(56) Inv(…) Context Lck(56)
![Page 30: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/30.jpg)
Experiments
Modified STAMP benchmarks to use Boosting with and without checkpointing. vacation – A travel reservation system kmeans – A clustering technique
Ran on 8-way 2.0 GHz Xeon processor
![Page 31: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/31.jpg)
![Page 32: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/32.jpg)
Conclusion
Partially abort a transaction No nesting needed Applies to read/write TMs Applies to Transactional boosting
![Page 33: Authors Eric Koskinen Maurice Herlihy Brown University Presented by – Nagashri Setty](https://reader035.vdocuments.net/reader035/viewer/2022081603/56814724550346895db459d2/html5/thumbnails/33.jpg)
Questions????