An Empirical Study on Deoptimization in the Graal Compiler

Managed language platforms such as the Java Virtual Machine or the Common Language Runtime rely on a dynamic compiler to achieve high performance. Besides making optimization decisions based on the actual program execution and the underlying hardware platform, a dynamic compiler is also in an ideal position to perform speculative optimizations. However, these tend to increase the compilation costs, because unsuccessful speculations trigger deoptimization and recompilation of the affected parts of the program, wasting previous work. Even though speculative optimizations are widely used, the costs of these optimizations in terms of extra compilation work has not been previously studied. In this paper, we analyze the behavior of the Graal dynamic compiler integrated in Oracle's HotSpot Virtual Machine. We focus on situations which cause program execution to switch from machine code to the interpreter, and compare application performance using three different deoptimization strategies which influence the amount of extra compilation work done by Graal. Using an adaptive deoptimization strategy, we managed to improve the average start-up performance of benchmarks from the DaCapo, ScalaBench, and Octane benchmark suites, mostly by avoiding wasted compilation work. On a single-core system, we observed an average speed-up of 6.4% for the DaCapo and ScalaBench workloads, and a speed-up of 5.1% for the Octane workloads; the improvement decreases with an increasing number of available CPU cores. We also find that the choice of a deoptimization strategy has negligible impact on steady-state performance. This indicates that the cost of speculation matters mainly during start-up, where it can disturb the delicate balance between executing the program and the compiler, but is quickly amortized in steady state.

[1]  John Whaley Partial method compilation using dynamic profile information , 2001, OOPSLA '01.

[2]  Mira Mezini,et al.  Da capo con scala: design and analysis of a scala benchmark suite for the java virtual machine , 2011, OOPSLA '11.

[3]  Lieven Eeckhout,et al.  Using hpm-sampling to drive dynamic compilation , 2007, OOPSLA.

[4]  Matthew Arnold,et al.  Online feedback-directed optimization of Java , 2002, OOPSLA '02.

[5]  Toshiaki Yasue,et al.  An efficient online path profiling framework for Java just-in-time compilers , 2003, 2003 12th International Conference on Parallel Architectures and Compilation Techniques.

[6]  Stephen J. Fink,et al.  Design, implementation and evaluation of adaptive recompilation with on-stack replacement , 2003, International Symposium on Code Generation and Optimization, 2003. CGO 2003..

[7]  Matthew Arnold,et al.  Dynamic compilation: the benefits of early investing , 2007, VEE '07.

[8]  Urs Hölzle,et al.  Reconciling responsiveness with performance in pure object-oriented languages , 1996, TOPL.

[9]  Christopher A. Vick,et al.  The Java HotSpotTM Server Compiler , 2001 .

[10]  Ben Hardekopf,et al.  Deoptimization for dynamic language JITs on typed, stack-based virtual machines , 2014, VEE '14.

[11]  L. Peter Deutsch,et al.  Efficient implementation of the smalltalk-80 system , 1984, POPL.

[12]  Craig Chambers,et al.  Making pure object-oriented languages practical , 1991, OOPSLA 1991.

[13]  Walter Binder,et al.  Accurate profiling in the presence of dynamic compilation , 2015, Software Engineering.

[14]  Amer Diwan,et al.  The DaCapo benchmarks: java benchmarking development and analysis , 2006, OOPSLA '06.

[15]  Vivek Sarkar,et al.  Reducing the overhead of dynamic compilation , 2001, Softw. Pract. Exp..

[16]  Craig Chambers,et al.  Debugging optimized code with dynamic deoptimization , 1992, PLDI '92.

[17]  Christian Wimmer,et al.  One VM to rule them all , 2013, Onward!.

[18]  Dayong Gu,et al.  Phase-based adaptive recompilation in a JVM , 2008, CGO '08.

[19]  Toshiaki Yasue,et al.  Design and evaluation of dynamic optimizations for a Java just-in-time compiler , 2005, TOPL.

[20]  Hanspeter Mössenböck,et al.  Design of the Java HotSpot#8482; client compiler for Java 6 , 2008, TACO.

[21]  Prasad A. Kulkarni,et al.  JIT compilation policy for modern machines , 2011, OOPSLA '11.

[22]  Donald E. Knuth,et al.  Structured Programming with go to Statements , 1974, CSUR.

[23]  Vojin Jovanovic,et al.  One compiler: deoptimization to optimized code , 2017, CC.

[24]  Matthew Arnold,et al.  A Survey of Adaptive Optimization in Virtual Machines , 2005, Proceedings of the IEEE.