Upload
guy-korland
View
1.364
Download
1
Embed Size (px)
DESCRIPTION
Citation preview
Quasi-Linearizability: relaxed consistency for improved
concurrency
Y. Afek, G. Korland, E. Yanovsky Tel-Aviv University
Motivation
• Linearizability Intuitive & clear
• BUT, requires strong synchronization
limited scalability
Motivation SEDA
• Highly concurrent server application
• Thread poolso A task queue and a set of consumer threads
Motivation SEDA cont.
• Typically, task queue is a linearizable queue
May become a contention point
Head Tail
Task TaskTask TaskTask
Task ProducersTask Consumers
Motivation Shared Counter
• Statistical Counter
• ID generator
Motivation HashTable
• Web Cache
Motivation Cont.
• What about Stack?• What about Tree?• What about Priority Queue?
The Solution
• Relax the linearizability requirement
• Back to the SEDA example…• Strict FIFO order is not a must
Replace FIFO with Loose-FIFO.
Example I
Eventual consistency
• Given a sufficiently long period of time over which no updates
are sent, we can expect
that during this period,
all updates will,
eventually, propagate
through the system and
all the replicas will be consistent.
Example II
Quiescent consistency
• Operations whose occurrence is
separated by a quiescent state
should appear in the order of their occurrence.
• An object is in a quiescent state if currently there is no pending or executing operation on that object.
The Solution cont.
• Relax the linearizability requirement
• Back to the SEAD example…• Strict FIFO order is not a musto Replace FIFO with Loose-FIFO.
• “Quasi-FIFO”o When a task is executed, no more than K tasks
that were inserted prior to it, are pending execution.
Quasi FIFO Queue
– Random Dequeue
HeadTail
Task TaskTask Task Task
Algorithm idea:• do
• Pick a node at random from the first K nodes • dequeue its element if possible.
• If already dequeued, and the queue is not empty, repeat.
Task Task
kTask
Quasi FIFO Example
T1:
T2:
T3:
enq(x) enq(z)
enq(y)
deq(z) deq(y) deq(x)NOT LIN
EARIZABLE
enq(y)enq(x) enq(z) deq(z) deq(y) deq(x)
Not Legal Sequential history
enq(y)enq(x) enq(z) deq(z) deq(y) deq(x)
Legal Sequential history
QUASI LIN
EARIZABLE
Distance 2
Quasi Linearizable Definition
Parallel Histories
LegalSequentialHistories
Quasi Linearizable Definition
1 2 3 4 5 6
4 1 2 3 5 6
H’
H
Distance 3
Q-Quasi-Sequential
Quasi Linearizable Definition
Parallel Histories
LegalSequentialHistories
Segmented Queue– Segmented Quasi-Linearizable queue
• do• Pick a random element from corresponding segment • If empty-segment (Full-segment) remove it (Add new)
• repeat
Each segment size == K.
Appendix
Counting Network (Thanks to “Art of Multiprocessor Programming, Herlihy & Shavit”)
1
Counting Network
2
1
Counting Network
3
2
1
Counting Network
3
2
1
4
Counting Network
3
2
1
4
5
Counting Network
Bitonic[k] not Linearizable
Bitonic[W] is not Linearizable
Bitonic[W] is not Linearizable
2
Bitonic[W] is not Linearizable
2
0
Bitonic[W] is not Linearizable
2
0
Problem is:• Red finished before Yellow started• Red took 2• Yellow took 0
But it is “Quiescently Consistent”
Bitonic[W] Counting Network
Is it K-Quasi Linearizable Counter?
Yes, for K≥N*W (N-Num of threads)