Atomic snapshots in O(log³ n) steps 1. Snapshot Objects p1p1 p1p1 p2p2 p2p2 pnpn pnpn … … update( v ) scan 2 update your location read all locations.

Slides:



Advertisements
Similar presentations
The Dictionary ADT Definition A dictionary is an ordered or unordered list of key-element pairs, where keys are used to locate elements in the list. Example:
Advertisements

1 © R. Guerraoui The Power of Registers Prof R. Guerraoui Distributed Programming Laboratory.
AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
S. Sudarshan Based partly on material from Fawzi Emad & Chau-Wen Tseng
Tree Data Structures &Binary Search Tree 1. Trees Data Structures Tree  Nodes  Each node can have 0 or more children  A node can have at most one parent.
1 Theory I Algorithm Design and Analysis (2 - Trees: traversal and analysis of standard search trees) Prof. Th. Ottmann.
Two Techniques for Proving Lower Bounds Hagit Attiya Technion TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
© The McGraw-Hill Companies, Inc., Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Max Registers, Counters, and Monotone Circuits James Aspnes, Yale University Hagit Attiya, Technion Keren Censor, Technion PODC 2009.
1 B trees Nodes have more than 2 children Each internal node has between k and 2k children and between k-1 and 2k-1 keys A leaf has between k-1 and 2k-1.
Tirgul 5 AVL trees.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
CPSC 668Set 17: Fault-Tolerant Register Simulations1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
1 Adaptive and Efficient Mutual Exclusion Presented by: By Hagit Attya and Vita Bortnikov Mian Huang.
Wait-Free Consensus with Infinite Arrivals James Aspnes Gauri Shah Jatin Shah Yale University STOC 2002.
1 Binary heaps binary tree that satisfy two properties –structural property (is a complete tree) –heap-ordering property (minimum item on top) Can have.
B-Trees Chapter 9. Limitations of binary search Though faster than sequential search, binary search still requires an unacceptable number of accesses.
Skip Lists1 Skip Lists William Pugh: ” Skip Lists: A Probabilistic Alternative to Balanced Trees ”, 1990  S0S0 S1S1 S2S2 S3S3 
B-Trees (continued) Analysis of worst-case and average number of disk accesses for an insert. Delete and analysis. Structure for B-tree node.
AALG, lecture 11, © Simonas Šaltenis, Range Searching in 2D Main goals of the lecture: to understand and to be able to analyze the kd-trees and.
Binary Trees Chapter 6.
Splay Trees Splay trees are binary search trees (BSTs) that:
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
Advanced Data Structures and Algorithms COSC-600 Lecture presentation-6.
CPSC 335 BTrees Dr. Marina Gavrilova Computer Science University of Calgary Canada.
B-trees (Balanced Trees) A B-tree is a special kind of tree, similar to a binary tree. However, It is not a binary search tree. It is not a binary tree.
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
Chapter 19 - basic definitions - order statistics ( findkth( ) ) - balanced binary search trees - Java implementations Binary Search Trees 1CSCI 3333 Data.
Faster than Optimal Snapshots (for a While) James Aspnes, Yale University Hagit Attiya, Technion Keren Censor-Hillel, MIT Faith Ellen, University of Toronto.
1 AVL-Trees: Motivation Recall our discussion on BSTs –The height of a BST depends on the order of insertion E.g., Insert keys 1, 2, 3, 4, 5, 6, 7 into.
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
March 7 & 9, Csci 2111: Data and File Structures Week 8, Lectures 1 & 2 Multi-Level Indexing and B-Trees.
Binary Heap.
BINARY SEARCH TREE. Binary Trees A binary tree is a tree in which no node can have more than two children. In this case we can keep direct links to the.
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.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 8.
Chapter 11 Heap. Overview ● The heap is a special type of binary tree. ● It may be used either as a priority queue or as a tool for sorting.
Starting at Binary Trees
1 Trees 4: AVL Trees Section 4.4. Motivation When building a binary search tree, what type of trees would we like? Example: 3, 5, 8, 20, 18, 13, 22 2.
Outline Binary Trees Binary Search Tree Treaps. Binary Trees The empty set (null) is a binary tree A single node is a binary tree A node has a left child.
Symbol Tables and Search Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
1 Searching Searching in a sorted linked list takes linear time in the worst and average case. Searching in a sorted array takes logarithmic time in the.
Lec 15 Oct 18 Binary Search Trees (Chapter 5 of text)
2-3 Trees Extended tree.  Tree in which all empty subtrees are replaced by new nodes that are called external nodes.  Original nodes are called internal.
1 Joe Meehean.  We wanted a data structure that gave us... the smallest item then the next smallest then the next and so on…  This ADT is called a priority.
Four different data structures, each one best in a different setting. Simple Heap Balanced Heap Fibonacci Heap Incremental Heap Our results.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
1 Multi-Level Indexing and B-Trees. 2 Statement of the Problem When indexes grow too large they have to be stored on secondary storage. However, there.
Max Registers, Counters, and Monotone Circuits Keren Censor, Technion Joint work with: James Aspnes, Yale University Hagit Attiya, Technion (Slides
Binary Search Trees (BSTs) 18 February Binary Search Tree (BST) An important special kind of binary tree is the BST Each node stores some information.
Rooted Tree a b d ef i j g h c k root parent node (self) child descendent leaf (no children) e, i, k, g, h are leaves internal node (not a leaf) sibling.
CS 367 Introduction to Data Structures Lecture 8.
Priority Queues and Heaps Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University.
Dynamic Dictionaries Primary Operations:  get(key) => search  put(key, element) => insert  remove(key) => delete Additional operations:  ascend()
Atomic snapshots in O(log³ n) steps using randomized helping James Aspnes, Yale Keren Censor-Hillel, Technion 1.
(c) University of Washington20c-1 CSC 143 Binary Search Trees.
Keeping Binary Trees Sorted. Search trees Searching a binary tree is easy; it’s just a preorder traversal public BinaryTree findNode(BinaryTree node,
BSTs, AVL Trees and Heaps Ezgi Shenqi Bran. What to know about Trees? Height of a tree Length of the longest path from root to a leaf Height of an empty.
Lecture 15 Nov 3, 2013 Height-balanced BST Recall:
File Organization and Processing Week 3
Multiway Search Trees Data may not fit into main memory
Lec 12 March 9, 11 Mid-term # 1 (March 21?)
Search Sorted Array: Binary Search Linked List: Linear Search
(Slides were added to Keren’s original presentation. DH.)
CSC 143 Binary Search Trees.
(Slides were added to Keren’s original presentation. DH.)
Presentation transcript:

Atomic snapshots in O(log³ n) steps 1

Snapshot Objects p1p1 p1p1 p2p2 p2p2 pnpn pnpn … … update( v ) scan 2 update your location read all locations

Model 3 System of n processes, multi-writer registers Asynchronous schedule controlled by an adversary Crash failures – require wait-free implementations Linearizable implementations p1p1 p1p1 p2p2 p2p2 R1R1 R1R1 pnpn pnpn R2R2 R2R2 R R … … read v write( v ) ok

Snapshots - Step Complexity 4 Using multi-writer registers: can be done in O(n) steps [Inoue and Chen, WDAG 1994] and requires Ω(n) steps [Jayanti, Tan, and Toueg, SICOMP 1996] Goal: a faster snapshot implementation (polylog) Limited-use: O(log 3 (n)) steps per operation, for polynomially many update operations Randomized unbounded: O(log 3 (n)) steps per operation, with high probability (without a usage bound)

Pointer to array location 5 s1s1 s1s1 s2s2 s2s2 s3s3 s3s3 s4s4 s4s4 s 1 +s 2 s 3 +s 4 s s 4 0 Tree structure, Updates help Scans Array of views 5 O(log n) steps?

Two Challenges 6 s1s1 s1s1 s2s2 s2s2 s3s3 s3s3 s4s4 s4s4 s 1 +s 2 s 3 +s 4 s s Coping with slow operations. Max-register: returns largest value previously written

Two Challenges 7 s1s1 s1s1 s2s2 s2s2 s3s3 s3s3 s4s4 s4s4 s 1 +s 2 s 3 +s 4 s s Guaranteeing consistent views. Max-array: returns comparable pairs of max-register values

Bounded/Randomized snapshot in O(log 3 n) steps Bounded/Randomized 2-component max-array O(log 2 n) steps Bounded/Randomized 2-component max-array O(log 2 n) steps Bounded/Randomized max-register in O(logn) steps Ingredients 8

Max register 9 Replace multi-writer registers with Max Registers Max Register WriteMax( v ) ok ReadMax v Maximal value previously written

Max register – recursive construction 10 MaxReg 0 : Max register that supports only the value 0 – WriteMax is a no-op, and ReadMax returns 0 MaxReg 1 supports values in {0,1} – Built from two MaxReg 0 objects – and one additional multi-writer register “switch” MaxReg 0 switch WriteMax =1 ReadMax = ? switch=0 : return 0 switch=1 : return 1

Max register – recursive construction 11 MaxReg k supports values in {0,…,k-1} – Built from two MaxReg k/2 objects with values in {0,…,k/2-1} – and one additional multi-writer register “switch” MaxReg k/2 MaxReg k switch WriteMax t t t t < k/2 ? t t t -k/2 ReadMax =1 = ? t t t t switch=0 : return t switch=1 : return t +k/2

MaxReg k unfolded 12 switch MaxReg 0 … switch MaxReg 0 … … MaxReg k 012k-1 Complexity does not depend on n: WriteMax and ReadMax in O(logk) steps O(logk)

Unbalanced tree 13 MaxReg 0 … switch MaxReg 0 Bentley and Yao [1976] switch MaxReg 0 Leaf i is at depth O(log i)

Unbounded max register 14 MaxReg 0 … switch Snapshot-based counter switch MaxReg 0 WriteMax and ReadMax of v in O(min(log v, n)) steps

2-component max array p1p1 p1p1 p2p2 p2p2 pnpn pnpn … max 1max 2 update( v,1 ) scan 15 update( v,2 )

Cannot Simply Read Both Locations 16 We need to make sure that pairs of values that are read from sibling nodes are comparable – As in a snapshot In general, snapshots are linear However, we only need to take a snapshot of two max registers

2-component max array 17 Simply reading one max register and then the other does not work max 1 max 2 1. p 1 read 0 2. p 2 write( 100 ) 3. p 3 read p 3 read 0 5. p 2 write( 100 ) 6. p 1 read 100 p 1 returns (0,100) p 3 returns (100,0)

2-component max array 18 Read max registers again to see if they change – Might change many times – What if they were only binary? (0,0) and (1,1) are comparable with any pair If you see (0,1) or (1,0) read again max 1 max 2 1. p 1 read 0 2. p 2 write( 100 ) 3. p 3 read p 3 read 0 5. p 2 write( 100 ) 6. p 1 read 100

A 2-component max array 19 MaxReg k/2 MaxReg k switch MaxReg l Write Read switch=0 : switch=1 : v,1 v,2 x=ReadMax component 2 WriteMax(x,2) to left subtree Return ( Read left subtree) x=ReadMax component 2 WriteMax(x,2) to right subtree Return (k/2,0)+( Read right subtree) x x x x = ?

A 2-component max array 20 MaxReg k/2 MaxReg k switch MaxReg l Write Read switch=0 : switch=1 : x=ReadMax component 2 WriteMax(x,2) to left subtree Return ( Read left subtree) x=ReadMax component 2 WriteMax(x,2) to right subtree Return (k/2,0)+( Read right subtree) Key idea: a reader going right at the switch always sees a value for component 2 that is at least as large as any value that a reader going left sees

A 2-component max array unfolded 21 switch MaxReg 0 … switch MaxReg 0 … … MaxReg k MaxReg l Complexity is O(logk log l ) steps

Summary of the Bounded Snapshot For k which is polynomial in n we get: A max-register with O(logn) steps per operation A 2-component max-array with O(log 2 n) steps per operation A bounded snapshot object, supporting a polynomial number of update operations, with O(log 3 n) steps per operation 22

Towards an Unbounded Max-Register switch = 0 value 0 value 1 value v value v’ … … … write( v ) switch = 1 read 23

Towards an Unbounded Max-Register switch = 0 value 0 value 1 value v value v’ … … … write( v ) switch = 1 read write( v’ ) switch = 1 write( v’’ ) 24

Randomized Max-Register switch = 0 … … write( v ) switch = 1 m-valued max register 25

Randomized Max-Register switch = 0 … … write( v ) switch = 1 k-bounded increments: value of write ≤ k + value of largest write m-valued max register O(log m + kn/m) = O(log n) steps per write 26 Assumption satisfied in snapshot tree for k=n

Writing to the Max-Register 0 0 … … write( v ) TS: HELP: POINTER: write( v ) pipi v', ts[j]  TS[j] p j (cyclic) i read (random) size n 3 27 read v’ = max(returned value, v)

Reading the Max-Register 0 0 … … read TS: HELP: POINTER: read pipi read (returns v, ts[j]) pjpj read (returns i) +1 (random) size n 3 (logarithmic no. of steps) if ts[j]==TS[j] return v Main argument: many read steps  many fresh values in pointer array, whp Main argument: many read steps  many fresh values in pointer array, whp 28

2-Component Max Array 29 write0( v ) read update first max-register read both max-registers write1( v ) update second max-register

Max Array Implementation switch = 0 value 0 value 1 value v value v’ … … … write0( v ) read 30 Max1 write1( v ) Max1

Randomized 2-Component Max Array switch = 0 … … write( v ) switch = 1 31 Max1 Problem: readers do not travel all the way from root to value Max1 Solution: read Max at root instead of Max at previous location

Summary of the Unbounded Snapshot A randomized max-register with O(logn) steps per operation, with high probability, under the bounded- increments assumption A randomized 2-component max-array with O(log 2 n) steps per operation, with high probability, under the bounded-increments assumption An randomized unbounded snapshot object, supporting a polynomial number of update operations, with O(log 3 n) steps per operation, with high probability 32