Checkpoints and Continuations instead of Nested Transactions Eric - - PowerPoint PPT Presentation

checkpoints and continuations
SMART_READER_LITE
LIVE PREVIEW

Checkpoints and Continuations instead of Nested Transactions Eric - - PowerPoint PPT Presentation

Checkpoints and Continuations instead of Nested Transactions Eric Koskinen Brown University Joint work with Maurice Herlihy Brown University Partial Aborts Early TMs aborted entire transactions Useful to partially abort Performance:


slide-1
SLIDE 1

Checkpoints and Continuations

instead of

Nested Transactions

Eric Koskinen

Brown University

Joint work with

Maurice Herlihy

Brown University

slide-2
SLIDE 2

Partial Aborts

Early TMs aborted entire transactions Useful to partially abort Performance: resolve conflict, without unnecessary rollback Semantic constructs: conditional and or- else synchronization, priority

slide-3
SLIDE 3

But what about Nesting?

TM literature is a nest of nested txns Claim that nesting gives you partial aborts Let’ s take a closer look ...

slide-4
SLIDE 4

Example 1

atomic { Object x = swap(htA, key, y); HashTable.Insert(htB, key, x); } Object swap(HashTable ht, int key , Object newVal) { atomic { Object r = HashTable Remove(ht,key); HashTable Insert ( ht , key , newVal); return r ; } }

Nesting for Modularity!

slide-5
SLIDE 5

Example 2

global int list[10]; atomic { int x = list[0]; list[1] = x + 1; atomic { list[2] = x + 3; } ... }

Defend against abort!

Conflict!

slide-6
SLIDE 6

Two Reasons for Nesting

  • 1. Code Modularity (sub-routines)

2.Defend against aborts (emulate partial abort)

slide-7
SLIDE 7

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 popping records

If you have a mechanism for partial aborts, nesting is unneeded

slide-8
SLIDE 8

The Key Idea

Partial Aborts . . . without nested transactions Simpler syntax: new keyword checkpoint Place a checkpoint anywhere in a transaction Don’ t have to make everything “nested” Fine-grained rollback Simpler implementation (no r/w act. records)

slide-9
SLIDE 9

Syntax

Example

atomic { int x = list[0]; list[1] = x + 1; atomic { list[2] = x + 3; ... } }

Example

void foo() { atomic { ... } } atomic { foo(); }

Checkpoints in useful locations Doesn’ t have to be nested Example

void foo() { if(_txn) { checkpoint; ... } else atomic { ... } } atomic { foo(); }

Example

atomic { int x = list[0]; list[1] = x + 1; checkpoint; list[2] = x + 3; ... }

slide-10
SLIDE 10

capture continuations mark in the log

Mechanism

To return to a checkpoint, we must: Save/restore program counter Save/restore stack Save/restore thread-local heap Save/restore shared heap

slide-11
SLIDE 11

Mechanism

read(list[0]) write(list[1]) write(list[2]) read(list[9]) ◆ read(list[0]) write(list[1]) ◆ write(list[2]) read(list[9]) ... ◆ ctx0 read(list[0]) write(list[1]) ◆ ctx1 write(list[2]) read(list[9]) ...

ctxi = 〈pcA,sA,hA〉

Thread A

partial full abort

Example

atomic { int x = list[0]; list[1] = x + 1; checkpoint; list[2] = x + 3; int y = list[9]; ... }

slide-12
SLIDE 12

Continuations

Most languages have facilities to capture PC and stack We implemented a simple facility to save/restore any thread-local heap data Prototype implementation is in C Could also work in Java

slide-13
SLIDE 13

Conclusion A

Partially abort a transaction No nesting needed Next: Applications. But first, what’ s boosting?

slide-14
SLIDE 14

Txn’l Boosting (PPoPP’08)

w

x

y z

Thread A

global ConcurrentSet l; atomic { AbstactLock(3); if(l.insert(3)) LogInverse(l.remove(3)); checkpoint; AbstactLock(7); if(l.remove(7)) LogInverse(l.add(7)); }

Concurrent Data Structure

  • Safe alternative to Open Nesting
  • No read/write sets,
  • Synchronize with abstract locks,
  • recovery via inverses
slide-15
SLIDE 15

◆ ctx0 lock(w) foo-1(w) ◆ ctx1 lock(x) bar-1(x) ... ◆ ctx0 read(list[0]) write(list[1]) ◆ ctx1 write(list[2]) read(list[9]) ...

Boosting

w

x

y z

Thread

Boosting Log

Thread

Traditional Log

slide-16
SLIDE 16

Conditional Sync.

retry

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

slide-17
SLIDE 17
  • rElse

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

  • rElse

{ with(alC.lock(key)) { Remove(htC, key); } with(alC.lock(key)) { Add(htC, key, result); } } }

Conditional Sync.

slide-18
SLIDE 18

Implementation

Base implementation is TL2 (in C) Added Boosting (PPoPP’08) Added support for Checkpoints setjmp and longjmp for capturing stack Priority experiment . . .

slide-19
SLIDE 19

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

slide-20
SLIDE 20

Application: Priority

w

x

y z

Concurrent Data Structure

HP Txn LP Txn

Conflict!

slide-21
SLIDE 21

Application: Priority

Simple benchmark, engineered to produce HP/LP contention

slide-22
SLIDE 22

Evaluation

vacation (flat) vacation (checkpoints) kmeans (flat) kmeans (checkpoints)

slide-23
SLIDE 23

Related Work

Moravan et al. Supporting Nested Transactional Memory in LogTM. ASPLOS-XII.

  • Harris. Abstract Nested Transactions. 2007

. Ni et al. Open Nesting in Software Transactional

  • Memory. PPoPP 2007

. This paper: Herlihy, Koskinen. Checkpoints and Continuations instead of Nested Transactions. Transact 2008.

slide-24
SLIDE 24

Conclusion B

Partially abort a transaction No nesting needed Applies to read/write TMs Applies to transactional boosting

slide-25
SLIDE 25

Thanks!

Questions?