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

a lock free priority queue design based on multi
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

Background Algorithm Experimental Evaluation Motivation

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

slide-3
SLIDE 3

Background Algorithm Experimental Evaluation Motivation

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

slide-4
SLIDE 4

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Ordered Linked List

3 2 1 4 7 6 5 8 11 10 9 12 15 14 13

O(n) search/insertion O(1) deletion

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-5
SLIDE 5

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Ordered 2-D List

(0,0) (3,0) (2,0) (0,3) (0,2) (0,1) (1,0) (1,1) (1,2) (2,1) (2,2) (3,1) (3,2) (3,3) (1,3) (2,3)

Vector (d0, d1) serves as insertion coordinates O(√n) search/insertion O(1) deletion

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-6
SLIDE 6

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin 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 mth child is assigned a dimension of d′ = d + m − 1. Definition Given a non-root node of dimension d with coordinate k = (k0, ..., kD−1) and its parent with coordinate k′ = (k′

0, ..., k′ D−1) in an ordered D-dimensional list:

ki = k′

i , ∀ i ∈ [0, d) ∧ kd > k′ d.

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-7
SLIDE 7

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Ordered 3-D List

(3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,2) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (0,0,0) (3,0,0) (2,0,1) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0)

Worst-case O(D D √n) search/insertion Choose D = log n then log n log n √n = O(log n) No need for global re- balancing/randomization

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-8
SLIDE 8

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Locate Unique Inserting Position

(3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,2) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (0,0,0) (3,0,0) (2,0,1) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0) (2,0,0)

Compare coordinate vector from d = 0 Increase d if equal Go to dth child if greater Stop if smaller

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-9
SLIDE 9

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Insert

(3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,2) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (0,0,0) (3,0,0) (2,0,1) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0) (2,0,0)

Point to parent’s old child Update parent’s child pointer Adopt old child’s children if old child’s dimension is changed

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-10
SLIDE 10

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Adopting Children

(2,0,2) (3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,1) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (0,0,0) (3,0,0) (2,0,0) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0)

New node d = 0 Old child d = 2 Old child’s children on dimension 0, 1 are transfer to new node

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-11
SLIDE 11

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Normal Deletion

(3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,2) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (0,0,0) (3,0,0) (2,0,1) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0)

Prompt the next minimal node Preserve two children

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-12
SLIDE 12

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Normal Deletion - Promotion

(3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,2) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (3,0,0) (2,0,1) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0)

Transfer them to the new head Heavy contention on the head nodes

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-13
SLIDE 13

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Stack-based Deletion

(3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,2) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (0,0,0) (3,0,0) (2,0,1) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0) DIM0 (0,0,0) DIM1 (0,1,0) DIM2 (0,1,2) Deletion Stack

Mark for logical deletion DPS to find next node Use stack as cache to DPS path

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-14
SLIDE 14

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Stack-based Deletion

(3,0,3) (3,0,2) (3,0,1) (3,3,3) (3,3,2) (3,3,1) (0,3,1) (2,0,2) (0,1,2) (0,0,3) (0,0,2) (0,0,1) (0,0,0) (3,0,0) (2,0,1) (0,3,0) (0,2,2) (1,0,3) (0,1,0) (1,0,2) (1,1,2) (1,2,1) (2,1,0) (2,2,0) (3,1,0) (3,2,0) (3,3,0) DIM0 (1,0,2) DIM1 (1,0,2) DIM2 (1,0,3) Deletion Stack

Mark for logical deletion DPS to find next node Use stack as cache to DPS path

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-15
SLIDE 15

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin 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

slide-16
SLIDE 16

Background Algorithm Experimental Evaluation Overview Insertions DeleteMin Concurrent Access Correctness

Abstract State Mapping

3 2 1 4 7 6 5 Stack Rewind Position Unreachable Nodes (M) Logically Deleted Nodes (S) All Nodes (L) 3 2 1 4 7 6 5 3 New Head Purged Nodes

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional

slide-17
SLIDE 17

Background Algorithm Experimental Evaluation Performance Testing

Throughput

100000 1e+06 1e+07 1e+08 1 2 4 8 16 32 64 128 Throughput (OP/s) Number of Threads 16DPQ 8DPQ TBBPQ LJPQ HSPQ

(a) 100% Insert on the

NUMA System

10000 100000 1e+06 1e+07 1 2 4 8 16 32 64 128 Throughput (OP/s) Number of Threads 4DPQ 8DPQ TBBPQ LJPQ HSPQ

(b) 100% DeleteMin

  • n the NUMA System

100000 1e+06 1e+07 1 2 4 8 16 32 64 128 Throughput (OP/s) Number of Threads 4DPQ 8DPQ TBBPQ LJPQ HSPQ

(c) 50% Insert on the

NUMA System

1e+06 1e+07 1e+08 2 4 6 8 10 12 14 16 18 20 22 24 Throughput (OP/s) Number of Threads 8DPQ TBBPQ LJPQ HSPQ

(d) 50% Insert on the

SMP System

1e+06 1e+07 1e+08 2 4 6 8 10 12 14 16 18 20 22 24 Throughput (OP/s) Number of Threads 16DPQ TBBPQ LJPQ HSPQ

(e) 80% Insert on the

SMP System

4 8 12 16 20 24 28 32 8 16 24 32 40 48 56 64 2e+06 3e+06 4e+06 5e+06 Throughput (op/s) 75% Insert on the NUMA system Dimensions Number of Threads Throughput (op/s)

(f) Dimensionality and

Performance

Figure: Throughput of the Priority Queues

  • D. Zhang, D. Dechev

A Lock-free Priority Queue Design Based on Multi-dimensional