Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.

Slides:



Advertisements
Similar presentations
CS16: Introduction to Data Structures & Algorithms
Advertisements

David Luebke 1 6/7/2014 CS 332: Algorithms Skip Lists Introduction to Hashing.
CMSC420: Skip Lists Kinga Dobolyi Based off notes by Dave Mount.
Linked Lists: Locking, Lock- Free, and Beyond … Based on the companion slides for The Art of Multiprocessor Programming (Maurice Herlihy & Nir Shavit)
Multicore Programming Skip list Tutorial 10 CS Spring 2010.
Fibonacci Heaps Especially desirable when the number of calls to Extract-Min & Delete is small (note that all other operations run in O(1) This arises.
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Scalable and Lock-Free Concurrent Dictionaries
Introduction Companion slides for
Linked Lists: Lazy and Non-Blocking Synchronization Based on the companion slides for The Art of Multiprocessor Programming (Maurice Herlihy & Nir Shavit)
Search Trees: BSTs and B-Trees David Kauchak cs302 Spring 2013.
Introduction to Software Engineering 7. Modeling Behaviour.
Binary Search Trees Briana B. Morrison Adapted from Alan Eugenio.
12. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Roadmap  Summary: —Trends in programming paradigms  Research:...
Shared Counters and Parallelism Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
ESE Einführung in Software Engineering N. XXX Prof. O. Nierstrasz Fall Semester 2009.
ESE Einführung in Software Engineering X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
Metamodeling Seminar X. CHAPTER Prof. O. Nierstrasz Spring Semester 2008.
ESE Einführung in Software Engineering X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
N. XXX Prof. O. Nierstrasz Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes.
Linked Lists: Locking, Lock- Free, and Beyond … Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
7. Fixed Points. © O. Nierstrasz PS — Fixed Points 7.2 Roadmap  Representing Numbers  Recursion and the Fixed-Point Combinator  The typed lambda calculus.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
CP — Concurrent Programming X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
Ch. 13: Balanced Search Trees Symbol table: insert, delete, find, pred, succ, sort,… Binary Search Tree review: What is a BST? binary tree with a key at.
12. eToys. © O. Nierstrasz PS — eToys 12.2 Denotational Semantics Overview:  … References:  …
Two-Process Systems TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A AA Companion slides for Distributed Computing.
Win8 on Intel Programming Course The challenge Paul Guermonprez Intel Software
B-Tree. B-Trees a specialized multi-way tree designed especially for use on disk In a B-tree each node may contain a large number of keys. The number.
Multicore Programming
AITI Lecture 20 Trees, Binary Search Trees Adapted from MIT Course 1.00 Spring 2003 Lecture 28 and Tutorial Note 10 (Teachers: Please do not erase the.
The Animated Sequence Chapter 5.1 in Sketching User Experiences: The Workbook.
Linked Lists: Locking, Lock- Free, and Beyond … Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
State Teleportation How Hardware Transactional Memory can Improve Legacy Data Structures Maurice Herlihy and Eli Wald Brown University.
Linked Lists: Optimistic, Lock-Free, … Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified by Pavol Černý,
Linked Lists: Locking, Lock- Free, and Beyond … Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified by.
Concurrent Linked Lists and Linearizability Proofs Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified.
Hashing and Natural Parallism Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
(c) University of Washington16-1 CSC 143 Java Linked Lists Reading: Ch. 20.
Advanced Locking Techniques
Skiplist-based Concurrent Priority Queues Itay Lotan Stanford University Nir Shavit Sun Microsystems Laboratories.
A Simple Optimistic skip-list Algorithm Maurice Herlihy Brown University & Sun Microsystems Laboratories Yossi Lev Brown University & Sun Microsystems.
Design of Everyday Things Part 2: Useful Designs? Lecture /slide deck produced by Saul Greenberg, University of Calgary, Canada Images from:
Concurrent Queues Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
Multiprocessor Architecture Basics Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
Concurrent Stacks Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
Futures, Scheduling, and Work Distribution Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit TexPoint fonts used.
Priority Queues Dan Dvorin Based on ‘The Art of Multiprocessor Programming’, by Herlihy & Shavit, chapter 15.
Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists.
Linked Lists: Locking, Lock-Free, and Beyond … Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
Binary Search Trees.  Understand tree terminology  Understand and implement tree traversals  Define the binary search tree property  Implement binary.
SkipLists and Balanced Search The Art Of MultiProcessor Programming Maurice Herlihy & Nir Shavit Chapter 14 Avi Kozokin.
Images of pesticides By: Leslie London, University of Cape Town This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5.
Linked Lists: Locking, Lock- Free, and Beyond … Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
Linked Lists: Locking, Lock- Free, and Beyond … Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
The Relative Power of Synchronization Operations Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
(c) University of Washington20c-1 CSC 143 Binary Search Trees.
Skip Lists. Linked Lists Fast modifications given a pointer Slow traversals to random point.
Lecture 9 : Concurrent Data Structures Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit.
6.852 Lecture 21 ● Techniques for highly concurrent objects – coarse-grained mutual exclusion – read/write locking – fine-grained locking (mutex and read/write)
Lecture 6-1 : Concurrent Data Structures (Concurrent Linked Lists)
Concurrent Objects Companion slides for
CO890 CONCURRENCY & PARALLELISM
Monday, April 16, 2018 Announcements… For Today…
Elements of Combinatorial Topology
FOTW Worksheet Slides Christopher Penn, Financial Aid Podcast Student Loan Network.
Concurrent Data Structures Concurrent Algorithms 2017
Simulations and Reductions
A Concurrent Lock-Free Priority Queue for Multi-Thread Systems
CSC 143 Binary Search Trees.
Presentation transcript:

Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Concurrent Skip Lists

Art of Multiprocessor Programming© Herlihy Shavit 2007 Set Object Interface Collection of elements No duplicates Methods –add() a new element –remove() an element –contains() if element is present

Art of Multiprocessor Programming© Herlihy Shavit 2007 Many are Cold but Few are Frozen Typically high % of contains() calls Many fewer add() calls And even fewer remove() calls –90% contains() –9% add() –1% remove() Folklore? –Yes but probably mostly true

Art of Multiprocessor Programming© Herlihy Shavit 2007 Concurrent Sets Balanced Trees? –Red-Black trees, AVL trees, … Problem: no one does this well … … because rebalancing after add() or remove() is a global operation

Art of Multiprocessor Programming© Herlihy Shavit 2007 Skip Lists Probabilistic Data Structure No global rebalancing Logarithmic-time search

Art of Multiprocessor Programming© Herlihy Shavit 2007 Skip List Property Each layer is sublist of lower-levels

Art of Multiprocessor Programming© Herlihy Shavit 2007 Skip List Property Each layer is sublist of lower-levels

Art of Multiprocessor Programming© Herlihy Shavit 2007 Skip List Property Each layer is sublist of lower-levels

Art of Multiprocessor Programming© Herlihy Shavit 2007 Skip List Property Each layer is sublist of lower-levels

Art of Multiprocessor Programming© Herlihy Shavit 2007 Skip List Property Each layer is sublist of lower-levels Lowest level is entire list

Art of Multiprocessor Programming© Herlihy Shavit 2007 Skip List Property Each layer is sublist of lower-levels Not easy to preserve in concurrent implementations …

Art of Multiprocessor Programming© Herlihy Shavit 2007 Search contains(8) Too far

Art of Multiprocessor Programming© Herlihy Shavit 2007 Search contains(8) OK

Art of Multiprocessor Programming© Herlihy Shavit 2007 Search contains(8) Too far

Art of Multiprocessor Programming© Herlihy Shavit 2007 Search contains(8) Too far

Art of Multiprocessor Programming© Herlihy Shavit 2007 Search contains(8) Yes!

Art of Multiprocessor Programming© Herlihy Shavit Search contains(8)

Art of Multiprocessor Programming© Herlihy Shavit Logarithmic contains(8) Log N

Art of Multiprocessor Programming© Herlihy Shavit 2007 Why Logarthimic Property: Each pointer at layer i jumps over roughly 2 i nodes Pick node heights randomly so property guaranteed probabilistically 2i2i 2i2i

Art of Multiprocessor Programming© Herlihy Shavit 2007 Find() -- Sequential int find(T x, Node [] preds, Node [] succs) { … }

Art of Multiprocessor Programming© Herlihy Shavit 2007 Find() -- Sequential int find(T x, Node [] preds, Node [] succs) { … } object height (-1 if not there)

Art of Multiprocessor Programming© Herlihy Shavit 2007 Find() -- Sequential int find(T x, Node [] preds, Node [] succs) { … } Object sought object height (-1 if not there)

Art of Multiprocessor Programming© Herlihy Shavit 2007 Find() -- Sequential int find(T x, Node [] preds, Node [] succs) { … } object sought return predecessors Object height (-1 if not there)

Art of Multiprocessor Programming© Herlihy Shavit 2007 Find() -- Sequential int find(T x, Node [] preds, Node [] succs) { … } object sought return predecessors return successors object height (-1 if not there)

Art of Multiprocessor Programming© Herlihy Shavit 2007 Successful Search find(7, …) prev

Art of Multiprocessor Programming© Herlihy Shavit 2007 Successful Search find(7, …) curr prev

Art of Multiprocessor Programming© Herlihy Shavit 2007 Unsuccessful Search find(6, …) prev

Art of Multiprocessor Programming© Herlihy Shavit 2007 Unsuccessful Search find(6, …) curr prev

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lazy Skip List Mix blocking and non-blocking techniques: –Use optimistic-lazy locking for add() and remove() –Wait-free contains() Remember: typically lots of contains() calls but few add() and remove()

Art of Multiprocessor Programming© Herlihy Shavit 2007 Review: Lazy List Remove aa b c d

Art of Multiprocessor Programming© Herlihy Shavit 2007 Review: Lazy List Remove aa b c d Present in list

Art of Multiprocessor Programming© Herlihy Shavit 2007 Review: Lazy List Remove aa b c d Logically deleted

Art of Multiprocessor Programming© Herlihy Shavit 2007 Review: Lazy List Remove aa b c d Physically deleted

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lazy Skip Lists Use a mark bit for logical deletion

Art of Multiprocessor Programming© Herlihy Shavit 2007 add(6) Create node of (random) height

Art of Multiprocessor Programming© Herlihy Shavit 2007 add(6) find() predecessors

Art of Multiprocessor Programming© Herlihy Shavit 2007 add(6) find() predecessors Lock them

Art of Multiprocessor Programming© Herlihy Shavit 2007 add(6) find() predecessors Lock them Validate Optimistic approach

Art of Multiprocessor Programming© Herlihy Shavit 2007 add(6) find() predecessors Lock them Validate Splice

Art of Multiprocessor Programming© Herlihy Shavit 2007 add(6) find() predecessors Lock them Validate Splice Unlock

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6)

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6) find() predecessors

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6) find() predecessors Lock victim

Art of Multiprocessor Programming© Herlihy Shavit remove(6) find() predecessors Lock victim Set mark (if not already set) Logical remove…

Art of Multiprocessor Programming© Herlihy Shavit remove(6) find() predecessors Lock victim Set mark (if not already set) Lock predecessors (ascending order) & validate

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6) find() predecessors Lock victim Set mark (if not already set) Lock predecessors (ascending order) & validate Physically remove

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6) find() predecessors Lock victim Set mark (if not already set) Lock predecessors (ascending order) & validate Physically remove

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6) find() predecessors Lock victim Set mark (if not already set) Lock predecessors (ascending order) & validate Physically remove

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6) find() predecessors Lock victim Set mark (if not already set) Lock predecessors (ascending order) & validate Physically remove

Art of Multiprocessor Programming© Herlihy Shavit 2007 remove(6) find() predecessors Lock victim Set mark (if not already set) Lock predecessors (ascending order) & validate Physically remove

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(8) Find() & not marked

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(8) Node 6 removed while traversed

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(8) Node removed while being traversed

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(8) Prove: an unmarked node (like 8) remains reachable

Art of Multiprocessor Programming© Herlihy Shavit remove(6): Linearization Successful remove happens when bit is set Logical remove…

Art of Multiprocessor Programming© Herlihy Shavit 2007 Add: Linearization Successful add() at point when fully linked Add fullyLinked bit to indicate this Bit tested by contains()

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(7): Linearization When fully-linked unmarked node found Pause while fullyLinked bit unset

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(7): Linearization When do we linearize unsuccessful Search? 1 So far OK…

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(7): Linearization When do we linearize unsuccessful Search? 7 7 But what if a new 7 added concurrently?

Art of Multiprocessor Programming© Herlihy Shavit 2007 contains(7): Linearization When do we linearize unsuccessful Search? Prove: at some point 7 was not in the skip list

Art of Multiprocessor Programming© Herlihy Shavit 2007 A Simple Experiment Each thread runs 1 million iterations, each either: –add() –remove() –contains() Item and method chosen in random from some distribution

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lazy Skip List: Performance Multiprogramming

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lazy Skip List: Performance Multiprogramming Higher contention Throughput

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lazy Skip List: Performance Multiprogramming Unrealistic Contention

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lock-Free Variant No locking –Cannot preserve “skiplist invariant” –Each list sublist of next Instead –Bottom-level list is the ground truth –Everything else is optimization

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lock-Free Skip List No locking –Cannot preserve “skiplist invariant” –Each list no longer sublist of child

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lock-Free Skip List Bottom-level list is actual list –Ground truth Find() works much as before

Art of Multiprocessor Programming© Herlihy Shavit 2007 Lock-Free Skip List Each level is individual LockFreeList Shortcuts only No need for FullyLinked field

Art of Multiprocessor Programming© Herlihy Shavit 2007 Add(7) Add from bottom level –Bottom level add is linearization point –Other levels optimization

Art of Multiprocessor Programming© Herlihy Shavit Remove(7) Logically remove from each list –Starting at top Linearization point is lowest remove

Art of Multiprocessor Programming© Herlihy Shavit 2007 Summary Lazy Skip List –Optimistic fine-grained Locking –Performs as well as the lock-free solution in “common” cases –But Simpler Lock-Free Skip List –Combines tricks from earlier lectures

Art of Multiprocessor Programming© Herlihy Shavit 2007 This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.Creative Commons Attribution-ShareAlike 2.5 License You are free: –to Share — to copy, distribute and transmit the work –to Remix — to adapt the work Under the following conditions: –Attribution. You must attribute the work to “The Art of Multiprocessor Programming” (but not in any way that suggests that the authors endorse you or your use of the work). –Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to – Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author's moral rights.