Slide 1

Slide 1 text

Bloom: A Language For Disorderly Distributed Programming Christopher Meiklejohn Wicked Good Ruby ’13 Sunday, October 13, 13

Slide 2

Slide 2 text

cmeiklejohn / @cmeik My Name is My Name Sunday, October 13, 13

Slide 3

Slide 3 text

What do you do? Sunday, October 13, 13

Slide 4

Slide 4 text

Sunday, October 13, 13

Slide 5

Slide 5 text

Sunday, October 13, 13

Slide 6

Slide 6 text

Sunday, October 13, 13

Slide 7

Slide 7 text

What did you do? Sunday, October 13, 13

Slide 8

Slide 8 text

Sunday, October 13, 13

Slide 9

Slide 9 text

Sunday, October 13, 13

Slide 10

Slide 10 text

UC Berkeley Sunday, October 13, 13

Slide 11

Slide 11 text

BOOM Sunday, October 13, 13

Slide 12

Slide 12 text

The Outline Sunday, October 13, 13

Slide 13

Slide 13 text

Theory, language. The Outline Sunday, October 13, 13

Slide 14

Slide 14 text

von Neumann Sunday, October 13, 13

Slide 15

Slide 15 text

Instructions, mutable state, executed in order. von Neumann Sunday, October 13, 13

Slide 16

Slide 16 text

Imposes a total order. von Neumann Sunday, October 13, 13

Slide 17

Slide 17 text

Disorderly actors Sunday, October 13, 13

Slide 18

Slide 18 text

Allow disorder and races; illusion of total order. Disorderly actors Sunday, October 13, 13

Slide 19

Slide 19 text

The idea behind transactions; serializability. Disorderly actors Sunday, October 13, 13

Slide 20

Slide 20 text

Tricky to scale. Disorderly actors Sunday, October 13, 13

Slide 21

Slide 21 text

Scaling Sunday, October 13, 13

Slide 22

Slide 22 text

Multiple machines; sharing computation. Scaling Sunday, October 13, 13

Slide 23

Slide 23 text

CAP Theorem Sunday, October 13, 13

Slide 24

Slide 24 text

Consistency, availability, partition tolerance. CAP Theorem Sunday, October 13, 13

Slide 25

Slide 25 text

Negative result: linearizability impossible. CAP Theorem Sunday, October 13, 13

Slide 26

Slide 26 text

Whoa, Theory! Sunday, October 13, 13

Slide 27

Slide 27 text

Distributed computing Sunday, October 13, 13

Slide 28

Slide 28 text

The “new normal”. Distributed computing Sunday, October 13, 13

Slide 29

Slide 29 text

Order is di!cult to impose. Distributed computing Sunday, October 13, 13

Slide 30

Slide 30 text

Synchronization; coordination. Distributed computing Sunday, October 13, 13

Slide 31

Slide 31 text

FLP result; delays, partitions, partial writes. Distributed computing Sunday, October 13, 13

Slide 32

Slide 32 text

Inverse methods; commutative operations. Distributed computing Sunday, October 13, 13

Slide 33

Slide 33 text

ACID 2.0 Sunday, October 13, 13

Slide 34

Slide 34 text

Associativity, commutativity, idempotence. ACID 2.0 Sunday, October 13, 13

Slide 35

Slide 35 text

(X · Y) · Z = X · (Y · Z) ACID 2.0: Associativity Sunday, October 13, 13

Slide 36

Slide 36 text

X · Y = Y · X ACID 2.0: Commutativity Sunday, October 13, 13

Slide 37

Slide 37 text

X · X = X ACID 2.0: Idempotence Sunday, October 13, 13

Slide 38

Slide 38 text

Associativity, commutativity, idempotence. ACID 2.0 Sunday, October 13, 13

Slide 39

Slide 39 text

Familiar? Sunday, October 13, 13

Slide 40

Slide 40 text

Bounded Join Semilattices Sunday, October 13, 13

Slide 41

Slide 41 text

Partially ordered set; least upper bound; ACI. Bounded Join Semilattices Sunday, October 13, 13

Slide 42

Slide 42 text

Objects grow over time; merge computes LUB. Bounded Join Semilattices Sunday, October 13, 13

Slide 43

Slide 43 text

Monotonic and con"uent; convergent. Bounded Join Semilattices Sunday, October 13, 13

Slide 44

Slide 44 text

Map into another via monotone functions. Bounded Join Semilattices Sunday, October 13, 13

Slide 45

Slide 45 text

Examples. Bounded Join Semilattices Sunday, October 13, 13

Slide 46

Slide 46 text

b a c a, b a, c a, b, c Set; merge function: union. b, c Sunday, October 13, 13

Slide 47

Slide 47 text

3 5 7 5 7 7 Increaing natual; merge function: max. Sunday, October 13, 13

Slide 48

Slide 48 text

F F T F T T Booleans; merge function: or. Sunday, October 13, 13

Slide 49

Slide 49 text

x <= y montone f(x) <= f(y) Sunday, October 13, 13

Slide 50

Slide 50 text

Sunday, October 13, 13

Slide 51

Slide 51 text

CvRDT examples. Sunday, October 13, 13

Slide 52

Slide 52 text

[ [{1, a}], [] ] [ [{1, a}], [] ] Sunday, October 13, 13

Slide 53

Slide 53 text

[ [{1, a}], [] ] [ [{1, a}], [] ] [ [{1, a}], [{1, a}] ] [ [{1, a}], [{1, a}] ] Sunday, October 13, 13

Slide 54

Slide 54 text

[ [{1, a}], [] ] [ [{1, a}], [] ] [ [{1, a}], [{1, a}] ] [ [{1, a}], [{1, a}] ] [ [{1, a}, {2, a}], [{1, a}] ] Sunday, October 13, 13

Slide 55

Slide 55 text

[ [{1, a}], [] ] [ [{1, a}], [] ] [ [{1, a}], [{1, a}] ] [ [{1, a}], [{1, a}] ] [ [{1, a}, {2, a}], [{1, a}] ] [ [{1, a}, {2, a}], [{1, a}] ] Sunday, October 13, 13

Slide 56

Slide 56 text

[ [{1, a}], [] ] [ [{1, a}], [] ] Sunday, October 13, 13

Slide 57

Slide 57 text

[ [{1, a}], [] ] [ [{1, a}], [] ] [ [{1, a}, {2, b}], [] ] Sunday, October 13, 13

Slide 58

Slide 58 text

[ [{1, a}], [] ] [ [{1, a}], [] ] [ [{1, a}, {2, b}], [] ] [ [{1, a}], [{1, a}] ] Sunday, October 13, 13

Slide 59

Slide 59 text

[ [{1, a}], [] ] [ [{1, a}], [] ] [ [{1, a}, {2, b}], [] ] [ [{1, a}], [{1, a}] ] [ [{1, a}, {2, b}], [{1, a}] ] Sunday, October 13, 13

Slide 60

Slide 60 text

Just data; what about computation? Bounded Join Semilattices Sunday, October 13, 13

Slide 61

Slide 61 text

Composability desired. Bounded Join Semilattices Sunday, October 13, 13

Slide 62

Slide 62 text

CALM Theorem Sunday, October 13, 13

Slide 63

Slide 63 text

Consistency as Logical Monotonicity CALM Theorem Sunday, October 13, 13

Slide 64

Slide 64 text

Consistent given async; all monotone functions. CALM Theorem Sunday, October 13, 13

Slide 65

Slide 65 text

Identify non-monotone functions. CALM Theorem Sunday, October 13, 13

Slide 66

Slide 66 text

Disorderly Programming Sunday, October 13, 13

Slide 67

Slide 67 text

Order-independent, explicit order-dependent. Disorderly Programming Sunday, October 13, 13

Slide 68

Slide 68 text

Prototype language: Bloom Disorderly Programming Sunday, October 13, 13

Slide 69

Slide 69 text

Bloom Sunday, October 13, 13

Slide 70

Slide 70 text

Based in a logic called Dedalus. Bloom Sunday, October 13, 13

Slide 71

Slide 71 text

Disorderly language. Bloom Sunday, October 13, 13

Slide 72

Slide 72 text

Lattices and mappings between lattices. Bloom Sunday, October 13, 13

Slide 73

Slide 73 text

Highlights non-monotonicity. Bloom Sunday, October 13, 13

Slide 74

Slide 74 text

Operational model. Bloom Sunday, October 13, 13

Slide 75

Slide 75 text

Local clock; local execution; local state. Bloom Sunday, October 13, 13

Slide 76

Slide 76 text

Timestepped execution. Bloom Sunday, October 13, 13

Slide 77

Slide 77 text

Local updates; system events; network. Sunday, October 13, 13

Slide 78

Slide 78 text

Bloom rules; merge functions. Sunday, October 13, 13

Slide 79

Slide 79 text

Network; next. Sunday, October 13, 13

Slide 80

Slide 80 text

Chat server. Bloom Sunday, October 13, 13

Slide 81

Slide 81 text

module ChatProtocol state do channel :connect, [:@addr, :client] => [:nick] channel :mcast end end examples/chat/chat_protocol.rb Sunday, October 13, 13

Slide 82

Slide 82 text

class ChatServer include Bud include ChatProtocol state { table :nodelist } bloom do nodelist <= connect.map { |c| [c.client, c.nick] } mcast <~ (mcast * nodelist).pairs { |m,n| [n.key, m.val] } end end examples/chat/chat_server.rb Sunday, October 13, 13

Slide 83

Slide 83 text

Lattices; monotonic functions. Bloom Sunday, October 13, 13

Slide 84

Slide 84 text

class ChatServer include Bud include ChatProtocol state do table :nodelist channel :disconnect end bloom do nodelist <= connect.map { |c| [c.client, c.nick] } mcast <~ (mcast * nodelist).pairs { |m,n| [n.key, m.val] } nodelist <- disconnect.map { |c| [c.client, c.nick] } end end examples/chat/chat_server.rb Sunday, October 13, 13

Slide 85

Slide 85 text

Non-monotonic; not eventually consistent. Bloom Sunday, October 13, 13

Slide 86

Slide 86 text

bloom do mcast <~ stdio do |s| [@server, [ip_port, @nick, Time.new.strftime("%I:%M.%S"), s.line]] end stdio <~ mcast { |m| [pretty_print(m.val)] } end examples/chat/chat.rb Sunday, October 13, 13

Slide 87

Slide 87 text

KV Store. Bloom Sunday, October 13, 13

Slide 88

Slide 88 text

module BasicKVS include KVSProtocol state do table :kvstate, [:key] => [:value] end bloom :mutate do kvstate <+ kvput {|s| [s.key, s.value]} kvstate <- (kvstate * kvput).lefts(:key => :key) end bloom :get do temp :getj <= (kvget * kvstate).pairs(:key => :key) kvget_response <= getj do |g, t| [g.reqid, t.key, t.value] end end bloom :delete do kvstate <- (kvstate * kvdel).lefts(:key => :key) end end kvs/kvs.rb Sunday, October 13, 13

Slide 89

Slide 89 text

module ReplicatedKVS include KVSProtocol include MulticastProtocol include MembershipProtocol import BasicKVS => :kvs bloom :local_indir do kvs.kvdel <= kvdel kvs.kvget <= kvget kvget_response <= kvs.kvget_response end bloom :puts do # if I am the master, multicast store requests mcast_send <= kvput do |k| unless member.include? [k.client] [k.reqid, ["put", [@addy, k.key, k.reqid, k.value]]] end end kvs.kvput <= mcast_done do |m| if m.payload[0] == "put" m.payload[1] end end # if I am a replica, store the payload of the multicast kvs.kvput <= pipe_out do |d| if d.payload.fetch(1) != @addy and d.payload[0] == "put" d.payload[1] end end end bloom :dels do mcast_send <= kvdel do |k| unless member.include? [k.client] [k.reqid, ["del", [@addy, k.key, k.reqid]]] end end kvs.kvdel <= mcast_done do |m| if m.payload[0] == "del" m.payload[1] end end kvs.kvdel <= pipe_out do |d| if d.payload.fetch(1) != @addy and d.payload[0] == "del" d.payload[1] end end end end kvs/kvs.rb Sunday, October 13, 13

Slide 90

Slide 90 text

CALM Analysis Sunday, October 13, 13

Slide 91

Slide 91 text

Label asynchronous, non-monotonic. CALM Analysis Sunday, October 13, 13

Slide 92

Slide 92 text

Identify where coordination is needed. CALM Analysis Sunday, October 13, 13

Slide 93

Slide 93 text

The Conclusion Sunday, October 13, 13

Slide 94

Slide 94 text

Prototype language. The Conclusion Sunday, October 13, 13

Slide 95

Slide 95 text

https://github.com/bloom-lang/bud https://github.com/bloom-lang/bud-sandbox Thanks! Questions? Sunday, October 13, 13