63
Transactions are back But are they the same? R. Guerraoui , EPFL

Transactions are back But are they the same? R. Guerraoui, EPFL

  • View
    218

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Transactions are back But are they the same? R. Guerraoui, EPFL

Transactions are backBut are they the same?

R. Guerraoui , EPFL

Page 2: Transactions are back But are they the same? R. Guerraoui, EPFL

- Le retour de Martin Guerre -

(Sommersby)

Page 3: Transactions are back But are they the same? R. Guerraoui, EPFL
Page 4: Transactions are back But are they the same? R. Guerraoui, EPFL

From the New York TimesSan Francisco, May 7, 2004Intel announces a drastic change in its business strategy:« Multicore is THE way to boost performance »

Page 5: Transactions are back But are they the same? R. Guerraoui, EPFL

The free ride is over

Every one will need to fork threads

Page 6: Transactions are back But are they the same? R. Guerraoui, EPFL

Forking threads is easy

Handling the conflicts is hard

Page 7: Transactions are back But are they the same? R. Guerraoui, EPFL

Coarse grained locks => slow

Fine grained locks => errors(Most Java bugs are due to misuse of he word « synchronized »)

Page 8: Transactions are back But are they the same? R. Guerraoui, EPFL

Double-ended queue

Enqueue Dequeue

Page 9: Transactions are back But are they the same? R. Guerraoui, EPFL

Lock-free computing?

Every lock-free data structure # podc/disc/spaa papers

Page 10: Transactions are back But are they the same? R. Guerraoui, EPFL

A concurrency control abstraction that is:

Simple to use Efficient to implement

Page 11: Transactions are back But are they the same? R. Guerraoui, EPFL

TransactionsCope with both concurrency and recovery control

Page 12: Transactions are back But are they the same? R. Guerraoui, EPFL

accessing object 1; accessing object 2;

Back to the undergraduate level

Begin {

end }

Page 13: Transactions are back But are they the same? R. Guerraoui, EPFL

TransactionsConsistency Contract (ACID)

CA-I-D

Page 14: Transactions are back But are they the same? R. Guerraoui, EPFL

Historical perspective

Eswaran et al (CACM’76) Database Papadimitriou (JACM’79) Theory Liskov/Sheifler (TOPLAS’82) Language Knight (ICFP’86) Architecture Herlihy/Moss (ISCA’93) Hardware Shavit/Touitou (PODC’95) Software

Page 15: Transactions are back But are they the same? R. Guerraoui, EPFL

Simple example (consistency invariant) 0 < x < y

Page 16: Transactions are back But are they the same? R. Guerraoui, EPFL

T: x := x+1 ; y:= y+1

Simple example (transaction)

Page 17: Transactions are back But are they the same? R. Guerraoui, EPFL

You: « atomicity » (AID) Grand’ma: « consistency » ( C)

Consistency Contract

CA-I-D

Page 18: Transactions are back But are they the same? R. Guerraoui, EPFL

A history is atomic if itsrestriction to committed transactions is serializable

The underlying theory (P’79)

Page 19: Transactions are back But are they the same? R. Guerraoui, EPFL

A history H of committed transactions is serializable if there is a history S(H) that is (1) equivalent to H(2) sequential (3) legal

Page 20: Transactions are back But are they the same? R. Guerraoui, EPFL

This is all fine

But this is not new Why should we care?

Because we want jobs

Page 21: Transactions are back But are they the same? R. Guerraoui, EPFL

Transactions are indeed back

But are they really the same? How can we figure that out?

Page 22: Transactions are back But are they the same? R. Guerraoui, EPFL

Ask system people

System people know

« Those who know don’t need to think » Iggy Pop

Page 23: Transactions are back But are they the same? R. Guerraoui, EPFL

Simple algorithm (DSTM)

To write an object O, a transaction acquires O and aborts “the” transaction that owns O

To read an object, a transaction T takes a snapshot to see if the system hasn’t changed since T’s last reads; else T is aborted

Page 24: Transactions are back But are they the same? R. Guerraoui, EPFL

Simple algorithm (DSTM)

Killer write (ownership)

Careful read (validation)

Page 25: Transactions are back But are they the same? R. Guerraoui, EPFL

More efficient algorithm

Apologizing versus asking permission

Killer writeOptimistic read: validity check at commit time

Page 26: Transactions are back But are they the same? R. Guerraoui, EPFL

Am I smarter than a system guy?

No way

Page 27: Transactions are back But are they the same? R. Guerraoui, EPFL

Back to the example

Invariant: 0 < x < yInitially: x := 1; y := 2

Page 28: Transactions are back But are they the same? R. Guerraoui, EPFL

Division by zero

T1: x := x+1 ; y:= y+1

T2: z := 1 / (y - x)

Page 29: Transactions are back But are they the same? R. Guerraoui, EPFL

T1: x := 3; y:= 6

Infinite loop

T2: a := y; b:= x; repeat b:= b + 1 until a = b

Page 30: Transactions are back But are they the same? R. Guerraoui, EPFL

System people care about live transactions

Theoreticians didn’t

Page 31: Transactions are back But are they the same? R. Guerraoui, EPFL

We need a theory that talks about ALL transactions

The old theoryA history is atomic if its restriction to committed transactions is serializable

Page 32: Transactions are back But are they the same? R. Guerraoui, EPFL

A history H is opaque if for every transaction T in H, there is a serializable history in committed(T,H)

A new theory: Opacity (KG’06)

Page 33: Transactions are back But are they the same? R. Guerraoui, EPFL

A new theory is nice but is it useful?

Check with system people

Page 34: Transactions are back But are they the same? R. Guerraoui, EPFL

Simple algorithm (DSTM)

Careful read (validation)

Killer write (ownership)

Page 35: Transactions are back But are they the same? R. Guerraoui, EPFL

Visible vs Invisible Read

(SXM; RSTM)

Write is mega killer: to write an object, a transaction aborts any live one which has read or written the object

Visible but not so careful read: when a transaction reads an object, it says so

Page 36: Transactions are back But are they the same? R. Guerraoui, EPFL

ConjectureEither the read has to be visible or has to be careful

Wrong

Page 37: Transactions are back But are they the same? R. Guerraoui, EPFL

Giving up Progress (TL2)

To write an object, a transaction acquires it and writes its timestamp

To read an object, the transaction aborts itself if the object was written by a transaction with a higher timestamp

Page 38: Transactions are back But are they the same? R. Guerraoui, EPFL

Theorem (GK’06)

Visible read Vs Validation Vs (solo) Progress

Page 39: Transactions are back But are they the same? R. Guerraoui, EPFL

The theorem does not hold for classical atomicity

i.e., the theorem does not hold for database transactions

Page 40: Transactions are back But are they the same? R. Guerraoui, EPFL

Solo progress cannot be ensured with disjoint access parallelism

Solo progress cannot be ensured with transparent reads

More theorems (GK’07)

Page 41: Transactions are back But are they the same? R. Guerraoui, EPFL

Many more issues

Progress? Real-time?Performance? Hardware support? Linguistic support?

Page 42: Transactions are back But are they the same? R. Guerraoui, EPFL

With solo progress, some transactions might never commit

Can we ensure that all transactions eventually commit?

Progress

Page 43: Transactions are back But are they the same? R. Guerraoui, EPFL

Theorem (GKK06): Solo progress and eventual global progress are incompatible

When exactly can we ensure eventual global progress (resp. solo progress)?

Page 44: Transactions are back But are they the same? R. Guerraoui, EPFL

If a transaction T wants to write an object O owned by another transaction, it calls a contention manager

Various contention management strategies are possible

Progress/Real-Time

Page 45: Transactions are back But are they the same? R. Guerraoui, EPFL

System Perspective

Scherer and Scott [CSJP 04] Exponential backoff“Karma”

Transaction with most work accomplished wins

Various priority inheritance schemes …

Some work well, but …Can’t prove anything!

Page 46: Transactions are back But are they the same? R. Guerraoui, EPFL

Greedy Contention Manager (GHP’05)

StatePriority (based on start time)Waiting flag (set while waiting)

Wait if other hasHigher priority AND not waiting

Abort other iflower priority OR waiting

Page 47: Transactions are back But are they the same? R. Guerraoui, EPFL

Preliminary Result

Compare time to complete transaction schedule forIdeal off-line scheduler

Knows transactions, conflicts, and start times in advance

Greedy contention managerDoes not know anything …

Page 48: Transactions are back But are they the same? R. Guerraoui, EPFL

Competitive Ratio

Let s be the number of objects accessed by all transactionsCompare time to commit all transactionsGreedy is O(s)-competitive with the off-line adversaryGHP’05 O(s2)AEST’06 O(s)

Page 49: Transactions are back But are they the same? R. Guerraoui, EPFL

Many more issues

Progress? Real-time?Performance? Hardware support? Linguistic support?

Page 50: Transactions are back But are they the same? R. Guerraoui, EPFL

Performance

How to evaluate transactional memory implementations?

So far, mainly micro-benchmarks (linked lists, red-black trees)

Page 51: Transactions are back But are they the same? R. Guerraoui, EPFL

Benchmarks

STMBench7 (GKV’06)

Dividing STMs by zero

Page 52: Transactions are back But are they the same? R. Guerraoui, EPFL

http://www.cs.wisc.edu/trans-memory/biblio/index.html

Sun, Intel, IBM, EU (VELOX)ISCA, OOPSLA, PODC, DISC, POPL, PPoPP, Transact

What about SRDS?

The Topic is VERY HOT

Page 53: Transactions are back But are they the same? R. Guerraoui, EPFL

Transactions are conquering the parallel programming world

They look simple and familiar and thus make the

programmer happyTheir implementation is in fact

very tricky and that should make YOU happy

The one slide to remember

Page 54: Transactions are back But are they the same? R. Guerraoui, EPFL
Page 55: Transactions are back But are they the same? R. Guerraoui, EPFL
Page 56: Transactions are back But are they the same? R. Guerraoui, EPFL
Page 57: Transactions are back But are they the same? R. Guerraoui, EPFL
Page 58: Transactions are back But are they the same? R. Guerraoui, EPFL

Real-timeT1: y := x; commit

T2: x := x+1; commit

T3: y := y+1; commit

Page 59: Transactions are back But are they the same? R. Guerraoui, EPFL

Real-time

X

Y

commit

T1 (read(x))

T1 (write(y))

T2 (read-write(x))

commit

T2 (read-write(y))

Page 60: Transactions are back But are they the same? R. Guerraoui, EPFL

Recoverability is not enough

commit

T1 (read(x))

T1 (write(y))

T2 (read-write(x))

commit

T2 (read-write(y))

Page 61: Transactions are back But are they the same? R. Guerraoui, EPFL

User 1 User 2

Transaction Server

Classical database transactions

Database (disk)

Page 62: Transactions are back But are they the same? R. Guerraoui, EPFL

User 1 User 2

Transaction server + database

In-memory transactions

Fast processor

Page 63: Transactions are back But are they the same? R. Guerraoui, EPFL

Thread 4Thread 3Thread 2

Processor 3Processor 2Processor 1

Transactional language: shared memory

Thread 1

Shared memory transactions