流融合,走向完整
Stream Fusion, to Completeness
摘要:
流处理(再次)成为主流:广泛使用的流库现在可用于几乎所有现代OO和函数式语言,从Java到C#到Scala到OCaml再到Haskell。然而,表现力和表现力仍然缺乏。例如,流行的、优化良好的Java 8流不支持zip运算符,仍然比手写的循环慢一个数量级。我们提出了第一种方法,代表了流处理的全部通用性,并消除了开销,通过使用分期。它基于一个异常丰富的流交互语义模型。我们支持有限或无限流的压缩、嵌套(或平面映射)、子范围、过滤、映射的任何组合。我们的模型捕捉了程序员在优化流管道时使用的特性,例如速率差异和“for”与“while”循环的选择。我们的方法提供了类似于手写的代码,但是自动的。它明确避免了对黑盒优化器和智能编译器的依赖,提供了最高的,有保证的和可移植的性能。我们的方法依赖于高层次的概念,然后很容易映射到一个实现。因此,我们有两个不同的实现:一个是OCaml流库,通过MetaOCaml暂存;另一个是用于JVM的Scala库,通过LMS暂存。在这两种情况下,我们得到的库更丰富,同时比过去的工作快几十倍。我们在性能上大大超过了Java、Scala和OCaml中可用的标准流库,包括优化良好的Java 8流。
英文摘要:
Stream processing is mainstream (again): Widely-used stream libraries are now available for virtually all modern OO and functional languages, from Java to C# to Scala to OCaml to Haskell. Yet expressivity and performance are still lacking. For instance, the popular, well-optimized Java 8 streams do not support the zip operator and are still an order of magnitude slower than hand-written loops. We present the first approach that represents the full generality of stream processing and eliminates overheads, via the use of staging. It is based on an unusually rich semantic model of stream interaction. We support any combination of zipping, nesting (or flat-mapping), sub-ranging, filtering, mapping-of finite or infinite streams. Our model captures idiosyncrasies that a programmer uses in optimizing stream pipelines, such as rate differences and the choice of a "for" vs. "while" loops. Our approach delivers hand-written-like code, but automatically. It explicitly avoids the reliance on black-box optimizers and sufficiently-smart compilers, offering highest, guaranteed and portable performance. Our approach relies on high-level concepts that are then readily mapped into an implementation. Accordingly, we have two distinct implementations: an OCaml stream library, staged via MetaOCaml, and a Scala library for the JVM, staged via LMS. In both cases, we derive libraries richer and simultaneously many tens of times faster than past work. We greatly exceed in performance the standard stream libraries available in Java, Scala and OCaml, including the well-optimized Java 8 streams.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。