Conurrent Data Strutures Semantis and Quantitative Relaxations Mike Dodds Andreas Haas Tom Henzinger Andreas Holzer Christoph Kirsh Mihael Lippautz Hannes Payer Ali Sezgin Ana Sokolova University of York University of Salzburg IST Austria TU Vienna University of Salzburg University of Salzburg University of Salzburg IST Austria University of Salzburg FRIDA, VSL 23.7.2014
Semantis of sequential data strutures e.g. pools, queues, staks Sequential speifiation - set of legal sequenes Stak - legal sequene push(a)push(b)pop(b)
Semantis of onurrent data strutures Stak - legal sequene push(a)push(b)pop(b) Sequential speifiation - set of legal sequenes linearizable wrt seq.spe. Consisteny ondition - e.g. linearizability Stak - onurrent history begin-push(a)begin-push(b) end-push(a) end-push(b)begin-pop(b)end-pop(b) Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Consisteny onditions There exists a sequential witness that preserves preedene T1 1 push(a) 3 pop(b) There exists a sequential witness that preserves per-thread preedene sequential onsisteny linearizability T2 2 push(b) There exists a sequential witness that preserves preedene aross quies.state quiesent onsisteny T1 T2 2 push(b) 1 push(a) 3 pop(b) T1 T2 pop(b) push(a) 3 2 1 push(b)
Performane and salability :-))) throughput :-) :-( :- # threads/ores Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Relaxations allow Stak - inorret behavior push(a)push(b)push()pop(a)pop(b) Trading orretness for performane In a ontrolled way with quantitative bounds orret in a relaxed stak... 2-relaxed? 3-relaxed? measure the error from orret behavior
It is interesting Why relax? Provides potential for better performing onurrent implementations Stak k-relaxed stak top b thread 1 thread 2... thread n top k{ } b thread 1 thread 2... thread n a a
Relaxations of onurrent data strutures Quantitative relaxations Henzinger, Kirsh, Payer, Sezgin, S. POPL 2013 Sequential speifiation - set of legal sequenes Consisteny ondition - e.g. linearizability (Quantitative) relaxations Dodds, Sezgin, S. work in progress
Quantitative relaxations (sequential speifiation) What we have Framework for semanti relaxations Generi examples out-of-order / stuttering Conrete relaxation examples Effiient onurrent implementations staks, queues, priority queues,.. / CAS, shared ounter of relaxation instanes
Quantitative relaxations (sequential speifiation) The big piture S * semantis sequential speifiation legal sequenes - methods with arguments
Quantitative relaxations (sequential speifiation) The big piture Sk * S * semantis sequential speifiation legal sequenes relaxed semantis - methods with arguments
Quantitative relaxations (sequential speifiation) The big piture Sk * S *. k. semantis sequential speifiation legal sequenes relaxed semantis - methods with arguments distane? Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Quantitative relaxations (sequential speifiation) Challenge There are natural onrete relaxations... Stak Eah pop pops one of the (k+1)-youngest elements Eah push pushes... k-out-of-order relaxation
Quantitative relaxations (sequential speifiation) Challenge There are natural onrete relaxations... Stak Eah pop pops one of the (k+1)-youngest elements Eah push pushes... makes sense also for queues, priority queues,... k-out-of-order relaxation How is it refleted by a distane between sequenes? one distane for all?
Quantitative relaxations (sequential speifiation) Syntati distanes do not help push(a)[push(i)pop(i)] n push(b)[push(j)pop(j)] m pop(a) is a 1-out-of-order stak sequene top top top b b a...... a a its permutation distane is min(n,m)
Quantitative relaxations (sequential speifiation) Semanti distanes need a notion of state top state States are equivalene lasses of sequenes in S example: for stak push(a)push(b)pop(b)push() push(a)push() Two sequenes in S are equivalent if they have an indistinguishable future a x y u Ủ*. (xu S yu S)
Quantitative relaxations (sequential speifiation) Semantis goes operational S * is the sequential speifiation states labels initial state Stak LTS(S) = (S/,,, [ ] ) with top a push() top a transition relation m [s] [sm] sm S
Quantitative relaxations (sequential speifiation) The framework Start from LTS(S) Add transitions with transition osts Fix a path ost funtion Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Quantitative relaxations (sequential speifiation) The framework Start from LTS(S) - singleton Add transitions with transition osts Fix a path ost funtion Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Quantitative relaxations (sequential speifiation) The framework Start from LTS(S) Add transitions with transition osts Fix a path ost funtion Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Quantitative relaxations (sequential speifiation) The framework Start from LTS(S) Add transitions with transition osts Fix a path ost funtion Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Quantitative relaxations (sequential speifiation) The framework Start from LTS(S) Add transitions with transition osts Fix a path ost funtion distane - minimal ost on all paths labelled by the sequene Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Quantitative relaxations (sequential speifiation) Out-of-order stak Sequene of push s with no mathing pop Canonial representative of a state Add inorret transitions with segment-osts top b a pop(a) 2 top b Possible path ost funtions max, sum,... also more advaned Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Quantitative relaxations (sequential speifiation) Out-of-order queue Sequene of enq s with no mathing deq Canonial representative of a state Add inorret transitions with segment-osts head tail head a b deq() 2 tail a b Possible path ost funtions max, sum,... also more advaned Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Implementations and Performane
Relaxed implementations k-stak Henzinger, Kirsh, Payer, Sezgin, S. POPL 2013 Top Distributed queues / staks Haas, Henzinger, Kirsh, Lippautz, Payer, Sezgin, S. CF 2013 Top1 Top2 Top n
k-stak Performane and Salability omparison 80 -ore mahine 9000 8000 7000 operations/ms (more is better) 6000 5000 4000 3000 2000 1000 0 2 10 20 30 40 50 60 70 80 LS NS number of threads BAG ED RP k-stak (k=80) lok-free segment stak Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Distributed queues Performane and Salability omparison 80 -ore mahine 40000 35000 operations per ms (more is better) 30000 25000 20000 15000 10000 5000 0 2 10 20 30 40 50 60 70 80 LB MS FC WF RD (r=80) SQ (s=80) number of threads BS k-fifo (k=80) US k-fifo (k=80) ED BAG RP LRU DQ (p=80) 1-RR DQ (p=80) 2-RR DQ (p=80) TL-RR DQ (p=80) 1-RA DQ (p=80) 2-RA DQ (p=80) Ana Sokolova University of Salzburg FRIDA, VSL 23.7.2014
Linearizability revisited Bad performane also relaxes semantis T1 push(a) pop(?) may return a or b T2 push(a) push(b) The slower the implementation, the more nondeterminism T1 T2 push(b) pop(?) must return a Semantis vs. performae omparison (Con 2 Coli testing) Haas, Henzinger, Holzer, Kirsh, S. work in progress