Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bloom: A Language For Disorderly Distributed Programming

Bloom: A Language For Disorderly Distributed Programming

Wicked Good Ruby '13.

Christopher Meiklejohn

October 13, 2013
Tweet

More Decks by Christopher Meiklejohn

Other Decks in Programming

Transcript

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

    View full-size slide

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

    View full-size slide

  3. What do you do?
    Sunday, October 13, 13

    View full-size slide

  4. Sunday, October 13, 13

    View full-size slide

  5. Sunday, October 13, 13

    View full-size slide

  6. Sunday, October 13, 13

    View full-size slide

  7. What did you do?
    Sunday, October 13, 13

    View full-size slide

  8. Sunday, October 13, 13

    View full-size slide

  9. Sunday, October 13, 13

    View full-size slide

  10. UC Berkeley
    Sunday, October 13, 13

    View full-size slide

  11. BOOM
    Sunday, October 13, 13

    View full-size slide

  12. The Outline
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

  14. von Neumann
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  17. Disorderly actors
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  21. Scaling
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

  23. CAP Theorem
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  26. Whoa, Theory!
    Sunday, October 13, 13

    View full-size slide

  27. Distributed computing
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  33. ACID 2.0
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  39. Familiar?
    Sunday, October 13, 13

    View full-size slide

  40. Bounded Join Semilattices
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  45. Examples.
    Bounded Join Semilattices
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  50. Sunday, October 13, 13

    View full-size slide

  51. CvRDT examples.
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  55. [ [{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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  62. CALM Theorem
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  66. Disorderly Programming
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  69. Bloom
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

  71. Disorderly language.
    Bloom
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  74. Operational model.
    Bloom
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

  76. Timestepped execution.
    Bloom
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  79. Network; next.
    Sunday, October 13, 13

    View full-size slide

  80. Chat server.
    Bloom
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

  82. 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

    View full-size slide

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

    View full-size slide

  84. 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

    View full-size slide

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

    View full-size slide

  86. 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

    View full-size slide

  87. KV Store.
    Bloom
    Sunday, October 13, 13

    View full-size slide

  88. 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

    View full-size slide

  89. 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

    View full-size slide

  90. CALM Analysis
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  93. The Conclusion
    Sunday, October 13, 13

    View full-size slide

  94. Prototype language.
    The Conclusion
    Sunday, October 13, 13

    View full-size slide

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

    View full-size slide