一句话:提出 JEDI,一个由 SQL 基准自动生成 Java 基准的套件,用于评测 Java Stream API 并总结高效写法。
Java Stream API 以声明式语法提升开发效率,并提供高层并行抽象,但缺少专门针对 stream 应用的基准,导致研究者难以优化 Stream API,开发者也难以获得高效用法指导。本文提出 JEDI,一个面向 Stream API 的基准套件。JEDI 将已有 SQL 基准自动转换为 Java 基准,其代码生成器能为同一查询生成多种实现,包括基于 stream 与命令式风格,以及不同并行化策略。该工作的核心目标是分析这些实现的性能,识别低效代码结构与更优替代方案,并向 Java 开发者提出最佳实践;同时,根据被处理数据的特征解释最高效的并行化策略。生成的命令式代码还提供了 baseline,可帮助研究者和 Java 库实现者优化 Stream API。
The Java Stream API aims at increasing developer productivity thanks to an easy-to-read declarative syntax to express computations. It also simplifies parallel computing, providing a high-level abstraction on top of common parallelization aspects. Unfortunately, there is a lack of benchmarks specifically targeting stream-based applications. Such a lack of benchmarks makes it difficult for researchers and developers of the Java class library to optimize the Stream API. Moreover, in the absence of dedicated benchmarks, it is difficult to analyze the performance of streams to suggest developers how to write efficient code using the API. In this work we present JEDI, a benchmark suite that targets the Stream API. JEDI is automatically generated by converting SQL benchmarks into Java benchmarks. Our code generator supports targets different implementations (both stream-based and imperative) for the same query. The ultimate goal of our benchmark suite—and the main contribution of this work—is to analyze the performance of the different implementations to spot inefficient code structures and better alternatives, suggesting best practices to Java developers. Among the multiple implementations we generate, we focus on different parallelization strategies and explain the most efficient parallelization strategies based on characteristics of the processed data. Finally, the code generation producing imperative code defines of a baseline that can guide researchers and Java implementers to optimize the Stream API.