STCLang: state thread composition as a foundation for monadic dataflow parallelism

Dataflow execution models are used to build highly scalable parallel systems. A programming model that targets parallel dataflow execution must answer the following question: How can parallelism between two dependent nodes in a dataflow graph be exploited? This is difficult when the dataflow language or programming model is implemented by a monad, as is common in the functional community, since expressing dependence between nodes by a monadic bind suggests sequential execution. Even in monadic constructs that explicitly separate state from computation, problems arise due to the need to reason about opaquely defined state. Specifically, when abstractions of the chosen programming model do not enable adequate reasoning about state, it is difficult to detect parallelism between composed stateful computations. In this paper, we propose a programming model that enables the composition of stateful computations and still exposes opportunities for parallelization. We also introduce smap, a higher-order function that can exploit parallelism in stateful computations. We present an implementation of our programming model and smap in Haskell and show that basic concepts from functional reactive programming can be built on top of our programming model with little effort. We compare these implementations to a state-of-the-art approach using monad-par and LVars to expose parallelism explicitly and reach the same level of performance, showing that our programming model successfully extracts parallelism that is present in an algorithm. Further evaluation shows that smap is expressive enough to implement parallel reductions and our programming model resolves short-comings of the stream-based programming model for current state-of-the-art big data processing systems.

[1]  Kevin Wilkinson,et al.  Data integration flows for business intelligence , 2009, EDBT '09.

[2]  Michael J. Franklin,et al.  Resilient Distributed Datasets: A Fault-Tolerant Abstraction for In-Memory Cluster Computing , 2012, NSDI.

[3]  William Thies,et al.  StreamIt: A Language for Streaming Applications , 2002, CC.

[4]  Jack B. Dennis,et al.  Data Flow Supercomputers , 1980, Computer.

[5]  John Hughes,et al.  Generalising monads to arrows , 2000, Sci. Comput. Program..

[6]  Ross Paterson,et al.  A new notation for arrows , 2001, ICFP '01.

[7]  Hai Liu,et al.  Causal commutative arrows revisited , 2016, Haskell.

[8]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[9]  David E. Culler,et al.  SEDA: an architecture for well-conditioned, scalable internet services , 2001, SOSP.

[10]  Paul Hudak,et al.  Functional reactive programming from first principles , 2000, PLDI '00.

[11]  Goetz Graefe,et al.  Encapsulation of parallelism in the Volcano query processing system , 1990, SIGMOD '90.

[12]  Christof Fetzer,et al.  Ohua: Implicit Dataflow Programming for Concurrent Systems , 2015, PPPJ.

[13]  Lars Birkedal,et al.  A logical relation for monadic encapsulation of state: proving contextual equivalences in the presence of runST , 2017, Proc. ACM Program. Lang..

[14]  Sanjay Ghemawat,et al.  MapReduce: Simplified Data Processing on Large Clusters , 2004, OSDI.

[15]  Simon L. Peyton Jones,et al.  A short cut to deforestation , 1993, FPCA '93.

[16]  Simon L. Peyton Jones,et al.  Lazy functional state threads , 1994, PLDI '94.

[17]  Arvind,et al.  Implicit parallel programming in pH , 2001 .

[18]  Henrik Nilsson,et al.  Functional reactive programming, continued , 2002, Haskell '02.

[19]  Sebastian Ertel,et al.  Supporting Fine-grained Dataflow Parallelism in Big Data Systems , 2018, PMAM@PPoPP.

[20]  Amr Sabry,et al.  Monadic state: axiomatization and type safety , 1997, ICFP '97.

[21]  Matt Welsh,et al.  Flask: staged functional programming for sensor networks , 2008, ICFP.

[22]  Ryan Newton,et al.  LVars: lattice-based data structures for deterministic parallelism , 2013, FHPC '13.

[23]  Satnam Singh,et al.  Feedback directed implicit parallelism , 2007, ICFP '07.

[24]  Wolfgang De Meuter,et al.  A survey on reactive programming , 2013, CSUR.

[25]  Zhuo Liu,et al.  Benchmarking Streaming Computation Engines: Storm, Flink and Spark Streaming , 2016, 2016 IEEE International Parallel and Distributed Processing Symposium Workshops (IPDPSW).

[26]  Paul Hudak,et al.  Monad transformers and modular interpreters , 1995, POPL '95.

[27]  Robert Grimm,et al.  A catalog of stream processing optimizations , 2014, ACM Comput. Surv..

[28]  Seif Haridi,et al.  Apache Flink™: Stream and Batch Processing in a Single Engine , 2015, IEEE Data Eng. Bull..

[29]  Simon L. Peyton Jones,et al.  Linear Haskell: practical linearity in a higher-order polymorphic language , 2017, Proc. ACM Program. Lang..

[30]  Simon L. Peyton Jones,et al.  Let-floating: moving bindings to give faster programs , 1996, ICFP '96.

[31]  José Manuel Calderón Trilla Improving implicit parallelism , 2015, Haskell.

[32]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[33]  Sebastian Ertel,et al.  Compiling for concise code and efficient I/O , 2018, CC.

[34]  Lloyd Allison Continuations Implement Generators and Streams , 1990, Comput. J..

[35]  Lars Birkedal,et al.  A relational model of types-and-effects in higher-order concurrent separation logic , 2017, POPL.

[36]  Stephen Chong,et al.  Asynchronous functional reactive programming for GUIs , 2013, PLDI.

[37]  Antony Courtney,et al.  Genuinely Functional User Interfaces , 2001 .

[38]  Edward A. Lee,et al.  Static Scheduling of Synchronous Data Flow Programs for Digital Signal Processing , 1989, IEEE Transactions on Computers.

[39]  Kevin Hammond,et al.  In search of a map: using program slicing to discover potential parallelism in recursive functions , 2017, FHPC@ICFP.

[40]  Ryan Newton,et al.  Parallel type-checking with haskell using saturating LVars and stream generators , 2016, PPOPP.