a lock free priority queue design based on multi
play

A Lock-free Priority Queue Design Based on Multi-dimensional Linked - PowerPoint PPT Presentation

Background Algorithm Experimental Evaluation A Lock-free Priority Queue Design Based on Multi-dimensional Linked Lists Deli Zhang Damian Dechev University of Central Florida September 9, 2014 D. Zhang, D. Dechev A Lock-free Priority Queue


  1. Background Algorithm Experimental Evaluation A Lock-free Priority Queue Design Based on Multi-dimensional Linked Lists Deli Zhang Damian Dechev University of Central Florida September 9, 2014 D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  2. Background Algorithm Motivation Experimental Evaluation Priority Queues Abstract Data Structure Insert adds a key-value pair into the queue sorted by keys DeleteMin returns and removes the first key-value pair Typical Sequential Implementations Balanced Search Trees Array-based Binary Heap D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  3. Background Algorithm Motivation Experimental Evaluation Concurrent Priority Queues Skip-list Use randomization to avoid global balancing Keep redundant short-cut lists for fast search Skip-list based approaches Sundell et al. 2005: first lock-free linearizable implementation Shavit et al. 2009: lock-free and quiescently consistent Linden et al 2013: batch physical deletion to reduce contention D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  4. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Ordered Linked List 0 1 2 3 4 5 6 7 O ( n ) search/insertion O (1) deletion 8 9 10 11 12 13 14 15 D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  5. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Ordered 2-D List (0,0) (1,0) (2,0) (3,0) Vector ( d 0 , d 1 ) serves as (3,1) (0,1) (1,1) (2,1) insertion coordinates O ( √ n ) search/insertion O (1) deletion (3,2) (0,2) (1,2) (2,2) (1,3) (3,3) (0,3) (2,3) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  6. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Multi-dimensional List Definition A D -dimensional list is a rooted tree in which each node is implicitly assigned a dimension of d ∈ [0 , D ). The root node’s dimension is 0. A node of dimension d has no more than D − d children, where the m th child is assigned a dimension of d ′ = d + m − 1. Definition Given a non-root node of dimension d with coordinate k = ( k 0 , ..., k D − 1 ) and its parent with coordinate k ′ = ( k ′ 0 , ..., k ′ D − 1 ) in an ordered D -dimensional list: k i = k ′ i , ∀ i ∈ [0 , d ) ∧ k d > k ′ d . D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  7. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Ordered 3-D List (3,0,3) (0,0,3) (0,0,2) (3,0,2) √ n ) Worst-case O ( D D (0,0,1) (1,0,3) (2,0,2) (3,0,1) search/insertion (0,0,0) (1,0,2) (2,0,1) (3,0,0) Choose D = log n then (0,1,2) √ n = O (log n ) log n log n (0,1,0) (1,1,2) (2,1,0) (3,1,0) No need for global re- (3,3,3) balancing/randomization (0,2,2) (1,2,1) (2,2,0) (3,2,0) (3,3,2) (0,3,1) (3,3,1) (0,3,0) (3,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  8. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Locate Unique Inserting Position (3,0,3) (0,0,3) (2,0,0) (0,0,2) (3,0,2) Compare coordinate (0,0,1) (1,0,3) (2,0,2) (3,0,1) vector from d = 0 (0,0,0) (1,0,2) (2,0,1) (3,0,0) Increase d if equal (0,1,2) (3,1,0) (0,1,0) (1,1,2) (2,1,0) Go to d th child if greater (3,3,3) Stop if smaller (0,2,2) (1,2,1) (2,2,0) (3,2,0) (3,3,2) (0,3,1) (3,3,1) (0,3,0) (3,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  9. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Insert (0,0,3) (3,0,3) (2,0,0) (0,0,2) (3,0,2) Point to parent’s old child (0,0,1) (1,0,3) (2,0,2) (3,0,1) Update parent’s child (0,0,0) (1,0,2) (2,0,1) (3,0,0) pointer (0,1,2) Adopt old child’s children (0,1,0) (1,1,2) (2,1,0) (3,1,0) if old child’s dimension is (3,3,3) changed (3,2,0) (0,2,2) (1,2,1) (2,2,0) (3,3,2) (0,3,1) (3,3,1) (0,3,0) (3,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  10. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Adopting Children (3,0,3) (0,0,3) (0,0,2) (2,0,2) (3,0,2) (0,0,1) (1,0,3) (2,0,1) (3,0,1) New node d = 0 (0,0,0) (1,0,2) (2,0,0) (3,0,0) Old child d = 2 (0,1,2) Old child’s children on (0,1,0) (1,1,2) (2,1,0) (3,1,0) dimension 0, 1 are transfer to new node (3,3,3) (0,2,2) (1,2,1) (2,2,0) (3,2,0) (3,3,2) (0,3,1) (3,3,1) (0,3,0) (3,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  11. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Normal Deletion (3,0,3) (0,0,3) (0,0,2) (3,0,2) (0,0,1) (1,0,3) (2,0,2) (3,0,1) (0,0,0) (1,0,2) (2,0,1) (3,0,0) Prompt the next minimal node (0,1,2) Preserve two children (0,1,0) (1,1,2) (2,1,0) (3,1,0) (3,3,3) (0,2,2) (1,2,1) (2,2,0) (3,2,0) (3,3,2) (0,3,1) (3,3,1) (0,3,0) (3,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  12. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Normal Deletion - Promotion (3,0,3) (0,0,3) (3,0,2) (0,0,2) (1,0,3) (2,0,2) (3,0,1) (0,0,1) (1,0,2) (2,0,1) (3,0,0) Transfer them to the new head (0,1,2) Heavy contention on the head (0,1,0) (1,1,2) (2,1,0) (3,1,0) nodes (3,3,3) (0,2,2) (1,2,1) (2,2,0) (3,2,0) (3,3,2) (0,3,1) (3,3,1) (0,3,0) (3,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  13. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Stack-based Deletion DIM0 (0,0,0) (3,0,3) (0,0,3) DIM1 (0,1,0) DIM2 (0,1,2) (0,0,2) (3,0,2) Deletion Stack (0,0,1) (1,0,3) (2,0,2) (3,0,1) Mark for logical deletion (0,0,0) (1,0,2) (2,0,1) (3,0,0) DPS to find next node (0,1,2) Use stack as cache to (0,1,0) (1,1,2) (2,1,0) (3,1,0) DPS path (3,3,3) (0,2,2) (1,2,1) (2,2,0) (3,2,0) (3,3,2) (3,3,1) (0,3,1) (3,3,0) (0,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  14. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Stack-based Deletion DIM0 (1,0,2) (3,0,3) (0,0,3) DIM1 (1,0,2) DIM2 (1,0,3) (0,0,2) (3,0,2) Deletion Stack (0,0,1) (1,0,3) (2,0,2) (3,0,1) Mark for logical deletion (0,0,0) (1,0,2) (2,0,1) (3,0,0) DPS to find next node (0,1,2) Use stack as cache to (0,1,0) (1,1,2) (2,1,0) (3,1,0) DPS path (3,3,3) (0,2,2) (1,2,1) (2,2,0) (3,2,0) (3,3,2) (3,3,1) (0,3,1) (3,3,0) (0,3,0) D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  15. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Lock-free Priority Queue Concurrent Insertion Use CAS to swing predecessor’s pointer Use descriptor that resides in the node to finish the children adoption process Concurrent DeleteMin Deletion threads use deletion stack to find the next node Deletion threads move stack forward, and purge deleted nodes Insertion threads rewind stack if new node cannot be reached D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  16. Overview Background Insertions Algorithm DeleteMin Experimental Evaluation Concurrent Access Correctness Abstract State Mapping Stack Rewind Position 3 Unreachable Nodes (M) 0 1 2 4 5 6 7 Logically Deleted Nodes (S) All Nodes (L) New Head 0 3 0 1 2 3 4 5 6 7 Purged Nodes D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional

  17. Background Algorithm Performance Testing Experimental Evaluation Throughput 1e+08 1e+07 1e+07 16DPQ 4DPQ 4DPQ 8DPQ 8DPQ 8DPQ TBBPQ TBBPQ TBBPQ LJPQ LJPQ LJPQ HSPQ HSPQ HSPQ Throughput (OP/s) 1e+07 Throughput (OP/s) 1e+06 Throughput (OP/s) 1e+06 1e+06 100000 100000 10000 100000 1 2 4 8 16 32 64 128 1 2 4 8 16 32 64 128 1 2 4 8 16 32 64 128 Number of Threads Number of Threads Number of Threads (a) 100% Insert on the (b) 100% DeleteMin (c) 50% Insert on the NUMA System on the NUMA System NUMA System 1e+08 1e+08 8DPQ 16DPQ TBBPQ TBBPQ 75% Insert on the NUMA system LJPQ LJPQ HSPQ HSPQ 5e+06 Throughput (OP/s) Throughput (OP/s) 4e+06 1e+07 1e+07 3e+06 2e+06 Throughput (op/s) Throughput (op/s) 8 16 24 32 40 48 56 64 4 8 12 16 20 24 Number of Threads Dimensions 28 32 1e+06 1e+06 2 4 6 8 10 12 14 16 18 20 22 24 2 4 6 8 10 12 14 16 18 20 22 24 Number of Threads Number of Threads (d) 50% Insert on the (e) 80% Insert on the (f) Dimensionality and SMP System SMP System Performance D. Zhang, D. Dechev A Lock-free Priority Queue Design Based on Multi-dimensional Figure: Throughput of the Priority Queues

Recommend


More recommend