Refactoring Java Concurrent Programs Based on Synchronization Requirement Analysis

Writing high quality concurrent programs is challenging. A concurrent program that is not well-written may suffer from coarse synchronization problems, e.g., overly-large critical sections, overly-coarse locks, and etc. These coarse synchronizations may introduce unnecessary lock contention and thereby affect the parallel execution of running threads. To optimize them, people suggest use refactorings, e.g., Split Lock refactoring and Split Critical Section refactoring, to gradually evolve the synchronization code for better parallelism. However, manually identifying the refactoring opportunities is difficult and by-hand code transformations are error-prone. To reduce the manual efforts, this paper proposes an automated refactoring approach for Java concurrent programs based on synchronization requirement analysis. It can automatically analyze the existing synchronization code to identify synchronization requirements. Bases on these requirements, we can find Split Lock, Split Critical Section, and Convert to Atomic refactoring opportunities and then make proper code transformation for each of them. Our experiment shows that the approach does find effective refactoring opportunities in real projects and can transform the refactorable code correctly. This indicates the approach could be helpful for concurrent program evolution.

[1]  Peter Kilpatrick,et al.  A language-independent parallel refactoring framework , 2012, WRT '12.

[2]  Martin C. Rinard,et al.  Synchronization transformations for parallel computing , 1999, POPL '97.

[3]  Urs Hölzle,et al.  Removing unnecessary synchronization in Java , 1999, OOPSLA '99.

[4]  Baowen Xu,et al.  Finding shrink critical section refactoring opportunities for the evolution of concurrent code in trustworthy software , 2013, Science China Information Sciences.

[5]  Kostadin Damevski,et al.  A refactoring tool to extract GPU kernels , 2011, WRT '11.

[6]  Michael D. Ernst,et al.  Refactoring sequential Java code for concurrency via concurrent libraries , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[7]  Xiao Ma,et al.  MUVI: automatically inferring multi-variable access correlations and detecting related semantic and concurrency bugs , 2007, SOSP.

[8]  Shane Markstrum,et al.  Towards concurrency refactoring for x10 , 2009, PPoPP '09.

[9]  Michael Hind,et al.  Pointer analysis: haven't we solved this problem yet? , 2001, PASTE '01.

[10]  Herb Sutter,et al.  The Free Lunch Is Over A Fundamental Turn Toward Concurrency in Software , 2013 .

[11]  Frank Tip,et al.  Refactoring for reentrancy , 2009, ESEC/FSE '09.

[12]  David Holmes,et al.  Java Concurrency in Practice , 2006 .

[13]  Martin C. Rinard,et al.  Lock Coarsening: Eliminating Lock Overhead in Automatically Parallelized Object-Based Programs , 1998, J. Parallel Distributed Comput..

[14]  Emin Gün Sirer,et al.  Static Analyses for Eliminating Unnecessary Synchronization from Java Programs , 1999, SAS.

[15]  Martin C. Rinard,et al.  Lock Coarsening: Eliminating Lock Overhead in Automatically Parallelized Object-Based Programs , 1996, LCPC.

[16]  Aaron Greenhouse,et al.  Observations on the assured evolution of concurrent Java programs , 2005, Sci. Comput. Program..

[17]  Doug Lea,et al.  Concurrent programming in Java - design principles and patterns , 1996, Java series.

[18]  Vijay Sundaresan,et al.  Automatically reducing repetitive synchronization with a just-in-time compiler for Java , 2005, International Symposium on Code Generation and Optimization.

[19]  Jong-Deok Choi,et al.  Escape analysis for Java , 1999, OOPSLA '99.

[20]  Laurie Hendren,et al.  Soot: a Java bytecode optimization framework , 2010, CASCON.

[21]  Erik Ruf,et al.  Effective synchronization removal for Java , 2000, PLDI '00.

[22]  Frank Tip,et al.  Refactoring Java programs for flexible locking , 2011, 2011 33rd International Conference on Software Engineering (ICSE).