Erlang CHRISTOPHER MEIKLEJOHN* AND PETER VAN ROY Basho Technologies, Inc. and Université catholique de Louvain We propose a new “generic” abstraction for Erlang/OTP that aids in the implementation of dataflow programming languages and models on the Erlang VM. This abstraction simplifies the implementation of “processing elements” in dataflow languages by providing a simple callback interface in the style of the gen_server and gen_fsm abstractions. We motivate the use of this new abstraction by examining the implementation of a distributed dataflow programming variant called Lasp. Categories and Subject Descriptors: D.1.3 [Programming Techniques]: Concurrent Programming; E.1 [Data Structures]: Distributed data structures Keywords: Dataflow Programming, Erlang, Concurrent Programming * work performed when the author was employed by Basho Technologies, Inc.
of the “generic” abstractions • Focuses on data and control flow • Support the development of dataflow based programming models* “Derflow”, Bravo et al., Erlang Workshop 2014 “DerflowL”, Meiklejohn et al., LADIS Workshop 2014 “Lasp”, Meiklejohn et al., PPDP 2015
list of functions that are used to retrieve the value for each argument to processing • Module:process/2 Process computation given the most recently received arguments from each “source”
to read all source variables 2. Cache responses As responses are received, cache the most recent value 3. Module:process/2 Reprocess the function with the most recent values from the cache 4. Propagate result The implementer can decide how to propagate values forward with an arbitrary function; via a TCP socket, Erlang message passing, etc.
“eventually consistent” computations • Prototypical implementation Implementation in Erlang using gen_flow • Convergent modules Primary data abstraction is the CRDT
closely resembles sequential data structures • Strong Eventual Consistency (SEC) Deterministic convergence guarantee once all messages have been delivered to all “replicas” • Non-monotonic operations How do we handle operations that are nondeterministic?
V) Bind a value to a variable; computes the least- upper-bound between the new and current value • update(X, Op, Actor) Update value of a variable with an identifier and a unique actor identifier
elements to initial set and update. {ok, _} = lasp:update(S1, {add_all, [1,2,3]}, a), %% Create second set. {ok, S2} = lasp:declare(riak_dt_orset), %% Apply map operation between S1 and S2. {ok, _} = lasp:map(S1, fun(X) -> X * 2 end, S2).
, and Lasp • Extracted from Lasp gen_flow was extracted from the Lasp runtime • Code reduction Assisted in ease of implementation of the Lasp language as we added new “operations” • Macros as read functions Replacement of read functions at compile time based on EQC, eunit, or actual execution
proper supervision • System messages Support system messages to replace or return state • Debugging Support Erlang debugging for tracking received messages • Elixir Elixir is looking to bring ideas from gen_flow into their generic abstraction gen_router