Automatic Fine-Grained Synchronization via Domination Locking
-
Upload
hayden-cooper -
Category
Documents
-
view
28 -
download
5
description
Transcript of Automatic Fine-Grained Synchronization via Domination Locking
![Page 1: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/1.jpg)
Guy Golan-Gueta Tel-Aviv UniversityNathan Bronson Stanford UniversityAlex Aiken Stanford UniversityG. Ramalingam Microsoft ResearchMooly Sagiv Tel-Aviv UniversityEran Yahav Technion
Automatic Fine-Grained Synchronizationvia Domination Locking
![Page 2: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/2.jpg)
Creating Highly Concurrent Data-Structures
• Given a sequential implementation of a data-structure
• Automatically create a correct highly concurrent version of this data-structure
![Page 3: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/3.jpg)
Creating Highly Concurrent Data-Structures via Fine-Grained Locking
• Automatically add locks to guarantee:• Correctness• Atomicity• Deadlock freedom
• High level of parallelism• Fine-grained locks, lock for each object• A lock is only held while necessary
![Page 4: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/4.jpg)
Creating Highly Concurrent Data-Structures via Fine-Grained Locking
• Automatically add locks to guarantee:• Correctness• Atomicity• Deadlock freedom
• High level of parallelism• Fine-grained locks, lock for each object• A lock is only held while necessary
n1
listn2 n3 n4
early release
![Page 5: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/5.jpg)
Example: remove from a balanced search-tree (Treap)
When should I acquire and release each lock?
Under what conditions?
![Page 6: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/6.jpg)
Locking Protocol
• Enforce a locking protocol in the given code
• What locking protocol do we need to enforce?• How to enforce this protocol in the given
code?
![Page 7: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/7.jpg)
What locking protocol?
• Two Phase Locking– Does not allow early release
• Tree/DAG locking – Assume that the objects graph is static
• Dynamic versions of Tree/DAG locking
![Page 8: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/8.jpg)
Our Approach: The Domination Locking Protocol
• Works for any shape
• Allows early release
![Page 9: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/9.jpg)
Two types of objects• Distinguishes between exposed and hidden objects• Exposed objects
– “roots” of data structures– may be pointed by transaction arguments
• Hidden objects– may not be pointed by transaction arguments– may be reachable via exposed objects
List...
exposed hidden hidden hidden
void insert(List l, int k) {…}
![Page 10: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/10.jpg)
Restricted Semantics
• Leverages the restricted semantics of software modules– thread can access n3 only after n1 & n2
exposed hidden hidden hidden
n1
Listn2 n3 n4
![Page 11: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/11.jpg)
Domination Locking1. transaction t can access object only when holding its lock 2. an hidden object u can be acquired by t only if
every path between an exposed object to u includes an object which is locked by t
DSa1 a2 a3 a4
a5 a6
a7
![Page 12: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/12.jpg)
assume ≤ be a total order of objects
3. t can acquire an exposed object u, only if• t has never acquired an exposed object v ≤ u• t has never released a lock
a1DSA
b1DSB
...
...
![Page 13: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/13.jpg)
Concurrent Correctness from Sequential Conditions
If every sequential execution satisfies DL and is able to terminate
concurrent operations are conflict-serializable and deadlock-free
(Intuition similar to Rinetzky et. al POPL’10)
![Page 14: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/14.jpg)
Automatic Locking
• A method to enforce DL when shape== forest– add locking by relying on the restricted shape– without understanding the details of the given
code
![Page 15: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/15.jpg)
Example: remove from a balanced search-tree (Treap)
![Page 16: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/16.jpg)
Forest-Based Data-Structure
• In every sequential execution, shape is a forest at the beginning and end of transactions
![Page 17: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/17.jpg)
Forest-Based Data-Structure
• In every sequential execution, shape is a forest at the beginning and end of transactions
• Example:
b3
ListA
ListB
b4b2b1
a1 a2 a3 a4
forest violation
move a3 from ListA to ListB
![Page 18: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/18.jpg)
Forest-Based Data Structure
• Consistent objects– exposed object has no predecessors– hidden object has 0 or 1 predecessors (unshared)
• A data-structure is forest-based if– In every sequential execution, all object are
consistent at the beginning and end of transactions
![Page 19: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/19.jpg)
Reference counters
We add to two reference counters to objects
• Stack reference counter – counts number of incoming pointers from private
memory (stack variables)• Heap reference counter– counts number of incoming pointers from heap
objects
![Page 20: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/20.jpg)
s=0 h=0 s=0 h=1 s=0 h=2 s=1 h=1
s=1 h=0
y
x
Reference counters
![Page 21: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/21.jpg)
Locking
• Acquire object u when – stack counter of u becomes positive
• Release object u when – stack counter of u becomes 0– u is consistent
![Page 22: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/22.jpg)
s=0 h=0 s=0 h=1 s=1 h=1 s=0 h=1
s=1 h=0
x
y
![Page 23: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/23.jpg)
s=0 h=0 s=0 h=1 s=1 h=2 s=0 h=1
s=1 h=0
x
y
![Page 24: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/24.jpg)
s=0 h=0 s=0 h=1 s=0 h=2 s=1 h=1
s=1 h=0
y
x
![Page 25: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/25.jpg)
Locking Argumentsvoid Move(List x, List y) {…
• Acquire *x and *y without leading to a deadlock– Define a unique identifier for each object• e.g. use memory addresses
– Acquire according the order of identifiers
void Move(List x, List y) {{ if( address(x) <= address(y) ) { acquire(x); acquire(y); } else { acquire(y); acquire(x); } …
![Page 26: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/26.jpg)
RB tree (top-down implementation)
1 2 4 8 16 32 640
100
200
300
400
500
600
Single Eager
Threads
Thro
ughp
ut (o
ps/m
sec)
![Page 27: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/27.jpg)
Treap
1 2 4 8 16 32 640
200
400
600
800
1000
1200
1400
1600
1800
Single Hand-Crafted Eager
Threads
Thro
ughp
ut (o
ps/m
sec)
![Page 28: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/28.jpg)
Apriori
1 2 4 80%
20%
40%
60%
80%
100%
120%
Single Original (fine-grained) Eager
Threads
Nor
mal
ized
Tim
e
![Page 29: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/29.jpg)
Summary
• New Locking Protocol – Domination Locking– Applies to any shape– Allows early release
• Automatic realization for forest-based data-structures
• Preliminary Evaluation– Automatic fine-grained locking for red-black tree
and others– Scales similarly to hand crafted locking
![Page 30: Automatic Fine-Grained Synchronization via Domination Locking](https://reader036.fdocuments.net/reader036/viewer/2022062408/568138ed550346895da0a10f/html5/thumbnails/30.jpg)
Thank You