Compile-Time Java Stream Fusion via mapMulti
Authors/Creators
Description
The Java Stream API, introduced in Java 8, makes data processing more expressive and concise compared to imperative loops. However, this abstraction can come with significant performance overhead, often due to the creation of multiple intermediate objects during pipeline execution. In functional languages such as Haskell, this problem is addressed through stream fusion, a compile-time optimization that eliminates unnecessary intermediate structures. Inspired by this idea, Streamliner was the first tool to perform ahead-of-time, bytecode-to-bytecode stream optimization for Java by unrolling stream pipelines into imperative loops. In the paper, we introduce an open-source optimizer that takes a different approach. Instead of unrolling streams into loops, it merges consecutive map() and filter() operations into a single mapMulti() call, available since Java 16. Our method avoids several limitations of Streamliner, including its sensitivity to escaping objects in lambda expressions and its restrictions on assigning or passing streams as variables. We evaluated our optimizer on nine benchmarks and observed superior performance in two cases and comparable results in most others. We also applied it to the bytecode of Apache Kafka, successfully executing all 31,799 unit tests without failures.
This archive contains the artifact for the paper.
It was automatically generated by the Makefile in the objectionary/soap26-paper GitHub repository.
The arXiv.zip contains LaTeX sources of the paper.
The hone-maven-plugin-0.24.0.jar file is a released version of the product, from Maven Central: https://repo1.maven.org/maven2/org/eolang/hone-maven-plugin/0.24.0/hone-maven-plugin-0.24.0.jar.
The jeo-maven-plugin-0.15.1.jar file is a released version of the product, from Maven Central: https://repo1.maven.org/maven2/org/eolang/hone-maven-plugin/0.15.1/jeo-maven-plugin-0.15.1.jar.
The tables/ directory contains raw data collected by the JMH.
The hone-maven-plugin/ directory contains source code of the objectionary/hone-maven-plugin GitHub repository (tag '0.24.0').
The jeo-maven-plugin/ directory contains source code of the objectionary/jeo-maven-plugin GitHub repository (tag '0.15.1').
The phino/ directory contains source code of the objectionary/phino GitHub repository (tag '0.0.67').
The kafka/ directory contains source code of the objectionary/kafka GitHub repository (tag 'stable').
Files
zenodo.zip
Files
(20.9 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:1f42775d2e6b772378131028b5079670
|
20.9 MB | Preview Download |