avoiding coordination announcements o ffi ce hours
play

Avoiding Coordination Announcements O ffi ce Hours No office hours - PowerPoint PPT Presentation

Avoiding Coordination Announcements O ffi ce Hours No office hours on 11/15: I am not here. No office hours on 11/22: Everyone should be out having and . No office hours on 11/29: I am not here. E-mail me if you want to


  1. Avoiding Coordination

  2. Announcements

  3. O ffi ce Hours • No office hours on 11/15: I am not here. • No office hours on 11/22: Everyone should be out having 🥨 and 🦄 . • No office hours on 11/29: I am not here. • E-mail me if you want to meet/need help. • Probably going to be over Skype or some such medium. • Or in person on 11/26 or 11/27.

  4. Final Project • Hopefully everyone has started... • ... at least thinking about the project. • Remember: no extensions or late days -- must receive final report on Dec 12.

  5. Onto Science...

  6. So Far... • Looked at mechanisms to achieve consensus, get machines to work together. • A few different algorithms, a few different failure conditions. • Powerful primitive: can replicate any deterministic state machine. • Don't even need to implement or understand consensus to do this. • Powerful abstraction: replicate most programs, get fault tolerance.

  7. So Far... • But everything is not rosy: • Configure and initialize system for correctness. • Need to communicate and wait before responding to any request. • Can we do better?

  8. Yes ‽

  9. Self Stabilizing Algorithms

  10. Setting • Treat program as transition machine.

  11. Setting • Treat program as transition machine. • Where some states are good.

  12. Setting • Treat program as transition machine. • Where some states are good. • All transitions from good states go to good.

  13. Setting • Treat program as transition machine. • Where some states are good. • All transitions from good states go to good. • Self-stabilization: • From any state arrive at good state. • In bounded steps.

  14. Setting • Treat program as transition machine. • Where some states are good. • All transitions from good states go to good. • Self-stabilization: • From any state arrive at good state. • In bounded steps.

  15. Djikstra's Example • Mutual exclusion: only one process gets to write (or compute) at a time. x 0 0 x 1 4 1 x 4 3 2 x 2 x 3

  16. Djikstra's Example • Mutual exclusion: only one process gets to write (or compute) at a time. At process 0 do { if (x 4 == x 0 ) { x 0 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 4 1 x 4 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 x 3 } } while (true);

  17. Djikstra's Example • When and why can this provide mutual exclusion? At process 0 do { if (x 4 == x 0 ) { x 0 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 4 1 x 4 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 x 3 } } while (true);

  18. Djikstra's Example At process 0 do { if (x 4 == x 0 ) { x 0 =1 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 =1 4 1 x 4 =1 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 =1 x 3 =1 } } while (true);

  19. Djikstra's Example At process 0 do { if (x 4 == x 0 ) { x 0 =2 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 =1 4 1 x 4 =1 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 =1 x 3 =1 } } while (true);

  20. Djikstra's Example At process 0 do { if (x 4 == x 0 ) { x 0 =2 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 =2 4 1 x 4 =1 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 =1 x 3 =1 } } while (true);

  21. Djikstra's Example At process 0 do { if (x 4 == x 0 ) { x 0 =2 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 =2 4 1 x 4 =1 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 =2 x 3 =1 } } while (true);

  22. Djikstra's Example At process 0 do { if (x 4 == x 0 ) { x 0 =2 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 =2 4 1 x 4 =2 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 =2 x 3 =2 } } while (true);

  23. Djikstra's Example What happens with random initial values? At process 0 do { if (x 4 == x 0 ) { x 0 =1 x 0 = (x 0 + 1) % 5; 0 } } while (true); x 1 =2 4 1 x 4 =0 At process n do { 3 2 if (x n != x n-1 ) { x n = x n-1 ; x 2 =3 x 3 =4 } } while (true);

  24. Djikstra's Example x 0 =1 0 x 1 =2 1 4 x 4 =0 3 2 • Assuming a fair execution. x 2 =3 x 3 =4 • Lemma 1 : At least every n rounds x 0 changes its value. At process 0 do { if (x 4 == x 0 ) { • Round here is every processor got a chance to run. x 0 = (x 0 + 1) % 5; } } while (true); At process n • Why? do { if (x n != x n-1 ) { x n = x n-1 ; } } while (true);

  25. Djikstra's Example x 0 =1 0 x 1 =2 1 4 x 4 =0 3 2 • Assuming a fair execution. x 2 =3 x 3 =4 • Lemma 1 : At least every n rounds x 0 changes its value. At process 0 do { if (x 4 == x 0 ) { • Lemma 2 : There is some value c in 0..(n+1) s.t. x i ≠ c ∀ i x 0 = (x 0 + 1) % 5; } } while (true); At process n • Why? do { if (x n != x n-1 ) { x n = x n-1 ; } } while (true);

  26. Djikstra's Example x 0 =1 0 x 1 =2 1 4 x 4 =0 • Assuming a fair execution. 3 2 x 2 =3 x 3 =4 • Lemma 1 : At least every n rounds x 0 changes its value. At process 0 do { • Lemma 2 : There is some value c in 0..(n+1) s.t. x i ≠ c ∀ i if (x 4 == x 0 ) { x 0 = (x 0 + 1) % 5; } • Theorem : Get to all x i s being equal in O(n 2 ) rounds. } while (true); At process n do { • Why? if (x n != x n-1 ) { x n = x n-1 ; } } while (true);

  27. Other Self Stabilizing Algorithms?

  28. Finding a Minimal Spanning Tree

  29. Thoughts on how?

  30. Finding a Minimal Spanning Tree At root do { for n in nbr { send(n, <d=0, parent=false>) } } d=0 } while (true); At process n do { n[i], parent = recv(nbr i) d = min(n) parent = find(i s.t. n[i] = d-1) send(parent, <d=d, parent=true>) for n in nbr { if n!= parent { send(n, <d = d, parent=false>) } } } while (true);

  31. Finding a Minimal Spanning Tree d=8 d=0 Why does this work? d=100 d=22

  32. Finding a Minimal Spanning Tree d=1 d=8 d=2 d=0 Why does this work? d=100 d=3 d=22 d=2 d=1 d=2 d=23

  33. Maximal Matching

  34. How?

  35. partner = null do { broadcast(id, partner) collect partners for id if partner = null and exists j s.t. partners[j]=id { partner = j } if partner = null and exists j s.t. partners[j] = null { partner = j } if partner = j and partners[j] != id { partner = null } } while (true);

  36. Why?

  37. CRDTs

  38. Revisiting RSMs Application Application Application Application Ordering Ordering Ordering Ordering Client Client Client Client

  39. What if we didn't care about ordering Application Application Application Application Gossip Gossip Gossip Gossip Client Client Client Client

  40. Challenge: Ensuring correctness despite reordering

  41. Challenge m(A, m(Z, m(A, m(Z, m(Y,m(Z, X))) m(A,m(X, Y))) m(X,m(Y, Z))) m(Y, m(X, A))) m(Y,m(X, A)) m(Y,m(Z, X)) m(A,m(X, Y)) m(X,m(Y, Z)) merge(X, A) merge(Z, X) merge(X, Y) merge(Y, Z) A X Y Z Peer 3 Peer 0 Peer 1 Peer 2

  42. Challenge m(A, m(Z, m(A, m(Z, m(Y,m(Z, X))) m(A,m(X, Y))) m(X,m(Y, Z))) m(Y, m(X, A))) m(Y,m(X, A)) m(Y,m(Z, X)) m(A,m(X, Y)) m(X,m(Y, Z)) merge(X, A) Need all of these to be equal. merge(Z, X) merge(X, Y) merge(Y, Z) A X Y Z Peer 3 Peer 0 Peer 1 Peer 2

  43. Modelling a Merge Function • Treat updates as a set. • For previous example {A, X, Y, Z} • Define merge function to be the least upper bound (similar to supremum). • Commutative, associative and idempotent. • Thus LUB(A, LUB(X, LUB(Y, Z)))) = LUB(X, LUB(A, LUB(Y, Z)))) = ... • In abstract algebra posets with LUBs are called semilattices.

  44. Is this enough?

  45. Modelling a Merge Function • Sufficient for consistency. • Not sufficient to make sure all semantics are preserved. • In particular picking the least upper bound might loose operations.

  46. Counters x = [0, 0, 0] x = [0, 0, 0] x = [1, 0, 0] x = [0, 0, 0] x = [0, 0, -1] + - Peer 0 Peer 1 Peer 3 Suppose we use element wise max as LUB. Is element wise max a LUB?

  47. Counters x = [1, 0, 0] x = [1, 0, 0] x = [1, 0, 0] x = LUB([1, 0, 0], x = LUB([1, 0, 0], x = LUB([1, 0, 0], [0,0,0], [0,0,0], [0,0,0], [0,0, -1]) [0,0, -1]) [0,0, -1]) + - Peer 0 Peer 1 Peer 3 Suppose we use element wise max as LUB. Is element wise max a LUB?

  48. Modelling a Merge Function • Need it to be a least upper bound for the state which is a semilattice. • Need LUB to be monotonic. • Each application preserves more information.

  49. Build a Collaborative Editor using CRDTs

  50. worst It was the best of times, it was the poohest of times, it was the age of very wisdom, it was the age of foolishness, it was the epoch of credulity, it was the epoch of incredulity, it was the season of Light, it was the belief season of Darkness

  51. i t _ w a s _ t h e _ p o o h e s t _

  52. r w i t _ w a s _ t h e _ p o o h e s t _ _ v e r y

  53. Sometimes it fails.

  54. What consistency guarantees do both of today's mechanisms provide?

  55. When are these good?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend