Visible to the public Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams

TitleSafe Automated Refactoring for Intelligent Parallelization of Java 8 Streams
Publication TypeConference Paper
Year of Publication2019
AuthorsKhatchadourian, R., Tang, Y., Bagherzadeh, M., Ahmed, S.
Conference Name2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE)
ISBN Number978-1-7281-0869-8
Keywordsapplication program interfaces, automated refactoring approach, automatic parallelization, Collaboration, data structures, finite data structures, Human Behavior, human factors, Image color analysis, infinite data structures, Instruction sets, intelligent parallelization, Java, Java 8, lambda expression side-effects, mainstream object-oriented programming languages, MapReduce-style operations, Metrics, optimizing stream code, parallel streams, Pipelines, policy-based governance, pubcrawl, Refactoring, resilience, Resiliency, running operations, safe automated refactoring, Safe Coding, Semantics, semantics-preserving fashion, sequential streams, software maintenance, static analysis, Stream API, stream code, stream operations, streams, typestate analysis, Writing

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.

Citation Keykhatchadourian_safe_2019