Tuesday, October 13, 2009

Refactoring for Reentrancy

This paper is the third one on automatically refactoring programs for parallelism. In this case, the tool enabled programmers to change programs to make them reentrant, by removing global references, using lazy initializers and warning about unsafe API calls. After reading this paper, I think the tool could be useful in some situations where a program is re-factored with the goal of running several copies simultaneously but overall this tool is not very impressive and may need lot more work to be able to recognize by the users as a good tool.

In summary, the contributions of this paper are as follows (directly from the paper):

1. Characterization of the causes of non-reentrancy in Java programs,

2. Mostly-automated refactoring for making Java programs reentrant by replacing global state with thread-local state, with associated precondition checking that warns of possible behavioral changes due to fragile static initializer behavior and non-reentrant library usage,

3. An implementation of a refactoring tool, Re-entrancer, as an extension to the Eclipse JDT, and

4. An evaluation of Re-entrancer on a set of Java applications, demonstrating its practicability.


The refactoring is comprised of the following 5 steps:

1. Removal of non-reentrant accesses to library global state.

2. Encapsulation of static fields in the application in getter/ setter methods.

3. Replacing static initializers with explicit lazy initialization.

4. Replacing global state with thread-local state.

The refactoring tool does all these automatically, and gives the developer warnings before doing so. Given benchmarks for analyzing the results were far from impressive - some programs ran even slower despite using multiple threads due to the overhead created by the getters and setters. The program could also take substantial time to run. I would also have liked more reasoning on why some methods were rejected at the beginning of the paper, such as making an environment block. It requires a lot of code change, but this approach did to, it would be interesting to see them contrasted.

No comments:

Post a Comment