xacid: (Default)
http://www.cs.kuleuven.ac.be/publicaties/rapporten/cw/CW715.pdf

Faster Coroutine Pipelines:A Reconstruction (Extended Version)

Ruben P. Pieters, Tom Schrijvers
Report CW 715, November 2018
Department of Computer Science, KU Leuven

Spivey has recently presented a novel functional representation that supports the efficient composition, or merging, of coroutine pipelines for processing streams of data. This representation was inspired by Shivers and Might’s three-continuation approach and is shown to be equivalent to a simple yet inefficient executable specification. Unfortunately, neither Shivers and Might’s original work nor the equivalence proof sheds much light on the underlying principles allowing the derivation of this efficient representation from its specification.This paper gives the missing insight by reconstructing a systematic derivation in terms of known transformation steps from the simple specification to the efficient representation. This derivation sheds light on the limitations of the representation and on its applicability to other settings. In particular, it has enabled us to obtain a similar representation for pipes featuring two-way communication,similar to the Haskell pipes library. Our benchmarks confirm that this two-way representation retains the same improved performance characteristics
xacid: (Default)
https://dl.acm.org/citation.cfm?id=3110249

Faster coroutine pipelines

Michael Spivey University of Oxford, UK, 2017

Coroutine pipelines provide an attractive structuring mechanism for complex programs that process streams of data, with the advantage over lazy streams that both ends of a pipeline may interact with the I/O system, as may processes in the middle. Two popular Haskell libraries, Pipes and Conduit, support such pipelines. In both libraries, pipelines are implemented in a direct style by combining a free monad of communication events with an interpreter for (pseudo-)parallel composition that interleaves the events of its argument processes. These implementations both suffer from a slow-down when processes are deeply nested in sequence or in parallel. We propose an alternative implementation of pipelines based on continuations that does not suffer from this slow-down. What is more, the implementation is significantly faster on small, communication-intensive examples even where they do not suffer from the slow-down, and comparable in speed with similar programs based on lazy streams. We also show that the continuation-based implementation may be derived from the direct-style implementation by algebraic reasoning.
xacid: (Default)
/*
https://github.com/rizo/streams/blob/master/src/coroutine.ml
https://pusher.com/sessions/meetup/the-realtime-guild/realtime-stream-processing-with-coroutines
*/

object Pipes {

  sealed trait Pipe[I, O, R] {

    final def flatMap[T](f: R => Pipe[I, O, T]): Pipe[I, O, T] = this match {
      case Yield(b, p) => Yield(b, () => p() flatMap f)
      case Await(k) => Await(a => k(a) flatMap f)
      case Ready(r) => f(r)
    }
Read more... )

Profile

xacid: (Default)
xacid

April 2021

S M T W T F S
    123
45678910
11121314151617
18192021222324
252627282930 

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 15th, 2025 11:12 pm
Powered by Dreamwidth Studios