scispace - formally typeset
Search or ask a question
Proceedings ArticleDOI

Refactoring Java programs using concurrent libraries

17 Jul 2011-pp 35-44
TL;DR: Refactoring algorithms are described that address three problems as they rewrite Java code for scalable performance - transformations that may change the behavior of a program, inter-procedural pointer analysis and consistency tests among the candidate code fragments.
Abstract: Multithread programming is becoming ever-more important to exploit the capabilities of multicore processors Versions of Java prior to version 5 provide only the synchronized construct as a consistency primitive, which causes a performance scalability problem for multicore machines Therefore, Java 5 added the javautilconcurrent package to reduce lock contention Programmers must manually rewrite their existing code to use this package in existing programs There are two typical rewritings methods One is to replace an operation on a variable within a synchronized block with an atomic-lock-free version The other is to replace a sequential concurrent class with its concurrent version The conventional rewriting approach has three deficiencies One problem is transformations that may change the behavior of a program The second problem is missed modifications to be rewritten The third problem is two difference writing techniques are applied individually to each code fragment even in the same method This paper describes our refactoring algorithms that address these three problems as they rewrite Java code for scalable performance We use inter-procedural pointer analysis and consistency tests among the candidate code fragments
Citations
More filters
Journal ArticleDOI
TL;DR: This study suggests that (1) library usage history collected from different client systems and (2) library semantics/content embodied in library identifiers should be balanced together for an efficient library recommendation technique.
Abstract: Context: Software library reuse has significantly increased the productivity of software developers, reduced time-to-market and improved software quality and reusability. However, with the growing number of reusable software libraries in code repositories, finding and adopting a relevant software library becomes a fastidious and complex task for developers.Objective: In this paper, we propose a novel approach called LibFinder to prevent missed reuse opportunities during software maintenance and evolution. The goal is to provide a decision support for developers to easily find "useful" third-party libraries to the implementation of their software systems.Method: To this end, we used the non-dominated sorting genetic algorithm (NSGA-II), a multi-objective search-based algorithm, to find a trade-off between three objectives : 1) maximizing co-usage between a candidate library and the actual libraries used by a given system, 2) maximizing the semantic similarity between a candidate library and the source code of the system, and 3) minimizing the number of recommended libraries.Results: We evaluated our approach on 6083 different libraries from Maven Central super repository that were used by 32,760 client systems obtained from Github super repository. Our results show that our approach outperforms three other existing search techniques and a state-of-the art approach, not based on heuristic search, and succeeds in recommending useful libraries at an accuracy score of 92%, precision of 51% and recall of 68%, while finding the best trade-off between the three considered objectives. Furthermore, we evaluate the usefulness of our approach in practice through an empirical study on two industrial Java systems with developers. Results show that the top 10 recommended libraries was rated by the original developers with an average of 3.25 out of 5.Conclusion: This study suggests that (1) library usage history collected from different client systems and (2) library semantics/content embodied in library identifiers should be balanced together for an efficient library recommendation technique.

89 citations

Journal Article
TL;DR: This paper develops Brinch-Hansen's concept of a monitor as a method of structuring an operating system, introduces a form of synchronization, describes a possible method of implementation in terms of semaphores and gives a suitable proof rule.
Abstract: This paper develops Brinch-Hansen's concept of a monitor as a method of structuring an operating system. It introduces a form of synchronization, describes a possible method of implementation in terms of semaphores and gives a suitable proof rule. Illustrative examples include a single resource scheduler, a bounded buffer, an alarm clock, a buffer pool, a disk head optimizer, and a version of the problem of readers and writers.

79 citations

Journal ArticleDOI
TL;DR: An analysis of 2227 Java projects, comprising more than 650 million lines of code, finds that more than 75% of the latest versions of the projects either explicitly create threads or employ some concurrency control mechanism.

47 citations


Cites background from "Refactoring Java programs using con..."

  • ...Besides that, regardless of the model of concurrency, many researchers [3, 4, 10, 11] argue that high level concurrency libraries can improve software quality....

    [...]

  • ...Uses of synchronized can often be replaced by more efficient and more flexible solutions, better suited for parallel execution [3, 5, 4]....

    [...]

  • ...Tool vendors can also benefit by supporting developers in the use of lesser-known, more efficient mechanisms, for example, by implementing novel refactorings [3, 4, 5]....

    [...]

  • ...This suggests that previous [3, 4, 43, 11, 40] and future work on the introduction of these high-level constructs in existing programs have fertile ground to work on....

    [...]

Journal ArticleDOI
TL;DR: This paper shows how genetic improvement can also be used to achieve specialisation to a specific set of usage scenarios, and uses genetic improvement to evolve faster versions of a C++ program, a Boolean satisfiability solver called MiniSAT, specialising it for three different applications, each with their own characteristics.
Abstract: Genetic improvement uses automated search to find improved versions of existing software. Genetic improvement has previously been concerned with improving a system with respect to all possible usage scenarios. In this paper, we show how genetic improvement can also be used to achieve specialisation to a specific set of usage scenarios. We use genetic improvement to evolve faster versions of a C++ program, a Boolean satisfiability solver called MiniSAT, specialising it for three different applications, each with their own characteristics. Our specialised solvers achieve between 4 and 36 percent execution time improvement, which is commensurate with efficiency gains achievable using human expert optimisation for the general solver. We also use genetic improvement to evolve faster versions of an image processing tool called ImageMagick, utilising code from GraphicsMagick, another image processing tool which was forked from it. We specialise the format conversion functionality to greyscale images and colour images only. Our specialised versions achieve up to 3 percent execution time improvement.

36 citations


Cites background from "Refactoring Java programs using con..."

  • ...code with external components [90], [91], [92], [93]....

    [...]

Journal ArticleDOI
TL;DR: CLOCK is presented, an automated refactoring tool that helps developers convert the synchronized lock into the StampedLock and save developer effort and is evaluated with the SPECjbb2005 benchmark and two real-world applications.
Abstract: StampedLock, proposed in JDK 1.8, provides many interesting features, such as optimistic read locks and upgrading/downgrading locks to improve the design of concurrent programs instead of employing pure read/write locks. Existing refactorings have proposed algorithms to convert locks, but there are a few refactorings that use these promising features of StampedLock. To illustrate a possible refactoring, this paper first shows three code transformations based on StampedLock. Then, this paper presents CLOCK, an automated refactoring tool that helps developers convert the synchronized lock into the StampedLock. An algorithm for reentrance analysis is proposed for the precondition validation. The write lock, read lock, optimistic read lock, and upgrading/downgrading lock are inferred and refactored. CLOCK is evaluated with the SPECjbb2005 benchmark and two real-world applications, Xalan and FOP. A total of 66 classes are modified by searching approximately 395KSLOC and applying the refactoring, achieving an average of 22 classes per benchmark. The experimental results show that CLOCK can help developers with refactoring for StampedLock and save developer effort.

9 citations


Additional excerpts

  • ...[22] proposed a refactoring approach to support atomic refactoring....

    [...]

References
More filters
Journal ArticleDOI
TL;DR: In this paper, the authors develop Brinch-Hansen's concept of a monitor as a method of structuring an operating system and describe a possible method of implementation in terms of semaphores and give a suitable proof rule.
Abstract: This paper develops Brinch-Hansen's concept of a monitor as a method of structuring an operating system. It introduces a form of synchronization, describes a possible method of implementation in terms of semaphores and gives a suitable proof rule. Illustrative examples include a single resource scheduler, a bounded buffer, an alarm clock, a buffer pool, a disk head optimizer, and a version of the problem of readers and writers.

1,705 citations

01 Jan 2005
TL;DR: This thesis presents an automatic partial evaluator for the Ansi C programming language, and proves that partial evaluation at most can accomplish linear speedup, and develops an automatic speedup analysis.
Abstract: Software engineers are faced with a dilemma. They want to write general and wellstructured programs that are flexible and easy to maintain. On the other hand, generality has a price: efficiency. A specialized program solving a particular problem is often significantly faster than a general program. However, the development of specialized software is time-consuming, and is likely to exceed the production of today’s programmers. New techniques are required to solve this so-called software crisis. Partial evaluation is a program specialization technique that reconciles the benefits of generality with efficiency. This thesis presents an automatic partial evaluator for the Ansi C programming language. The content of this thesis is analysis and transformation of C programs. We develop several analyses that support the transformation of a program into its generating extension. A generating extension is a program that produces specialized programs when executed on parts of the input. The thesis contains the following main results. • We develop a generating-extension transformation, and describe specialization of the various parts of C, including pointers and structures. • We develop constraint-based inter-procedural pointer and binding-time analysis. Both analyses are specified via non-standard type inference systems, and implemented by constraint solving. • We develop a side-effect and an in-use analysis. These analyses are developed in the classical monotone data-flow analysis framework. Some intriguing similarities with constraint-based analysis are observed. • We investigate separate and incremental program analysis and transformation. Realistic programs are structured into modules, which break down inter-procedural analyses that need global information about functions. • We prove that partial evaluation at most can accomplish linear speedup, and develop an automatic speedup analysis. • We study the stronger transformation technique driving, and initiate the development of generating super-extensions. The developments in this thesis are supported by an implementation. Throughout the chapters we present empirical results.

1,009 citations


"Refactoring Java programs using con..." refers background in this paper

  • ...Categories and Subject Descriptors D.2.7 [Software Engineering]: Distribution, Maintenance, and Enhancement General Terms Performance Keywords Refactoring, Java, concurrent library, pointer analysis;...

    [...]

Journal ArticleDOI
TL;DR: This work presents object sensitivity, a new form of context sensitivity for flow-insensitive points-to analysis for Java, and proposes a parameterization framework that allows analysis designers to control the tradeoffs between cost and precision in the object-sensitive analysis.
Abstract: The goal of points-to analysis for Java is to determine the set of objects pointed to by a reference variable or a reference object field. We present object sensitivity, a new form of context sensitivity for flow-insensitive points-to analysis for Java. The key idea of our approach is to analyze a method separately for each of the object names that represent run-time objects on which this method may be invoked. To ensure flexibility and practicality, we propose a parameterization framework that allows analysis designers to control the tradeoffs between cost and precision in the object-sensitive analysis.Side-effect analysis determines the memory locations that may be modified by the execution of a program statement. Def-use analysis identifies pairs of statements that set the value of a memory location and subsequently use that value. The information computed by such analyses has a wide variety of uses in compilers and software tools. This work proposes new versions of these analyses that are based on object-sensitive points-to analysis.We have implemented two instantiations of our parameterized object-sensitive points-to analysis. On a set of 23 Java programs, our experiments show that these analyses have comparable cost to a context-insensitive points-to analysis for Java which is based on Andersen's analysis for C. Our results also show that object sensitivity significantly improves the precision of side-effect analysis and call graph construction, compared to (1) context-insensitive analysis, and (2) context-sensitive points-to analysis that models context using the invoking call site. These experiments demonstrate that object-sensitive analyses can achieve substantial precision improvement, while at the same time remaining efficient and practical.

432 citations

Book
01 Jan 2006
TL;DR: Java Concurrency in Practice provides the concepts and techniques needed to write safe and scalable Java programs for today's--and tomorrow's--systems, and addresses the fundamental issues and complexities of concurrency with uncommon clarity.
Abstract: "I was fortunate indeed to have worked with a fantastic team on the design and implementation of the concurrency features added to the Java platform in Java 5.0 and Java 6. Now this same team provides the best explanation yet of these new features, and of concurrency in general. Concurrency is no longer a subject for advanced users only. Every Java developer should read this book." --Martin Buchholz JDK Concurrency Czar, Sun Microsystems"For the past 30 years, computer performance has been driven by Moore's Law; from now on, it will be driven by Amdahl's Law. Writing code that effectively exploits multiple processors can be very challenging. Java Concurrency in Practice provides you with the concepts and techniques needed to write safe and scalable Java programs for today's--and tomorrow's--systems." --Doron Rajwan Research Scientist, Intel Corp"This is the book you need if you're writing--or designing, or debugging, or maintaining, or contemplating--multithreaded Java programs. If you've ever had to synchronize a method and you weren't sure why, you owe it to yourself and your users to read this book, cover to cover." --Ted Neward Author of Effective Enterprise Java"Brian addresses the fundamental issues and complexities of concurrency with uncommon clarity. This book is a must-read for anyone who uses threads and cares about performance." --Kirk Pepperdine CTO, JavaPerformanceTuning.com"This book covers a very deep and subtle topic in a very clear and concise way, making it the perfect Java Concurrency reference manual. Each page is filled with the problems (and solutions!) that programmers struggle with every day. Effectively exploiting concurrency is becoming more and more important now that Moore's Law is delivering more cores but not faster cores, and this book will show you how to do it." --Dr. Cliff Click Senior Software Engineer, Azul Systems"I have a strong interest in concurrency, and have probably written more thread deadlocks and made more synchronization mistakes than most programmers. Brian's book is the most readable on the topic of threading and concurrency in Java, and deals with this difficult subject with a wonderful hands-on approach. This is a book I am recommending to all my readers of The Java Specialists' Newsletter, because it is interesting, useful, and relevant to the problems facing Java developers today." --Dr. Heinz Kabutz The Java Specialists' Newsletter"I've focused a career on simplifying simple problems, but this book ambitiously and effectively works to simplify a complex but critical subject: concurrency. Java Concurrency in Practice is revolutionary in its approach, smooth and easy in style, and timely in its delivery--it's destined to be a very important book." --Bruce Tate Author of Beyond Java"Java Concurrency in Practice is an invaluable compilation of threading know-how for Java developers. I found reading this book intellectually exciting, in part because it is an excellent introduction to Java's concurrency API, but mostly because it captures in a thorough and accessible way expert knowledge on threading not easily found elsewhere." --Bill Venners Author of Inside the Java Virtual MachineThreads are a fundamental part of the Java platform. As multicore processors become the norm, using concurrency effectively becomes essential for building high-performance applications. Java SE 5 and 6 are a huge step forward for the development of concurrent applications, with improvements to the Java Virtual Machine to support high-performance, highly scalable concurrent classes and a rich set of new concurrency building blocks. In Java Concurrency in Practice, the creators of these new facilities explain not only how they work and how to use them, but also the motivation and design patterns behind them.However, developing, testing, and debugging multithreaded programs can still be very difficult; it is all too easy to create concurrent programs that appear to work, but fail when it matters most: in production, under heavy load. Java Concurrency in Practice arms readers with both the theoretical underpinnings and concrete techniques for building reliable, scalable, maintainable concurrent applications. Rather than simply offering an inventory of concurrency APIs and mechanisms, it provides design rules, patterns, and mental models that make it easier to build concurrent programs that are both correct and performant.This book covers: Basic concepts of concurrency and thread safety Techniques for building and composing thread-safe classes Using the concurrency building blocks in java.util.concurrent Performance optimization dos and don'ts Testing concurrent programs Advanced topics such as atomic variables, nonblocking algorithms, and the Java Memory Model

424 citations


"Refactoring Java programs using con..." refers methods in this paper

  • ...The third problem is two difference writing techniques are applied individually to each code fragment even in the same method....

    [...]

Proceedings ArticleDOI
12 Oct 2005
TL;DR: A regularization and refinement approach achieves nearly the precision of field-sensitive Andersen's analysis in time budgets as small as 2ms per query, which can yield speedups of up to 16x over computing an exhaustive Andersen'sAnalysis for some clients, with little to no precision loss.
Abstract: We present a points-to analysis technique suitable for environments with small time and memory budgets, such as just-in-time (JIT) compilers and interactive development environments (IDEs). Our technique is demand-driven, performing only the work necessary to answer each query (a request for a variable's points-to information) issued by a client. In cases where even the demand-driven approach exceeds the time budget for a query, we employ early termination, i.e., stopping the analysis prematurely and returning an over-approximated result to the client. Our technique improves on previous demand-driven points-to analysis algorithms [17, 33] by achieving much higher precision under small time budgets and early termination.We formulate Andersen's analysis [5] for Java as a CFL-reachability problem [33]. This formulation shows that Andersen's analysis for Java is a balanced-parentheses problem, an insight that enables our new techniques. We exploit the balanced parentheses structure to approximate Andersen's analysis by regularizing the CFL-reachability problem, yielding an asymptotically cheaper algorithm. We also show how to regain most of the precision lost in the regular approximation as needed through refinement. Our evaluation shows that our regularization and refinement approach achieves nearly the precision of field-sensitive Andersen's analysis in time budgets as small as 2ms per query. Our technique can yield speedups of up to 16x over computing an exhaustive Andersen's analysis for some clients, with little to no precision loss.

203 citations