transactions are back but are they the same? r. guerraoui, epfl
Post on 19-Dec-2015
221 views
TRANSCRIPT
![Page 1: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/1.jpg)
Transactions are backBut are they the same?
R. Guerraoui , EPFL
![Page 2: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/2.jpg)
- Le retour de Martin Guerre -
(Sommersby)
![Page 3: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/3.jpg)
![Page 4: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/4.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/5.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/6.jpg)
Forking threads is easy
Handling the conflicts is hard
![Page 7: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/7.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/8.jpg)
Double-ended queue
Enqueue Dequeue
![Page 9: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/9.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/10.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/11.jpg)
TransactionsCope with both concurrency and recovery control
![Page 12: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/12.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/13.jpg)
TransactionsConsistency Contract (ACID)
CA-I-D
![Page 14: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/14.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/15.jpg)
Simple example (consistency invariant) 0 < x < y
![Page 16: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/16.jpg)
T: x := x+1 ; y:= y+1
Simple example (transaction)
![Page 17: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/17.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/18.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/19.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/20.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/21.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/22.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/23.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/24.jpg)
Simple algorithm (DSTM)
Killer write (ownership)
Careful read (validation)
![Page 25: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/25.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/26.jpg)
Am I smarter than a system guy?
No way
![Page 27: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/27.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/28.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/29.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/30.jpg)
System people care about live transactions
Theoreticians didn’t
![Page 31: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/31.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/32.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/33.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/34.jpg)
Simple algorithm (DSTM)
Careful read (validation)
Killer write (ownership)
![Page 35: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/35.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/36.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/37.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/38.jpg)
Theorem (GK’06)
Visible read Vs Validation Vs (solo) Progress
![Page 39: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/39.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/40.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/41.jpg)
Many more issues
Progress? Real-time?Performance? Hardware support? Linguistic support?
![Page 42: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/42.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/43.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/44.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/45.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/46.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/47.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/48.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/49.jpg)
Many more issues
Progress? Real-time?Performance? Hardware support? Linguistic support?
![Page 50: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/50.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/51.jpg)
Benchmarks
STMBench7 (GKV’06)
Dividing STMs by zero
![Page 52: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/52.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/53.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/54.jpg)
![Page 55: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/55.jpg)
![Page 56: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/56.jpg)
![Page 57: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/57.jpg)
![Page 58: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/58.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/59.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/60.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/61.jpg)
User 1 User 2
Transaction Server
Classical database transactions
Database (disk)
![Page 62: Transactions are back But are they the same? R. Guerraoui, EPFL](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/62.jpg)
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](https://reader030.vdocuments.net/reader030/viewer/2022032800/56649d2b5503460f94a0133f/html5/thumbnails/63.jpg)
Thread 4Thread 3Thread 2
Processor 3Processor 2Processor 1
Transactional language: shared memory
Thread 1
Shared memory transactions