Presentation is loading. Please wait.

Presentation is loading. Please wait.

Guy Golan-GuetaTel-Aviv University Nathan Bronson Stanford University Alex Aiken Stanford University G. Ramalingam Microsoft Research Mooly Sagiv Tel-Aviv.

Similar presentations


Presentation on theme: "Guy Golan-GuetaTel-Aviv University Nathan Bronson Stanford University Alex Aiken Stanford University G. Ramalingam Microsoft Research Mooly Sagiv Tel-Aviv."— Presentation transcript:

1 Guy Golan-GuetaTel-Aviv University Nathan Bronson Stanford University Alex Aiken Stanford University G. Ramalingam Microsoft Research Mooly Sagiv Tel-Aviv University Eran Yahav Technion Automatic Fine-Grained Synchronization via Domination Locking

2 Creating Highly Concurrent Data-Structures Given a sequential implementation of a data- structure Automatically create a correct highly concurrent version of this data-structure

3 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

4 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 list n2 n3n4 early release

5 Example: remove from a balanced search-tree (Treap) When should I acquire and release each lock? Under what conditions?

6 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?

7 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

8 What locking protocol? Two Phase Locking [Papadimitriou `1979] – Does not allow early release Tree/DAG locking [Kedem et al. ‘1981], [Silberschatz, et al. ‘1982] – Assume that the objects graph is static Dynamic versions of Tree/DAG locking [Chaudhri et al. ‘1995], [Attiya et al. ‘2010]

9 Our Approach: The Domination Locking Protocol Works for any shape Allows early release

10 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... exposedhidden void insert(List l, int k) {…}

11 Restricted Semantics Leverages the restricted semantics of software modules – thread can access n3 only after n1 & n2 exposedhidden n1 List n2 n3n4

12 Domination Locking 1.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 DS a1 a2 a3 a4 a5a6 a7

13 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 a1 DS A b1 DS B...

14 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)

15 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

16 Example: remove from a balanced search-tree (Treap)

17 Forest-Based Data-Structure In every sequential execution, shape is a forest at the beginning and end of transactions

18 Forest-Based Data-Structure In every sequential execution, shape is a forest at the beginning and end of transactions Example: b3 List A List B b4 b2 b1 a1 a2a3 a4 forest violation move a3 from List A to List B

19 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

20 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

21 s=0 h=0 s=0 h=1 s=0 h=2s=1 h=1 s=1 h=0 yx Reference counters

22 Locking Acquire object u when – stack counter of u becomes positive Release object u when – stack counter of u becomes 0 – u is consistent

23 s=0 h=0 s=0 h=1 s=1 h=1s=0 h=1 s=1 h=0 xy

24 s=0 h=0 s=0 h=1 s=1 h=2s=0 h=1 s=1 h=0 xy

25 s=0 h=0 s=0 h=1 s=0 h=2s=1 h=1 s=1 h=0 yx

26 Locking Arguments void 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); } …

27 RB tree (top-down implementation)

28 Treap

29 Apriori

30 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

31 Thank You

32 Example: Sorted Linked List void Insert(SortedList list, int k) { Node p = list.Sentinel; Node c = p.next; while( c != null && c.k < k) { p = c ; c = c.next ; } n.next = c; p.next = n ; } n1 list n2 n3n4 void Insert(SortedList list, int k) { // original code + locking … } early release


Download ppt "Guy Golan-GuetaTel-Aviv University Nathan Bronson Stanford University Alex Aiken Stanford University G. Ramalingam Microsoft Research Mooly Sagiv Tel-Aviv."

Similar presentations


Ads by Google