Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Atomic snapshots in O(log³ n) steps 1

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

3 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

4 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)

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

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

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

8 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

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

10 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 0 0 1 1 =1 ReadMax = ? switch=0 : return 0 switch=1 : return 1

11 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

12 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)

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

14 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

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

16 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

17 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 100 4. p 3 read 0 5. p 2 write( 100 ) 6. p 1 read 100 p 1 returns (0,100) p 3 returns (100,0)

18 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 100 4. p 3 read 0 5. p 2 write( 100 ) 6. p 1 read 100

19 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 = ?

20 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

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

22 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

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

24 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

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

26 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

27 Writing to the Max-Register 0 0 … … write( v ) 1 1 1 1 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)

28 Reading the Max-Register 0 0 … … read 1 1 1 1 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

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

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

31 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

32 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


Download ppt "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."

Similar presentations


Ads by Google