paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Faster coroutine pipelines

更快的协程管道
ICFP 1(ICFP)2017匹配度 1/10 · 该论文属于函数式编程中协程管道的实现与性能优化,主题是 Haskell 库 Pipes/Conduit 的延续式实现,与用户关注的静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析均无直接关联。引用 4 inbox
Michael Spivey
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:提出基于延续的协程管道实现,消除嵌套减速并显著提升通信密集场景性能。

协程管道便于组织处理数据流的复杂程序,相比惰性流还能让管道两端及中间过程与 I/O 交互。Haskell 的 Pipes 与 Conduit 以直接风格实现:用通信事件的自由单子结合解释器来交错伪并行组合。该实现在进程深度嵌套于顺序或并行组合时出现减速。本文提出基于延续(continuation)的管道实现,避免这一减速;在小型、通信密集的例子中即使未受减速影响也显著更快,速度可与基于惰性流的程序相当。作者还通过代数推理说明该实现可由直接风格实现推导而来。

问题
现有 Haskell 协程管道(Pipes/Conduit)在进程深度嵌套于顺序或并行组合时性能下降,且通信密集的小例子上也偏慢。
方法
用基于延续的实现替代自由单子加伪并行解释器的直接风格实现,并通过代数推理从原实现推导新实现。
评估
对小型、通信密集的基准与 Pipes/Conduit 及惰性流程序比较运行速度,并分析嵌套场景的减速是否消除。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@article{Spivey17,
  title = {Faster coroutine pipelines},
  author = {Michael Spivey},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {1},
  number = {ICFP},
  year = {2017},
  doi = {10.1145/3110249}
}