Relational Reasoning for Mergeable Replicated Data Types KC - - PowerPoint PPT Presentation

relational reasoning for mergeable replicated data types
SMART_READER_LITE
LIVE PREVIEW

Relational Reasoning for Mergeable Replicated Data Types KC - - PowerPoint PPT Presentation

Relational Reasoning for Mergeable Replicated Data Types KC Sivaramakrishnan joint work with Gowtham Kaki, Swarn Priya, Suresh Jagannathan 1 INTERNET INTERNET INTERNET INTERNET Serializability Linearizability Weak


slide-1
SLIDE 1

Relational Reasoning for Mergeable Replicated Data Types

  • 1

KC Sivaramakrishnan

joint work with

Gowtham Kaki, Swarn Priya, Suresh Jagannathan

slide-2
SLIDE 2
slide-3
SLIDE 3

INTERNET

slide-4
SLIDE 4

INTERNET

slide-5
SLIDE 5

INTERNET

slide-6
SLIDE 6

INTERNET

  • Serializability
  • Linearizability
  • Weak Consistency & Isolation
slide-7
SLIDE 7

When system-level concerns like replication & availability affect application-level design decisions, programming becomes complicated.

slide-8
SLIDE 8

4

slide-9
SLIDE 9

5

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d end

Sequential Counter

slide-10
SLIDE 10
  • Written in idiomatic style
  • Composable

5

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d end type counter_list = Counter.t list

Sequential Counter

slide-11
SLIDE 11

INTERNET

Replicated Counter

slide-12
SLIDE 12

INTERNET

Replicated Counter

slide-13
SLIDE 13

INTERNET

Replicated Counter

slide-14
SLIDE 14

INTERNET

Replicated Counter

slide-15
SLIDE 15

INTERNET

Replicated Counter

slide-16
SLIDE 16

INTERNET

Replicated Counter

+2 2

slide-17
SLIDE 17

INTERNET

Replicated Counter

+2 2

slide-18
SLIDE 18

INTERNET

Replicated Counter

+2 2 +3 3

slide-19
SLIDE 19

INTERNET

Replicated Counter

+2 +3 5 5 5 5

slide-20
SLIDE 20

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

slide-21
SLIDE 21

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7

slide-22
SLIDE 22

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8

+1

slide-23
SLIDE 23

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

slide-24
SLIDE 24

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

24

*3

slide-25
SLIDE 25

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

24 22

*3 +1

slide-26
SLIDE 26

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

24 22

*3 +1 Diverges

slide-27
SLIDE 27

8

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

24 22

*3 +1 Diverges

Addition and multiplication do not commute

slide-28
SLIDE 28

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

slide-29
SLIDE 29

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

  • Capture the effect of multiplication through the commutative

addition operation

slide-30
SLIDE 30

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7

  • Capture the effect of multiplication through the commutative

addition operation

slide-31
SLIDE 31

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8

+1

  • Capture the effect of multiplication through the commutative

addition operation

slide-32
SLIDE 32

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

  • Capture the effect of multiplication through the commutative

addition operation

slide-33
SLIDE 33

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

22

+14

  • Capture the effect of multiplication through the commutative

addition operation

slide-34
SLIDE 34

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

22 22

+14 +1

  • Capture the effect of multiplication through the commutative

addition operation

slide-35
SLIDE 35

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

22 22

+14 +1 Converges

  • Capture the effect of multiplication through the commutative

addition operation

slide-36
SLIDE 36

9

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n end

7 8 21

+1 *3

22 22

+14 +1 Converges

  • Capture the effect of multiplication through the commutative

addition operation

  • CRDTs
slide-37
SLIDE 37

Conflict-free Replicated Data Types (CRDT)

10

slide-38
SLIDE 38

Conflict-free Replicated Data Types (CRDT)

  • CRDT is guaranteed to ensure strong eventual consistency (SEC)

★ G-counters, PN-counters, OR-Sets, Graphs, Ropes, docs, sheets ★ Simple interface for the clients of CRDTs 10

slide-39
SLIDE 39

Conflict-free Replicated Data Types (CRDT)

  • CRDT is guaranteed to ensure strong eventual consistency (SEC)

★ G-counters, PN-counters, OR-Sets, Graphs, Ropes, docs, sheets ★ Simple interface for the clients of CRDTs

  • Need to reengineer every datatype to ensure SEC

(commutativity)

★ Do not mirror sequential counter parts => implementation & proof

burden

★ Do not compose!

counter set is not a composition of counter and set CRDTs

10

slide-40
SLIDE 40

Can we program & reason about replicated data types as an extension of their sequential counterparts?

slide-41
SLIDE 41

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

slide-42
SLIDE 42

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7

slide-43
SLIDE 43

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7 8

+1

slide-44
SLIDE 44

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7 8 21

+1 *3

slide-45
SLIDE 45

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7 8 21

+1 *3

22

slide-46
SLIDE 46

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7 8 21

+1 *3

22 22

slide-47
SLIDE 47

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7 8 21

+1 *3

22 22

22 = 7 + (8-1) + (21 -7)

slide-48
SLIDE 48

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7 8 21

+1 *3

22 22

22 = 7 + (8-1) + (21 -7)

  • 3-way merge function makes the counter suitable for distribution
slide-49
SLIDE 49

12

module Counter : sig type t val read : t -> int val add : t -> int -> t val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end

7 8 21

+1 *3

22 22

22 = 7 + (8-1) + (21 -7)

  • 3-way merge function makes the counter suitable for distribution
  • Does not appeal to individual operations => independently

extend data-type

slide-50
SLIDE 50

13

Systems ➞ PL

slide-51
SLIDE 51

13

Systems ➞ PL

  • CRDTs need to take care of

systems level concerns such as exactly once delivery

slide-52
SLIDE 52

13

Systems ➞ PL

  • CRDTs need to take care of

systems level concerns such as exactly once delivery

  • 3-way merge handles it

automatically

slide-53
SLIDE 53

13

7 8 21

+1 *3

22 22

Systems ➞ PL

  • CRDTs need to take care of

systems level concerns such as exactly once delivery

  • 3-way merge handles it

automatically

slide-54
SLIDE 54

??

13

7 8 21

+1 *3

22 22

Systems ➞ PL

  • CRDTs need to take care of

systems level concerns such as exactly once delivery

  • 3-way merge handles it

automatically

slide-55
SLIDE 55

??

13

7 8 21

+1 *3

22 22 22

22 = 21 + (21-21) + (22 -21)

Systems ➞ PL

  • CRDTs need to take care of

systems level concerns such as exactly once delivery

  • 3-way merge handles it

automatically

slide-56
SLIDE 56

Does the 3-way merge idea generalise?

slide-57
SLIDE 57

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

slide-58
SLIDE 58

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

  • Try replicating queues by asynchronously transmitting operations
slide-59
SLIDE 59

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2]

  • Try replicating queues by asynchronously transmitting operations
slide-60
SLIDE 60

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2]

pop() 1

  • Try replicating queues by asynchronously transmitting operations
slide-61
SLIDE 61

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2]

pop() 1 pop() 1

  • Try replicating queues by asynchronously transmitting operations
slide-62
SLIDE 62

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ]

pop() 1 pop() 1 pop()

  • Try replicating queues by asynchronously transmitting operations
slide-63
SLIDE 63

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ] [ ]

pop() 1 pop() 1 pop() pop()

  • Try replicating queues by asynchronously transmitting operations
slide-64
SLIDE 64

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ] [ ]

pop() 1 pop() 1 pop() pop()

  • Convergence is not sufficient; Intent is not preserved
  • Try replicating queues by asynchronously transmitting operations
slide-65
SLIDE 65

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ] [ ]

pop() 1 pop() 1 pop() pop()

  • Convergence is not sufficient; Intent is not preserved

[1]

  • Try replicating queues by asynchronously transmitting operations
slide-66
SLIDE 66

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ] [ ]

pop() 1 pop() 1 pop() pop()

  • Convergence is not sufficient; Intent is not preserved

[1] [1,2]

push(2)

  • Try replicating queues by asynchronously transmitting operations
slide-67
SLIDE 67

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ] [ ]

pop() 1 pop() 1 pop() pop()

  • Convergence is not sufficient; Intent is not preserved

[1] [1,2] [1,3]

push(2) push(3)

  • Try replicating queues by asynchronously transmitting operations
slide-68
SLIDE 68

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ] [ ]

pop() 1 pop() 1 pop() pop()

  • Convergence is not sufficient; Intent is not preserved

[1] [1,2] [1,3] [1,2,3]

push(2) push(3) push(3)

  • Try replicating queues by asynchronously transmitting operations
slide-69
SLIDE 69

15

module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end

[1,2] [2] [2] [ ] [ ]

pop() 1 pop() 1 pop() pop()

  • Convergence is not sufficient; Intent is not preserved

[1] [1,2] [1,3] [1,2,3] [1,3,2]

push(2) push(3) push(3) push(2)

  • Try replicating queues by asynchronously transmitting operations
slide-70
SLIDE 70

Concretising Intent

16

slide-71
SLIDE 71

Concretising Intent

  • Intent is a woolly term

★ How can we formalise the intent of operations on a data

structure?

16

slide-72
SLIDE 72

Concretising Intent

  • Intent is a woolly term

★ How can we formalise the intent of operations on a data

structure?

16

l v1 v2 v

slide-73
SLIDE 73

Concretising Intent

  • Intent is a woolly term

★ How can we formalise the intent of operations on a data

structure?

  • For a replicated queue,

16

l v1 v2 v

slide-74
SLIDE 74

Concretising Intent

  • Intent is a woolly term

★ How can we formalise the intent of operations on a data

structure?

  • For a replicated queue,
  • 1. Any element popped in either v1 or v2 does not remain in v

16

l v1 v2 v

slide-75
SLIDE 75

Concretising Intent

  • Intent is a woolly term

★ How can we formalise the intent of operations on a data

structure?

  • For a replicated queue,
  • 1. Any element popped in either v1 or v2 does not remain in v
  • 2. Any element pushed into either v1 or v2 appears in v

16

l v1 v2 v

slide-76
SLIDE 76

Concretising Intent

  • Intent is a woolly term

★ How can we formalise the intent of operations on a data

structure?

  • For a replicated queue,
  • 1. Any element popped in either v1 or v2 does not remain in v
  • 2. Any element pushed into either v1 or v2 appears in v
  • 3. An element that remains untouched in l, v1, v2 remains in v

16

l v1 v2 v

slide-77
SLIDE 77

Concretising Intent

  • Intent is a woolly term

★ How can we formalise the intent of operations on a data

structure?

  • For a replicated queue,
  • 1. Any element popped in either v1 or v2 does not remain in v
  • 2. Any element pushed into either v1 or v2 appears in v
  • 3. An element that remains untouched in l, v1, v2 remains in v
  • 4. Order of pairs of elements in l, v1, v2 must be preserved in

m, if those elements are present in v.

16

l v1 v2 v

slide-78
SLIDE 78

Relational Specification

17

slide-79
SLIDE 79

Relational Specification

  • Let’s define relations Rmem and Rob to capture membership and
  • rdering

★ Rmem [1,2,3] = {1,2,3} ★ Rob [1,2,3] = { (1,2), (1,3), (2,3) }

17

slide-80
SLIDE 80

Relational Specification

  • Let’s define relations Rmem and Rob to capture membership and
  • rdering

★ Rmem [1,2,3] = {1,2,3} ★ Rob [1,2,3] = { (1,2), (1,3), (2,3) }

17

l v1 v2 v

slide-81
SLIDE 81

Relational Specification

  • Let’s define relations Rmem and Rob to capture membership and
  • rdering

★ Rmem [1,2,3] = {1,2,3} ★ Rob [1,2,3] = { (1,2), (1,3), (2,3) }

17

l v1 v2 v

slide-82
SLIDE 82

Relational Specification

  • Let’s define relations Rmem and Rob to capture membership and
  • rdering

★ Rmem [1,2,3] = {1,2,3} ★ Rob [1,2,3] = { (1,2), (1,3), (2,3) }

1.Any element popped in either v1 or v2 does not remain in v

17

l v1 v2 v

slide-83
SLIDE 83

Relational Specification

  • Let’s define relations Rmem and Rob to capture membership and
  • rdering

★ Rmem [1,2,3] = {1,2,3} ★ Rob [1,2,3] = { (1,2), (1,3), (2,3) }

1.Any element popped in either v1 or v2 does not remain in v

  • 2. Any element pushed into either v1 or v2 appears in v

17

l v1 v2 v

slide-84
SLIDE 84

Relational Specification

  • Let’s define relations Rmem and Rob to capture membership and
  • rdering

★ Rmem [1,2,3] = {1,2,3} ★ Rob [1,2,3] = { (1,2), (1,3), (2,3) }

1.Any element popped in either v1 or v2 does not remain in v

  • 2. Any element pushed into either v1 or v2 appears in v
  • 3. An element that remains untouched in l, v1, v2 remains in v

17

l v1 v2 v

slide-85
SLIDE 85

Relational Specification

18

l v1 v2 v

slide-86
SLIDE 86

Relational Specification

18

l v1 v2 v

  • RHS has to be confined to Rmem(v) x Rmem(v) since certain
  • rders might be missing

★ Consider l = [0], v1= [0,1], v2 = [ ], v = [1]

slide-87
SLIDE 87

Relational Specification

18

l v1 v2 v

  • RHS has to be confined to Rmem(v) x Rmem(v) since certain
  • rders might be missing

★ Consider l = [0], v1= [0,1], v2 = [ ], v = [1]

  • RHS is an underspecification since orders between concurrent

insertions will only be present in Rob(v)

★ Consider l = [ ], v1= [0], v2 = [1], v = [0,1]

slide-88
SLIDE 88

19

slide-89
SLIDE 89

19

[1,2]

Rmem = {1,2} Rob = { (1,2) }

slide-90
SLIDE 90

19

[1,2] [2]

pop() 1

Rmem = {1,2} Rob = { (1,2) } Rmem = {2} Rob = { }

slide-91
SLIDE 91

19

[1,2] [2] [2]

pop() 1 pop() 1

Rmem = {1,2} Rob = { (1,2) } Rmem = {2} Rob = { } Rmem = {2} Rob = { }

slide-92
SLIDE 92

19

[1,2] [2] [2] [2] [2]

pop() 1 pop() 1

Rmem = {1,2} Rob = { (1,2) } Rmem = {2} Rob = { } Rmem = {2} Rob = { } Rmem = {2} Rob = { } Rmem = {2} Rob = { }

slide-93
SLIDE 93

20

slide-94
SLIDE 94

20

[1]

Rmem = {1} Rob = { }

slide-95
SLIDE 95

20

[1] [1,2]

push(2)

Rmem = {1} Rob = { } Rmem = {1,2} Rob = { (1,2) }

slide-96
SLIDE 96

20

[1] [1,2] [1,3]

push(2) push(3)

Rmem = {1} Rob = { } Rmem = {1,2} Rob = { (1,2) } Rmem = {1,3} Rob = { (1,3) }

slide-97
SLIDE 97

20

[1] [1,2] [1,3]

push(2) push(3)

Rmem = {1} Rob = { } Rmem = {1,2} Rob = { (1,2) } Rmem = {1,3} Rob = { (1,3) }

Use < as an arbitration function between concurrent insertions

slide-98
SLIDE 98

20

[1] [1,2] [1,3] [1,2,3] [1,3,2]

push(2) push(3)

Rmem = {1} Rob = { } Rmem = {1,2} Rob = { (1,2) } Rmem = {1,3} Rob = { (1,3) } Rmem = {1,2,3} Rob = { (1,2), (1,3), (2,3) } Rmem = {1,2,3} Rob = { (1,2), (1,3). (2,3) }

Use < as an arbitration function between concurrent insertions

slide-99
SLIDE 99

Characteristic Relations

21

A sequence of relations RT is called a characteristic relation

  • f a data type T, if for every x : T and y : T, RT (x) = RT (y) iff

x and y are extensionally equal as interpreted under T.

slide-100
SLIDE 100
  • Rmem and Rob are the characteristic relations of queue

Characteristic Relations

21

A sequence of relations RT is called a characteristic relation

  • f a data type T, if for every x : T and y : T, RT (x) = RT (y) iff

x and y are extensionally equal as interpreted under T.

slide-101
SLIDE 101
  • Rmem and Rob are the characteristic relations of queue
  • Appeals only to the sequential properties of the data type

★ Ignore distribution when defining characteristic relations.

Characteristic Relations

21

A sequence of relations RT is called a characteristic relation

  • f a data type T, if for every x : T and y : T, RT (x) = RT (y) iff

x and y are extensionally equal as interpreted under T.

slide-102
SLIDE 102

Synthesizing Merge

22

slide-103
SLIDE 103

Synthesizing Merge

  • Semantics of merge in relational domain is quite standard

across data types

22

slide-104
SLIDE 104

Synthesizing Merge

  • Semantics of merge in relational domain is quite standard

across data types

★ Can we synthesise merge functions for arbitrary data type? 22

slide-105
SLIDE 105

Synthesizing Merge

  • Semantics of merge in relational domain is quite standard

across data types

★ Can we synthesise merge functions for arbitrary data type? 22

slide-106
SLIDE 106

Synthesizing Merge

  • Semantics of merge in relational domain is quite standard

across data types

★ Can we synthesise merge functions for arbitrary data type? 22

Abstraction function

slide-107
SLIDE 107

Synthesizing Merge

  • Semantics of merge in relational domain is quite standard

across data types

★ Can we synthesise merge functions for arbitrary data type? 22

Abstraction function Concretisation function

slide-108
SLIDE 108

Synthesizing Merge

  • Semantics of merge in relational domain is quite standard

across data types

★ Can we synthesise merge functions for arbitrary data type? 22

Abstraction function Concretisation function Synthesize (goal)

slide-109
SLIDE 109

Synthesizing Merge

  • Semantics of merge in relational domain is quite standard

across data types

★ Can we synthesise merge functions for arbitrary data type? 22

Abstraction function Concretisation function

Directed synthesis using the type of the characteristic relations

Synthesize (goal)

slide-110
SLIDE 110

Abstraction Function: Queue

23

slide-111
SLIDE 111

Abstraction Function: Queue

23

slide-112
SLIDE 112

Abstraction Function: Queue

23

slide-113
SLIDE 113

Abstraction Function: Queue

23

slide-114
SLIDE 114

Abstraction Function: Queue

23

slide-115
SLIDE 115

Abstraction Function: Binary Tree

24

slide-116
SLIDE 116

Abstraction Function: Binary Tree

24

slide-117
SLIDE 117

Abstraction Function: Binary Tree

24

slide-118
SLIDE 118

Abstraction Function: Binary Heap

25

slide-119
SLIDE 119

Abstraction Function: Binary Heap

25

slide-120
SLIDE 120

26

slide-121
SLIDE 121

Compositionality: Pair

27

slide-122
SLIDE 122

Compositionality: Pair

  • The merge of a pair is the merge of the corresponding

constituents

27

slide-123
SLIDE 123

Compositionality: Pair

  • The merge of a pair is the merge of the corresponding

constituents

  • A pair data type is defined by the relations:

27

slide-124
SLIDE 124

Compositionality: Pair

  • The merge of a pair is the merge of the corresponding

constituents

  • A pair data type is defined by the relations:
  • Assume that the pair is composed of 2 counters. The counter

merge spec is:

27

slide-125
SLIDE 125

Compositionality: Pair

  • The merge of a pair is the merge of the corresponding

constituents

  • A pair data type is defined by the relations:
  • Assume that the pair is composed of 2 counters. The counter

merge spec is:

  • Then, pair merge spec is:

27

slide-126
SLIDE 126

Generalising Pairs to Ordinates

28

slide-127
SLIDE 127

Generalising Pairs to Ordinates

  • An alternative characteristic relation for a pair is:

28

slide-128
SLIDE 128

Generalising Pairs to Ordinates

  • An alternative characteristic relation for a pair is:

28

slide-129
SLIDE 129

Generalising Pairs to Ordinates

  • An alternative characteristic relation for a pair is:
  • Corresponding merge specification is:

28

slide-130
SLIDE 130

Generalising Pairs to Ordinates

  • An alternative characteristic relation for a pair is:
  • Corresponding merge specification is:

28

slide-131
SLIDE 131

Generalising Pairs to Ordinates

  • An alternative characteristic relation for a pair is:
  • Corresponding merge specification is:
  • Given appropriate characteristic relation for a n-tuple (Rn-tuple),

the same merge specification can be used.

28

slide-132
SLIDE 132

Generalising Pairs to Ordinates

  • Similar encoding can be given to maps with non-mergeable

types as keys and mergeable types as values

29

slide-133
SLIDE 133

Types of Characteristic Relations

30

slide-134
SLIDE 134

Types of Characteristic Relations

  • Practical characteristic relations fall into 3 types:

30

slide-135
SLIDE 135

Types of Characteristic Relations

  • Practical characteristic relations fall into 3 types:

★ Membership (Rmem) 30

R : {v : T} → P

  • T
  • , where T is a non-mergeable type
slide-136
SLIDE 136

Types of Characteristic Relations

  • Practical characteristic relations fall into 3 types:

★ Membership (Rmem) ★ Ordering (Rob, Rans, Rto)

where 𝜍 is a sequence of non-mergeable types and other relations, which flattens to a sequence of non-mergeable types

30

R : {v : T} → P

  • T
  • , where T is a non-mergeable type

R : {v : T} → P (ρ)

slide-137
SLIDE 137

Types of Characteristic Relations

  • Practical characteristic relations fall into 3 types:

★ Membership (Rmem) ★ Ordering (Rob, Rans, Rto)

where 𝜍 is a sequence of non-mergeable types and other relations, which flattens to a sequence of non-mergeable types

★ Ordinates (Rpair, Rkv) 30

R : {v : T} → P

  • T
  • , where T is a non-mergeable type

R : {v : T} → P (ρ)

R : {v : T} → P

  • T × τ
  • , where τ is a mergeable type
slide-138
SLIDE 138

Deriving merge spec

31

slide-139
SLIDE 139

Deriving merge spec

  • Not complete, but practical
  • Can derive merge spec for

★ Data structures: Set, Heap, Graph, Queue, TreeDoc ★ Larger apps: TPC-C, TPC-E, Twissandra, Rubis

31

slide-140
SLIDE 140

Distributed Implementation

32

slide-141
SLIDE 141

Distributed Implementation

  • For making this programming model practical, we need to:

★ Quickly compute LCA ★ Optimise storage through sharing ★ Optimise network transmissions (state based merge)

32

slide-142
SLIDE 142

Distributed Implementation

  • For making this programming model practical, we need to:

★ Quickly compute LCA ★ Optimise storage through sharing ★ Optimise network transmissions (state based merge)

  • Irmin

★ A reimplementation of Git in pure OCaml ★ Arbitrary OCaml objects, not just files + User-defined 3-way merges ★ Only transmit diffs over the network ★ Multiple storage backends including in-memory, filesystems, log-structured-

merge database, distributed databases

32

slide-143
SLIDE 143

Performance

33

slide-144
SLIDE 144

Performance

  • What is the size of diff compared to the size of data structure?

33

slide-145
SLIDE 145

Performance

  • What is the size of diff compared to the size of data structure?
  • Setup

★ 2 Replicas, fixed number of rounds, each round has N operations ★ 75% inserts, 25% deletions ★ Synchronise after each round 33

slide-146
SLIDE 146

Performance

  • What is the size of diff compared to the size of data structure?
  • Setup

★ 2 Replicas, fixed number of rounds, each round has N operations ★ 75% inserts, 25% deletions ★ Synchronise after each round 33

Binary Heap Growable Array

slide-147
SLIDE 147

Thanks for listening!

34