当前位置: X-MOL 学术Sci. Comput. Program. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Safe automated refactoring for intelligent parallelization of Java 8 streams
Science of Computer Programming ( IF 1.3 ) Pub Date : 2020-05-06 , DOI: 10.1016/j.scico.2020.102476
Raffi Khatchadourian , Yiming Tang , Mehdi Bagherzadeh

Streaming APIs are becoming more pervasive in mainstream Object-Oriented programming languages and platforms. For example, the Stream API introduced in Java 8 allows for functional-like, MapReduce-style operations in processing both finite, e.g., collections, and infinite data structures. However, using this API efficiently involves subtle considerations such as 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 and transformations 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 popular Eclipse IDE, uses the WALA and SAFE analysis frameworks, and was evaluated on 18 Java projects consisting of ∼1.65M lines of code. We found that 116 of 419 candidate streams (27.68%) 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.



中文翻译:

安全的自动重构,可实现Java 8流的智能并行化

流API在主流的面向对象的编程语言和平台中正变得越来越普遍。例如,Java 8中引入的Stream API允许在处理有限(例如集合)和无限数据结构这两者时进行类似于功能的MapReduce样式的操作。但是,有效地使用此API涉及一些细微的考虑,例如确定何时最好使流操作并行运行,何时并行运行操作效率较低以及何时由于可能的lambda表达式而安全运行并行-效果。在本文中,我们提出了一种自动重构方法,该方法可帮助开发人员以保留语义的方式编写有效的流代码。该方法基于新颖的数据排序和类型状态分析,由先决条件和转换组成,用于自动确定何时将顺序流转换为并行和无序或取消并行化已并行的流是安全的,并且可能是有利的。该方法被实现为流行的Eclipse IDE的插件,使用WALA和SAFE分析框架,并在18个Java项目中进行了评估,这些项目由大约165万行代码组成。我们发现419个候选流中的116个(27.68%)是可重构的,并且在性能测试中观察到平均加速为3.49。结果表明,该方法对于优化流代码的全部潜力很有用。该方法被实现为流行的Eclipse IDE的插件,使用WALA和SAFE分析框架,并在18个Java项目中进行了评估,这些项目由大约165万行代码组成。我们发现419个候选流中的116个(27.68%)是可重构的,并且在性能测试中观察到平均加速为3.49。结果表明,该方法对于优化流代码的全部潜力很有用。该方法被实现为流行的Eclipse IDE的插件,使用WALA和SAFE分析框架,并在18个Java项目中进行了评估,这些项目由大约165万行代码组成。我们发现419个候选流中的116个(27.68%)是可重构的,并且在性能测试中观察到平均加速为3.49。结果表明,该方法对于优化流代码的全部潜力很有用。

更新日期:2020-05-06
down
wechat
bug