The Adaptive Priority Queue with Elimination and Combining - - PowerPoint PPT Presentation

the adaptive priority queue with elimination and combining
SMART_READER_LITE
LIVE PREVIEW

The Adaptive Priority Queue with Elimination and Combining - - PowerPoint PPT Presentation

The Adaptive Priority Queue with Elimination and Combining Irina Calciu, Hammurabi Mendes, Maurice Herlihy Brown University Scalability in the Multicore Age Our


slide-1
SLIDE 1

The ¡Adaptive ¡Priority ¡Queue ¡with ¡ Elimination ¡and ¡Combining

Irina ¡Calciu, ¡Hammurabi ¡Mendes, ¡Maurice ¡Herlihy Brown ¡University

slide-2
SLIDE 2

Scalability ¡in ¡the ¡Multicore ¡Age

  • Our ¡machines ¡are ¡getting ¡

bigger, ¡with ¡more ¡cores

  • Scalability ¡is ¡far ¡from ¡ideal
  • Synchronization ¡is ¡

expensive

  • We ¡need ¡better ¡data ¡

structures ¡for ¡these ¡new ¡ architectures

slide-3
SLIDE 3

Priority ¡Queue

  • Abstract ¡data ¡structure
  • Stores ¡<key, ¡value> ¡pairs, ¡where ¡keys ¡are ¡priorities
  • Interface: ¡synchronous ¡add(x) ¡and ¡removeMin()
  • Implementation: ¡heap ¡or ¡skiplist
  • Usage: ¡e.g. ¡resource ¡management
slide-4
SLIDE 4

Lazy ¡and ¡LockfreeSkiplists(prior ¡work) ¡– Add()

Head (Dummy) Tail (Dummy) Efficient ¡parallel ¡add ¡operations [Lotan2000, ¡Sundell2003] ¡

slide-5
SLIDE 5

Lazy ¡and ¡LockfreeSkiplists(prior ¡work) ¡– RemoveMin()

Head (Dummy) Tail (Dummy) Bottleneck: ¡contention ¡on ¡remove ¡operations [Lotan2000, ¡Sundell2003] ¡

slide-6
SLIDE 6

Thread Flat ¡Combining ¡(prior ¡work) Thread Thread Thread

EMPTY EMPTY EMPTY EMPTY OP ¡REQ OP ¡REQ OP ¡REQ OP ¡REQ

Combiner

[Hendler2010]

slide-7
SLIDE 7

Flat ¡Combining ¡(prior ¡work) ¡– RemoveMin()

Head (Dummy) Tail (Dummy)

slide-8
SLIDE 8

Flat ¡Combining ¡(prior ¡work) ¡– RemoveMin()

Head (Dummy) Tail (Dummy) Combiner

slide-9
SLIDE 9

Flat ¡Combining ¡(prior ¡work) ¡– RemoveMin()

Head (Dummy) Tail (Dummy) Combiner

slide-10
SLIDE 10

Flat ¡Combining ¡(prior ¡work) ¡– Add()

Head (Dummy) Tail (Dummy) Combiner Combiner Add ¡operations ¡are ¡sequential

slide-11
SLIDE 11

Flat ¡Combining ¡(prior ¡work) ¡– Add()

Head (Dummy) Tail (Dummy)

slide-12
SLIDE 12

Goal ¡(1): ¡Combining ¡+ ¡Parallel ¡Adds

Head (Dummy) Tail (Dummy) Combined ¡Operations Parallel ¡Adds

slide-13
SLIDE 13

Goal ¡(2): ¡Parallelize ¡Combined ¡Adds ¡Too

Head (Dummy) Tail (Dummy) Combined ¡Removes Parallel ¡Adds ¡? Parallel ¡Adds

slide-14
SLIDE 14

Stack ¡and ¡Queue ¡Elimination ¡(prior ¡work)

EMPTY EMPTY EMPTY EMPTY Elimination ¡Array Data ¡Structure ¡ (Stack ¡or ¡Queue)

Add

ADD

Rem

REM

Add [Hendler2004, ¡Moir2005]

slide-15
SLIDE 15

Parallelize ¡Combined ¡Adds ¡Too: ¡Use ¡Elimination

Head (Dummy) Tail (Dummy) Combined ¡Removes Parallel ¡Adds ¡? Parallel ¡Adds

slide-16
SLIDE 16

The ¡Priority ¡Queue ¡at ¡a ¡Glance

  • Elimination
  • RemoveMinand ¡small-­‑value ¡Add ¡combining
  • Large-­‑value ¡Add ¡parallelism
slide-17
SLIDE 17

Implementation: ¡Elimination

Head (Dummy) Tail (Dummy)

Priority ¡Queue

x

Elimination ¡Array

Add(x) Remove() Min

slide-18
SLIDE 18

Implementation: ¡Elimination

Head (Dummy) Tail (Dummy)

Priority ¡Queue x, ¡stamp Elimination ¡Array

Add(x) Remove() Min

slide-19
SLIDE 19

Implementation: ¡Combining

Head (Dummy) Tail (Dummy)

Priority ¡Queue rem, ¡0 y, ¡stamp x, ¡stamp Elimination ¡Array

Add(x) Remove() Min server

slide-20
SLIDE 20

Transitions ¡of ¡a ¡Slot ¡in ¡the ¡Elimination ¡Array

slide-21
SLIDE 21

Transitions ¡of ¡a ¡Slot ¡in ¡the ¡Elimination ¡Array

slide-22
SLIDE 22

Transitions ¡of ¡a ¡Slot ¡in ¡the ¡Elimination ¡Array

slide-23
SLIDE 23

Transitions ¡of ¡a ¡Slot ¡in ¡the ¡Elimination ¡Array

slide-24
SLIDE 24

Implementation: ¡Parallel ¡Adds

Head (Dummy) Tail (Dummy) Combined ¡Operations

rem, ¡0 y, ¡stamp x, ¡stamp Elimination ¡Array

Add(x) Remove() server Parallel ¡Adds Head (Dummy) Tail (Dummy)

slide-25
SLIDE 25

Adaptive ¡PQ ¡Split: ¡moveHead()

Head (Dummy) Tail (Dummy) Parallel ¡Adds server

slide-26
SLIDE 26

Adaptive ¡PQ ¡Split: ¡moveHead()

Head (Dummy) Tail (Dummy) Parallel ¡Adds server

slide-27
SLIDE 27

Adaptive ¡PQ ¡Split: ¡chopHead()

Head (Dummy) Tail (Dummy) Parallel ¡Adds server

slide-28
SLIDE 28

Adaptive ¡PQ ¡Split: ¡chopHead()

Head (Dummy) Tail (Dummy) Parallel ¡Adds server

slide-29
SLIDE 29

Synchronization

  • MoveHead() ¡and ¡chopHead() ¡change ¡the ¡parallel ¡skiplist
  • We ¡need ¡to ¡synchronize ¡server ¡and ¡parallel ¡adds
  • Use ¡RW ¡Lock
  • Server: ¡acquire ¡writeLock for ¡moveHead() ¡and ¡chopHead()
  • Parallel ¡adds: ¡acquire ¡readLock
slide-30
SLIDE 30

Synchronization

  • Single ¡writer ¡lock
  • Writer ¡preference
  • Implementation: ¡based ¡on ¡timestamps
  • Server ¡increments ¡timestamp ¡for ¡moveHead() ¡and ¡chopHead()
  • Don’t ¡hold ¡the ¡lock ¡for ¡the ¡whole ¡time ¡of ¡the ¡parallel ¡add
  • Do ¡a ¡clean ¡find ¡first ¡(as ¡verified ¡by ¡the ¡timestamp)
  • Acquire ¡read ¡lock ¡and ¡finish ¡the ¡insertion
slide-31
SLIDE 31

Linearizability-­‑ Elimination

slide-32
SLIDE 32

Linearizability-­‑ Combining

slide-33
SLIDE 33

50% ¡Add ¡Operations ¡50% ¡RemoveMinOperations

500 1000 1500 2000 2500 3000 3500 4000 1 2 4 8 16 24 32 40 48 54 60 Throughput Threads pqe fcpairheap fcskiplist lazyskiplist 0% 20% 40% 60% 80% 100% Add ¡Operations RemoveMin ¡ Operations Parallel Server Elimination

slide-34
SLIDE 34

500 1000 1500 2000 2500 3000 1 2 4 8 16 24 32 40 48 54 60

Throughput Threads pqe fcpairheap fcskiplist lazyskiplist

80% ¡Add ¡Operations ¡20% ¡RemoveMinOperations

0% 20% 40% 60% 80% 100%

Add ¡Operations RemoveMin ¡Operations Parallel Server Elimination

(Ops/ms)

slide-35
SLIDE 35

Impact ¡of ¡Maintaining ¡Two ¡Skiplists

slide-36
SLIDE 36

Hardware ¡Transactions ¡-­‑ Motivation

  • RW ¡Lock ¡can ¡be ¡too ¡expensive
  • Use ¡hardware ¡transactions ¡
  • Intel ¡TSX
  • Speculative ¡execution
slide-37
SLIDE 37

Hardware ¡Transactions ¡(1)

  • Naïve ¡version
  • Start ¡a ¡transaction
  • Find ¡+ ¡Insert
  • End ¡transaction ¡
  • Too ¡many ¡aborts
slide-38
SLIDE 38

Hardware ¡Transactions ¡(2)

  • Timestamp ¡approach
  • Server ¡increments ¡timestamp ¡for ¡moveHead() ¡and ¡chopHead()
  • Find ¡executes ¡non-­‑transactionallybut ¡has ¡to ¡be ¡restarted ¡if ¡

timestamp ¡changes

  • Insert ¡executed ¡in ¡a ¡transaction
  • Read ¡the ¡timestamp ¡in ¡the ¡transaction
slide-39
SLIDE 39

Using ¡Hardware ¡Transactions

(Ops/ms)

slide-40
SLIDE 40

Using ¡Hardware ¡Transactions

(Ops/ms)

slide-41
SLIDE 41

Transactions ¡Stats ¡for ¡50% ¡Add() ¡and ¡50% ¡RemoveMin()

slide-42
SLIDE 42

Summary

  • First ¡elimination ¡algorithm ¡for ¡a ¡priority ¡queue ¡
  • Use ¡two ¡skiplist to ¡separate ¡small ¡adds ¡from ¡large ¡value ¡adds
  • Combining ¡+ ¡Parallel ¡Adds ¡+ ¡Elimination ¡
  • HTM ¡simplified ¡the ¡algorithm ¡and ¡improved ¡performance ¡
slide-43
SLIDE 43

cs.brown.edu/~irina cs.brown.edu/~hmendes

slide-44
SLIDE 44

Transactions ¡Stats ¡for ¡3 ¡Working ¡Threads, ¡1 ¡Server ¡Thread