a simple abstraction for complex concurrent indexes
DESCRIPTION
A Simple Abstraction for Complex Concurrent Indexes. OOPSLA 2011. Imperial College London : Pedro da Rocha Pinto , Thomas Dinsdale-Young , Philippa Gardner and Mark Wheelhouse University of Cambridge: Mike Dodds. Motivation. Indexes are ubiquitous in computing systems: - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/1.jpg)
A Simple Abstraction for Complex Concurrent Indexes
Imperial College London:Pedro da Rocha Pinto, Thomas Dinsdale-Young, Philippa Gardner and Mark Wheelhouse
University of Cambridge:Mike Dodds
OOPSLA 2011
![Page 2: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/2.jpg)
Motivation
Indexes are ubiquitous in computing systems:
And have a variety of implementations:
File systemsDatabases Caches
JavaScript Objects
Linked ListsHash Tables
Arrays
B-trees
![Page 3: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/3.jpg)
Intuitive Index Specification
An index is a partial function mapping keys to values:
There are three basic operations on an index :
r search(h,k)
insert(h,k,v)
remove(h,k)
𝐻 :𝐾𝑒𝑦𝑠⇀𝑉𝑎𝑙𝑠
![Page 4: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/4.jpg)
Simple Concurrent Example
This intuitive specification is not enough to reason about concurrent access to the index.
e.g
r search(h,k);insert(h,k1,r) || remove(h,k2)
with k1 k2
![Page 5: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/5.jpg)
Disjoint Key Concurrency
Concurrent Abstract Predicates:
: there is a mapping in the index from to , and only the thread holding the predicate can modify .
: there is no mapping in the index from , and only the thread holding the predicate can modify .
Axioms:
e.g.
![Page 6: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/6.jpg)
Concurrent Index Specification
r search(h,k)
r search(h,k)
insert(h,k,v)
insert(h,k,v)
remove(h,k)
remove(h,k)
![Page 7: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/7.jpg)
Simple Concurrent Example
r search(h,k);
insert(h,k1,r) remove(h,k2)
{𝑖𝑛 (h ,𝑘1 ,𝑣 )∗𝑜𝑢𝑡 (h ,𝑘2 )}
![Page 8: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/8.jpg)
More Example Programs
However, we still cannot reason about the following programs:
remove(h,k) || remove(h,k)
insert(h,k,v) || remove(h,k)
r search(h,k) || remove(h,k)
We need to account for the sharing of keys between threads.
![Page 9: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/9.jpg)
Real-World Client ProgramsDatabase sanitation:
remove all patients who have been cured, transferred or released
Graphics drawing: clip all objects outside of some horizontal and vertical bounds
Garbage collection: parallel marking in the mark/sweep algorithm
Web caching (NOSQL): removing a picture whilst others are attaching comments to it
![Page 10: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/10.jpg)
Shared Key Concurrency
Extended Concurrent Abstract Predicates: with
• : the key definitely maps to value
• : no other thread can change the value at key
• : this thread can change the value at key
• is analogous
![Page 11: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/11.jpg)
Shared Key ConcurrencyExtended Concurrent Abstract Predicates: with
• : the key might map to a value, and if it does that value is
• : all threads can only remove the value at key k, the current thread has not done this so far
• is analogous
• Similarly we have and for insert only
![Page 12: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/12.jpg)
Concurrent Index Specification
New specification of remove(h,k):
remove(h,k)
remove(h,k)
remove(h,k)
![Page 13: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/13.jpg)
Concurrent remove
remove(h,k) remove(h,k)
![Page 14: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/14.jpg)
Parallel Sieve of Eratosthenes
![Page 15: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/15.jpg)
Parallel Sieve of Eratosthenes
Worker thread:
worker(v,max,h)c v + v;while(c max)
remove(h,c);c c + v;
![Page 16: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/16.jpg)
Combining Predicates
if
if
![Page 17: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/17.jpg)
Parallel Sieve of Eratosthenes
Sieve specification:
worker(2,max,h)|| worker(3,max,h) || … || worker(m,max,h)
where m =
![Page 18: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/18.jpg)
Implementing a Concurrent Index
Our abstract concurrent index specification is sound for a number of different implementations, including:
Linked ListsHash Tables
Arrays
B-trees
![Page 19: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/19.jpg)
Concurrent B-tree
1-∞ 4 10 20 22 22L
237 38 3822
L
738 40 42 44 44L
444 52 62 66 66L
668 71 7166
L
577 85 9371
L∞
338 4422-∞
866 7144 ∞
944 ∞-∞
![Page 20: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/20.jpg)
Concurrent B-tree
B-tree remove implementation must satisfy the specification:
remove(h,k)
Concrete definition of :
Shared stateInterference environment
Capability tokens
![Page 21: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/21.jpg)
Concurrent B-tree
Check axioms: for example,
if
Check stability of predicates
Check implementations satisfy abstract specifications
![Page 22: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/22.jpg)
Concurrent B-tree
Proof of remove implementation:
![Page 23: A Simple Abstraction for Complex Concurrent Indexes](https://reader035.vdocument.in/reader035/viewer/2022062323/56816022550346895dcf2408/html5/thumbnails/23.jpg)
ConclusionSummary:
simple abstract spec for concurrent indexesessence of real-world client programscorrect implementations
linked listshash tablesconcurrent B-trees
proof structure lends itself to automation
Future work: Automation/Proof Assistant (Dinsdale-Young)java.util.concurrent (da Rocha Pinto)File Systems (Ntzik)