From a Calculus to an Execution Environment for Stream Processing

From a Calculus to an Execution Environment for Stream Processing

From a Calculus to an Execution Environment for Stream Processing Robert Soule´ Martin Hirzel Bugra˘ Gedik Robert Grimm New York University IBM Research Bilkent University New York University [email protected] [email protected] [email protected] [email protected] Abstract real-world domains, including transportation, audio and video pro- At one level, this paper is about River, a virtual execution envi- cessing, network monitoring, telecommunications, healthcare, and ronment for stream processing. Stream processing is a paradigm finance. well-suited for many modern data processing systems that ingest The starting point for this paper is the Brooklet calculus [32]. high-volume data streams from the real world, such as audio/video A Brooklet application is a stream graph, where each edge is streaming, high-frequency trading, and security monitoring. One a conceptually infinite stream of data items, and each vertex is attractive property of stream processing is that it lends itself to par- an operator. Each time a data item arrives on an input stream allelization on multicores, and even to distribution on clusters when of an operator, the operator fires, executing a pure function to extreme scale is required. Stream processing has been co-evolved compute data items for its output streams. Optionally, an operator by several communities, leading to diverse languages with similar may also maintain state, consisting of variables to remember across core concepts. Providing a common execution environment reduces operator firings. Prior work demonstrated that Brooklet is a natural language development effort and increases portability. We designed abstraction for different streaming languages. River as a practical realization of Brooklet, a calculus for stream The finishing point for this paper is the River execution envi- processing. So at another level, this paper is about a journey from ronment. Extending a calculus into an execution environment is theory (the calculus) to practice (the execution environment). The challenging. A calculus deliberately abstracts away features that are challenge is that, by definition, a calculus abstracts away all but the not relevant in theory, whereas an execution environment must add most central concepts. Hence, there are several research questions them back in to be practical. The question is how to do that while in concretizing the missing parts, not to mention a significant engi- (1) maintaining the desirable properties of the calculus, (2) making neering effort in implementing them. But the effort is well worth it, the source language development effort economic, and (3) safely because using a calculus as a foundation yields clear semantics and supporting common optimizations and reaching reasonable target- proven correctness results. platform performance. The answers to these questions are the re- search contributions of this paper. Categories and Subject Descriptors D.3.2 [Programming Lan- On the implementation side, we wrote front-ends for dialects of guages]: Language Classifications—parallel languages; D.3.4 three very different streaming languages (CQL [2], Sawzall [31], [Programming Languages]: Processors—compilers and StreamIt [34]) on River. We wrote a back-end for River on Keywords Stream Processing, Domain Specific Language, Inter- System S [1], a high-performance distributed streaming runtime. mediate Language, CQL, Sawzall, StreamIt And we wrote three high-level optimizations (placement, fusion, and fission) that work at the River level, decoupled from and thus reusable across front-ends. This is a significant advance over prior 1. Introduction work, where source languages, optimizations, and target platforms It is widely accepted that virtual execution environments help pro- are tightly coupled. For instance, since River’s target platform, gramming languages by decoupling them from the target platform System S, runs on a shared-nothing cluster, this paper reports the and vice versa. At its core, a virtual execution environment pro- first distributed CQL implementation, making CQL more scalable. vides a small interface with well-defined behavior, facilitating ro- Overall, this paper shows how to get the best of both theory bust, portable, and economic language implementations. Similarly, and practice for stream processing. Starting from a calculus sup- a calculus is a formal system that mathematically defines the behav- ports formal proofs showing that front-ends realize the semantics ior of the essential features of a domain. This paper demonstrates of their source languages, and that optimizations are safe. And fin- how to use a calculus as the foundation for an execution environ- ishing in an execution environment lowers the barrier to entry for ment for stream processing. Stream processing makes it convenient new streaming language implementations, and thus grows the eco- to exploit parallelism on multicores or even clusters. Streaming lan- system of this crucial style of programming. guages are diverse [2,3, 10, 31, 34], because they address many 2. Maintaining Properties of the Calculus Being a calculus, Brooklet makes abstractions. In other words, Permission to make digital or hard copies of all or part of this work for personal or it removes irrelevant details to reduce stream processing to the classroom use is granted without fee provided that copies are not made or distributed features that are essential for formal reasoning. On the other hand, for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute River, being a practical execution environment, has to take a stand to lists, requires prior specific permission and/or a fee. on each of the abstracted-away details. This section describes these DEBS ’12, July 16–20, 2012, Berlin, Germany. decisions, and explains how the execution environment retains the Copyright c 2012 ACM 978-1-4503-1315-5. $10.00 benefits of the calculus. 1 In order for this paper to be self-contained and suitable for a No physical platform. Brooklet programs are completely inde- systems audience, it first restates the formal semantics from the pendent from any actual machines they would run on. Brooklet paper [32] in more informal terms. Here is an example Brooklet program: Finite execution. Stream processing applications run conceptu- ally forever, but a Brooklet execution is a finite sequence of steps. (appleTrades) <- SelectApple(trades); One can reason about an infinite execution by induction over each ($volume) <- Count(appleTrades, $volume); finite prefix [16]. The SelectApple operator filters data items from stream trades 2.2 River Concretizations and their Rationale into stream appleTrades, where the Count operator counts their volume in variable $volume. Note that $volume appears both on the This section shows how the River execution environment fills in left (written) and right (read) side of the Count operator. Brooklet the holes left by the Brooklet calculus. For each of the abstractions models streams as FIFO queues of data items. Queues are one-to- from the previous section, it briefly explains how to concretize it one: they have at most one producer and one consumer. Queues and why. The details and correctness arguments for these points without producers, such as trades, are input queues, and queues come in later sections. without consumers are output queues. At the beginning of the exe- Atomic steps. Whereas Brooklet executes firings one at a time, cution, only input queues are non-empty. Convergent or divergent albeit in non-deterministic order, River executes them concurrently graphs can be constructed by using the same operator as the con- whenever it can guarantee that the end result is the same. This sumer or producer of multiple queues, respectively. A queue is el- concurrency is crucial for performance. To guarantee the same igible to fire if and only if it is non-empty and has a consumer. end result, River uses a minimum of synchronization that keeps Execution proceeds as follows: firings conceptually atomic. River shields the user from concerns while there is at least one queue eligible to fire: of locking or memory models. atomically perform the firing as a single step: • Non-deterministically pick a queue that is eligible to fire. Pure functions. Both the calculus and the execution environ- By definition, the queue has a unique consumer operator. ment separate state from operators. However, whereas the calculus • Pop one data item from the front of the firing queue. passes variables in and out of functions by copies, the execution • Read the values of the input variables of the operator. environment uses pointers instead to avoid the copying cost. Us- • Call the function that implements the operator, passing the ing the fact that state is explicit, River automates the appropriate data item from the firing queue and the values of the input locking discipline where necessary, thus relieving users from this variables as parameters. burden. Furthermore, instead of returning data items to be pushed • The result of the function call contains, for each output on output queues, functions in River directly invoke call-backs for queue of the operator, zero or more data items, and for the run-time library, thus avoiding copies and simplifying the func- each output variable of the operator, its new value. tion implementations. • Push the data items to the operator’s output queues. Opaque functions. Functions for River are implemented in a • Write the values to the operator’s output variables. traditional non-streaming language. They are separated from the At the end, only the program’s output queues are non-empty. The River runtime library by a well-defined API. Since atomicity is result of the execution consists of the contents of variables and preserved at the granularity of operator firings, River does not output queues. interfere with any local instruction-reordering optimizations the low-level compiler or the hardware may want to perform. 2.1 Brooklet Abstractions and their Rationale Non-determinism.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us