Skiplist-based Concurrent Priority Queues Itay Lotan Stanford University Nir Shavit Sun Microsystems Laboratories.

Slides:



Advertisements
Similar presentations
CS 225 Lab #11 – Skip Lists.
Advertisements

Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems Håkan Sundell Philippas Tsigas.
COL 106 Shweta Agrawal and Amit Kumar
Heaps1 Part-D2 Heaps Heaps2 Recall Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is a pair (key, value)
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
CHAPTER 5 PRIORITY QUEUES (HEAPS) §1 ADT Model Objects: A finite ordered list with zero or more elements. Operations:  PriorityQueue Initialize( int.
A Distributed and Oblivious Heap Christian Scheideler and Stefan Schmid Dept. of Computer Science University of Paderborn.
1 6.3 Binary Heap - Other Heap Operations There is no way to find any particular key without a linear scan through the entire heap. However, if we know.
Binary Search Trees Briana B. Morrison Adapted from Alan Eugenio.
CMPT 225 Priority Queues and Heaps. Priority Queues Items in a priority queue have a priority The priority is usually numerical value Could be lowest.
Shared Counters and Parallelism Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
Binary Heaps CSE 373 Data Structures Lecture 11. 2/5/03Binary Heaps - Lecture 112 Readings Reading ›Sections
Chapter 6: Priority Queues Priority Queues Binary Heaps Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Heaps & Priority Queues Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
DEAPS By: Michael Gresenz Austin Forrest. Deaps A deap is a double-ended heap that supports the double-ended priority operations of insert, delete-min,
Priority Queues. Container of elements where each element has an associated key A key is an attribute that can identify rank or weight of an element Examples.
Source: Muangsin / Weiss1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
Skip Lists1 Skip Lists William Pugh: ” Skip Lists: A Probabilistic Alternative to Balanced Trees ”, 1990  S0S0 S1S1 S2S2 S3S3 
Programming Logic and Design Fourth Edition, Comprehensive
Chapter 6: Priority Queues
1 Priority Queues (Heaps)  Sections 6.1 to The Priority Queue ADT  DeleteMin –log N time  Insert –log N time  Other operations –FindMin  Constant.
§3 Binary Heap 1. Structure Property: 【 Definition 】 A binary tree with n nodes and height h is complete iff its nodes correspond to the nodes numbered.
Compiled by: Dr. Mohammad Alhawarat BST, Priority Queue, Heaps - Heapsort CHAPTER 07.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
ADT Table and Heap Ellen Walker CPSC 201 Data Structures Hiram College.
For Monday Read Weiss, chapter 7, sections 1-3. Homework –Weiss, chapter 4, exercise 6. Make sure you include parentheses where appropriate.
The Binary Heap. Binary Heap Looks similar to a binary search tree BUT all the values stored in the subtree rooted at a node are greater than or equal.
Data Structures Week 8 Further Data Structures The story so far  Saw some fundamental operations as well as advanced operations on arrays, stacks, and.
November 15, 2007 A Java Implementation of a Lock- Free Concurrent Priority Queue Bart Verzijlenberg.
CSC 213 – Large Scale Programming Lecture 15: Heap-based Priority Queue.
Skip Lists 二○一七年四月二十五日
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
A Simple Optimistic skip-list Algorithm Maurice Herlihy Brown University & Sun Microsystems Laboratories Yossi Lev Brown University & Sun Microsystems.
Range Queries in Non-blocking k-ary Search Trees Trevor Brown Hillel Avni.
CHAPTER 5 PRIORITY QUEUES (HEAPS) §1 ADT Model Objects: A finite ordered list with zero or more elements. Operations:  PriorityQueue Initialize( int.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Hashtables. An Abstract data type that supports the following operations: –Insert –Find –Remove Search trees can be used for the same operations but require.
The Set ADT List and Tree Implementations CSCI 2720 Spring 2007 Eileen Kraemer.
CS223 Advanced Data Structures and Algorithms 1 Priority Queue and Binary Heap Neil Tang 02/09/2010.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
Intro. to Data Structures Chapter 6 Priority Queue (Heap) Veera Muangsin, Dept. of Computer Engineering, Chulalongkorn University 1 Priority Queue.
HEAPS. Review: what are the requirements of the abstract data type: priority queue? Quick removal of item with highest priority (highest or lowest key.
AVL Trees and Heaps. AVL Trees So far balancing the tree was done globally Basically every node was involved in the balance operation Tree balancing can.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
CompSci 100e 8.1 Scoreboard l What else might we want to do with a data structure? AlgorithmInsertionDeletionSearch Unsorted Vector/array Sorted vector/array.
SkipLists and Balanced Search The Art Of MultiProcessor Programming Maurice Herlihy & Nir Shavit Chapter 14 Avi Kozokin.
2 Binary Heaps What if we’re mostly concerned with finding the most relevant data?  A binary heap is a binary tree (2 or fewer subtrees for each node)
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
Priority Queues and Heaps Tom Przybylinski. Maps ● We have (key,value) pairs, called entries ● We want to store and find/remove arbitrary entries (random.
Partially Ordered Data ,Heap,Binary Heap
Priority Queue A Priority Queue Set S is made up of n elements: x0 x1 x2 x3 … xn-1 Functions: createEmptySet() returns a newly created empty priority.
Chapter 11 Heap.
Recitation 3 (Heap Sort and Binary Search Tree)
Priority Queues and Heaps
Source: Muangsin / Weiss
O(lg n) Search Tree Tree T is a search tree made up of n elements: x0 x1 x2 x3 … xn-1 No function (except transverse) takes more than O(lg n) in the.
Heap Chapter 9 Objectives Upon completion you will be able to:
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Priority Queue and Binary Heap Neil Tang 02/12/2008
CS Data Structure: Heaps.
A Robust Data Structure
Binary Search Trees.
CSE 332: Data Structures Priority Queues – Binary Heaps Part II
A Concurrent Lock-Free Priority Queue for Multi-Thread Systems
Data Structures and Algorithm Analysis Priority Queues (Heaps)
Data Structures for Shaping and Scheduling
Priority Queues (Heaps)
Presentation transcript:

Skiplist-based Concurrent Priority Queues Itay Lotan Stanford University Nir Shavit Sun Microsystems Laboratories

2 Priority Queues For Large-Scale MultiProcessor Machines Priority Queue – A data structure that allows n asynchronous processes to insert an item, or delete the item with highest priority Large Scale Machine – Hundreds of Processors –Usually different architecture than small scale machines

3 Fixed Set Priority Queue A priority queue with a fixed and predetermined set of priorities Used by operating systems to distribute CPU time. Funnel Tree [Shavit, Zemach]There is a scalable solution - Funnel Tree [Shavit, Zemach]

4 General Priority Queue Supports an unlimited range of priorities Between any two priorities may be another Useful for –Heuristic searches –Graph searches HeapHunt et al Best solution – Heap algorithm of Hunt et al binary search treesWorks better than binary search trees

5 Hunt et al Heaps [Hunt et al]

6 Scalability Problem of Heaps

7 New Approach - SkipQueues Skip ListPughBased on Skip List of Pugh All locking is distributed and local Balancing of structure is probabilistic Deletions evenly distributed, minimal contention No need to pre-allocate memory All operations in expected logarithmic time

8 Coming up Next … Skip Lists Pugh 1.The inside story on concurrent Skip Lists [Pugh] SkipQueue 2.How to make a SkipQueue 3.Experimental Results

9 Skip List Structure [Pugh]

10 Inserting an Element InsertInsert (key_t k): –Randomly choose a level l –Find at each level of the list up to l the largest key smaller than k –For each level from 1 to l Acquire a lock on the item found before Insert the new key after it Release lock

11 Skip List - Insertion New Item

12 Deleting an Element DeleteDelete (key_t k) –Find k at all levels at which it appears. –For each level from l to 1 Acquire locks on k and the item before it. Remove k Release locks

13 Skip List - Deletion

14 SkipQueues Delete_MinProblem: How to allow Delete_Min operations without creating a bottle neck around the first element?

15 Our Solution Skip ListObservation - The lowest level of the Skip List contains all the elements in ascending order Processes can advance down this list and “logically” delete the first available key Each process can then delete the key that it previously deleted “logically”

16 Delete_Min Operation Skip ListTraverse the bottom level of the Skip List structure For each traversed Item –Try to SWAP its Deleted flag –If it was not already deleted, return the key of the item –Else, go on to next item If at the end of the list, return EMPTY No locking at all

17 From Skip List to SkipQueue

18 Performance Benchmarks We compared the performance of 3 structures: HeapHunt et al 1.The Heap structure of Hunt et al 2.FunnelList combining-funnel Shavit, Zemach 2.FunnelList – a simple linked list, access to which is governed by a combining-funnel [Shavit, Zemach] structure 3.SkipQueue 3.SkipQueue structure as described before

19 Benchmark Methodology Proteus Brewer et alWe used the Proteus multiprocessor simulator by Brewer et al We simulated a 256 processors machine similar to the MIT Alewife Processors alternate between performing small amount of work and accessing the queue.

20 Benchmark Methodology Cont’d Processors randomly choose whether to insert or delete Priorities of inserted items are chosen uniformly at random Insert Delete_MinWe measured the average latency of Insert and Delete_Min operations

21 Small Structure - Deletions

22 Small Structure - Insertions

23 Large Structure - Deletions

24 Large Structure - Insertions

25 Large Structure Benchmark With 70% Deletions - Deletions

26 Large Structure Benchmark With 70% Deletions - Insertions

27 Conclusions SkipQueues HeapsSkipQueues scale significantly better than Heaps SkipQueuesSkipQueues are highly distributed – no hot spots or bottle necks Deletes are 3 times faster and Inserts are 10 times faster when concurrency reaches 256 processors Future Directions –Implementation without locks –Experimenting with other data structures

28 Delete_Min Cont’d In order to assure a stronger ordering property we added the following: –Each item is time–stamped when its insertion is completed Delete_Min –Each Delete_Min operation notes the time at which it begins Delete_Min –The Delete_Min operation will only try to “logically” delete items that were inserted before it started.

29 Serialization Order Delete_MinEach successful Delete_Min is ordered at the time its “logical” deletion was completed Delete_Min EMPTYEach unsuccessful Delete_Min that returned EMPTY is ordered at the time of its return instruction Delete_MinEach uncompleted Delete_Min is ordered at the time of its invocation

30 SkipQueue Specification Delete_MinFor every Delete_Min operation –Let I be the set of keys inserted by Insert operations serialized before it Delete_Min –Let D be the set of keys removed by Delete_Min operations serialized before it EMPTYThe returned value is the smallest in the set I – D, or EMPTY if I – D is empty.