Faster Coroutine Pipelines: A Reconstruction
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.
KeywordsStream processing Structured recursion Algebra
We would like to thank Nicolas Wu, Alexander Vandenbroucke and the anonymous PADL reviewers for their feedback. This work was partly funded by the Flemish Fund for Scientific Research (FWO).
- 5.Gonzalez, G.: Haskell Pipes library (2012). http://hackage.haskell.org/package/pipes
- 6.Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP 2013, pp. 145–158. ACM, New York (2013) https://doi.org/10.1145/2500365.2500590
- 7.Lindley, S., McBride, C., McLaughlin, C.: Do be do be do. In: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, pp. 500–514. ACM, New York (2017). https://doi.org/10.1145/3009837.3009897
- 9.O’Sullivan, B.: Haskell Criterion library (2009). http://hackage.haskell.org/package/criterion
- 10.Shivers, O., Might, M.: Continuations and transducer composition. In: Proceedings of the 27th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2006, pp. 295–307. ACM, New York (2006). https://doi.org/10.1145/1133981.1134016
- 11.Snoyman, M.: Haskell Conduit library (2011). http://hackage.haskell.org/package/conduit