paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams

面向 Java 8 Stream 智能并行化的安全自动重构
ICSE 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE)2019匹配度 2/10 · 该论文属于传统程序分析与自动重构,提出基于数据顺序和类型状态分析来安全并行化 Java 8 Stream,虽涉及静态分析与并发,但与用户核心方向(PL→AI、AI→PL、浮点/贝叶斯程序分析及其与 LLM 的交叉)几乎没有直接关联。引用 48 inbox
Raffi Khatchadourian, Yiming Tang, Mehdi Bagherzadeh, Syed Ahmed
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出基于数据顺序与类型状态分析的安全自动重构,将顺序 Stream 安全并行化或去并行化。

针对 Java 8 Stream 等流式 API 在面向对象语言中高效使用困难的问题:开发者需判断何时并行更优、何时因 lambda 副作用而不安全。本文提出一种保持语义的自动重构方法,基于数据顺序与 typestate 分析,建立前置条件,自动将顺序流安全转为并行流,或对已并行流取消排序/去并行化。该方法实现为 Eclipse IDE 插件,使用 WALA 与 SAFE 分析框架。在 11 个 Java 项目(约 642K 行代码)上评估:157 个候选流中 57 个(36.31%)可重构,性能测试平均加速 3.49 倍。结果表明该方法有助于充分发挥流代码优化潜力。

问题
Java 8 Stream 等流式 API 的并行化效率与安全性难以把握:开发者需判断何时并行更优,以及 lambda 表达式的副作用是否允许安全并行。
方法
基于数据顺序与 typestate 分析的自动重构方法,定义前置条件以判定将顺序流转换为并行流、取消排序或去并行化是否安全且可能有利;实现为 Eclipse IDE 插件并集成 WALA/SAFE。
评估
在 11 个 Java 项目(约 642K 行代码)上评估,157 个候选流中 57 个(36.31%)可重构,性能测试平均加速 3.49 倍。
原文摘要(Abstract)

Streaming APIs are becoming more pervasive in mainstream Object-Oriented programming languages. For example, the Stream API introduced in Java 8 allows for functional-like, MapReduce-style operations in processing both finite and infinite data structures. However, using this API efficiently involves subtle considerations like determining when it is best for stream operations to run in parallel, when running operations in parallel can be less efficient, and when it is safe to run in parallel due to possible lambda expression side-effects. In this paper, we present an automated refactoring approach that assists developers in writing efficient stream code in a semantics-preserving fashion. The approach, based on a novel data ordering and typestate analysis, consists of preconditions for automatically determining when it is safe and possibly advantageous to convert sequential streams to parallel and unorder or de-parallelize already parallel streams. The approach was implemented as a plug-in to the Eclipse IDE, uses the WALA and SAFE analysis frameworks, and was evaluated on 11 Java projects consisting of ?642K lines of code. We found that 57 of 157 candidate streams (36.31%) were refactorable, and an average speedup of 3.49 on performance tests was observed. The results indicate that the approach is useful in optimizing stream code to their full potential.

链接与引用

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

BibTeX
@inproceedings{KhatchadourianT20,
  title = {Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams},
  author = {Raffi Khatchadourian and Yiming Tang and Mehdi Bagherzadeh and Syed Ahmed},
  booktitle = {ICSE},
  year = {2019},
  doi = {10.1109/icse.2019.00072}
}