Loading…

Safe automated refactoring for intelligent parallelization of Java 8 streams

•Streaming APIs are pervasive in mainstream Object-Oriented programming languages.•Our automated refactoring approach helps in writing efficient stream code.•The approach is based on a novel data ordering and typestate analysis.•Implemented as a plug-in to Eclipse using WALA and SAFE and evaluated o...

Full description

Saved in:
Bibliographic Details
Published in:Science of computer programming 2020-09, Vol.195, p.102476, Article 102476
Main Authors: Khatchadourian, Raffi, Tang, Yiming, Bagherzadeh, Mehdi
Format: Article
Language:English
Subjects:
Citations: Items that this one cites
Items that cite this one
Online Access:Get full text
Tags: Add Tag
No Tags, Be the first to tag this record!
Description
Summary:•Streaming APIs are pervasive in mainstream Object-Oriented programming languages.•Our automated refactoring approach helps in writing efficient stream code.•The approach is based on a novel data ordering and typestate analysis.•Implemented as a plug-in to Eclipse using WALA and SAFE and evaluated on 18 subjects.•Found that 27.68% streams were refactorable, with an average speedup of 3.49. 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.
ISSN:0167-6423
1872-7964
DOI:10.1016/j.scico.2020.102476