Title: ComputerAssisted Construction of Efficient Concurrent Algorithms
1Computer-Assisted Construction of
Efficient Concurrent Algorithms
Martin Vechev, Eran Yahav, Maged Michael,
Hagit Attiya, Greta Yorsh
IBM T.J. Watson Research Center
Technion
2Construction Challenge Lets suppose
I want a concurrent set that is correct
efficient portable QUICKLY
2
3Now what
3
4The result
Harris (DISC01)
Heller et al. (OPODIS05)
Michael (PODC02)
Vechev Yahav (PLDI08)
4
5Another Domain Concurrent Garbage Collection
Yuasa 90
Steele(C) 75
Dijkstra(C) 78
FAMILY
Ben-Ari Base 84
Doligez(C) 93
Boehm 91
Azatchi 03
Ben-Ari Extended 84
Barabash 03
ALGORITHMS
Domani 03
Ben-Ari Base 84
Doligez 94
Pixley 88
PROOFS
THEOREM PROVING
6What if an assumption/requirement changes ?
- Examples
- Synchronization primitives are missing
- Automatic memory management is missing
- Allow obstruction-free instead of lock-free
- Effort is per-algorithm each time
- Construction
- Verification
CONSTRUCTION
VERIFICATION
Why verify this arbitrary algorithm ?!
6
7Awkward disconnected spaces
- Concurrent Data Structures
- Sets, Queues, Weak Queues
- Concurrent (and real-time, parallel) garbage
collection - (Java) Virtual machines and processor simulators
- Concurrent memory allocators
- Real-time OS kernels
8Core Challenges
- Commonalities
- Share construction and verification effort
across algorithms -
-
- Comparison
- Define formally what is better, more
efficient - Representation
- Expose dependencies
- Find Transformations
- Support assumption changes
9Commonalities Example Concurrent Sets
Sequential
Intermediate Algorithm
Published Algorithm
Priority Queue
Stack
DCAS
DCAS
CAS/DCAS
Trieber Stack
Vechev Yahav (PLDI08)
Michael (PODC02)
Heller et al. (OPODIS05)
9
10Commonalities Example One Instantiation
Implementations
Common Algorithm
bool remove(int key) Entry pred,curr,r
restart locate(pred,curr,key) k
(curr-gtkey ? key) if (k) return false
curr-gtmarked true r curr-gtnext atomic mp
?pred-gtmarked val(pred-gtnextcurr) ? mp
if (?val) goto restart pred-gtnext r return
true
CAS (if bit in pointer supported)
LOCKS and TRY-LOCKS
REENTRANT LOCKS and TRY-LOCKS
LOCKS
DCAS
10
11Commonalities Example Concurrent Sets
Sequential
Intermediate Algorithm
Published Algorithm
Share construction and verification effort across
algorithms
Priority Queue
Stack
DCAS
DCAS
CAS/DCAS
Trieber Stack
Vechev Yahav (PLDI08)
Michael (PODC02)
Heller et al. (OPODIS05)
11
12Comparison
Which algorithm is better ? What does
more concurrent mean ?
Harris (DISC01)
Heller et al. (OPODIS05)
Maged (PODC02)
Vechev Yahav (PLDI08)
13Comparison starting dimensions
- Problem is finding the right dimensions
Sequential
Concurrent
Space
Space
Synchronization
Time
Time
14Concurrent Sets Breaking atomicity
bool remove(int key) atomic Entry
pred,curr,r
locate(pred,curr,key) k
(curr-gtkey ? key) if (k) return false r
curr-gtnext pred-gtnext r return true
bool remove(int key) Entry pred,curr,r
restart locate(pred,curr,key) k
(curr-gtkey ? key) if (k) return false
curr-gtmarked true r curr-gtnext atomic mp
?pred-gtmarked val(pred-gtnextcurr)? mp if
(?val) goto restart pred-gtnext r return
true
15Concurrent Garbage Collectors Breaking atomicity
mutate(source, fld, new) old source.fld e
source.E_fld source.fld new s source.S_fld
if (s) val gc_state atomic if (val
TRACE) new.MC else new.MC max
val new.inLog if (!val) new.inLog
true atomic candnextcand new
atomic if (e) old.MC
mutate(source, field, new)
atomic old source.field w
source.field.WF w ? new.MC w ? log log U
new w ? old.MC-- source.fld new
16Comparison existing work
- Concurrent Garbage Collection (PLDI06)
- Precision formalizes expected intuition
- Tailored to a specific domain
- Linked List algorithms (Attiya Hillel,
DISC06) - A measure of locality
- Based on worst-case
- Concurrent GC, Data structures (PLDI07,
PLDI08) - Subset of traces simple and intuitive
- Many algorithms are incomparable (that should be)
17Central Problem Representation
bool remove(int key) Entry pred,curr,r
restart locate(pred,curr,key)
k (curr-gtkey ? key) if
(k) return false ltr,mgt curr-gtnext
lvalCAS(curr-gtnext, ?r,m?,?r,1?) if (?lval)
goto restart pvalCAS(pred-gtnext,
?curr,0?,?r,0?) if (?pval) goto restart return
true
18Representation Expressing an algorithm
- Gap between theory and practice
- Need to allow explicit description of concurrency
- Should capture commonalities
- Should enable concurrency transformations
18
19Summary Practical Systematic Construction
- Representation of Fundamental Algorithms
- Concurrent Garbage Collection, new algorithms
PLDI06 - Semi-Automated Reduction of Atomicity
- Concurrent Collectors, new algorithms PLDI07
- Concurrent Sets, new algorithms PLDI08
- Practically Beneficial
- Results were surprising even to algorithmic
experts - Explore space of algorithms, understand design
space - Expose commonalities and tradeoffs between
algorithms - Naturally leads to new algorithms
19