Paul Krill
Editor at Large

Ahead of time compilation proposed for the JVM

news
Aug 11, 20232 mins

An OpenJDK plan would improve Java Virtual Machine startup times with the ability to load Java applications and libraries already compiled to native code.

speed fast race car shutterstock 1168856884
Credit: Jamesboy Nuchaikong / Shutterstock

The Java Virtual Machine, renowned for the “write once, run anywhere” portability of Java programs, is being considered for ahead-of-time (AOT) compilation, which would enable faster startup and baseline execution of Java programs.

A recent OpenJDK draft proposal would enhance the JVM with the ability to load Java applications and libraries already compiled to native code. The proposal addresses performance issues that result from Java’s customizable, three-stage execution model, which involves many iterations of optimization and de-optimization. This dynamic process also means that code warmup can take a long time, causing performance issues in applications. These performance issues are sometimes critical and therefore unacceptable, the proposal states.

The Graal compiler, which was an available replacement for Java’s C2 compiler thread before Java 17, serves as a good example. Bootstrapping Graal impacted application performance negatively, because Graal had to be compiled itself before it could begin delivering its performance benefits.

Also impacting Java performance is the deoptimization that occurs when C2-compiled code hits an incorrect assumption, which can be costly. A solution to these issues would be to have a permanent AOT C1-compiled variant of the method replace the interpreter and C1 runtime compilation, so that on startup, execution begins with precompiled C1 code and then progresses to C2 compilation, bypassing some warmup steps as well as the interpreter.

With the Galahad project reintroducing potential AOT compilation for the JIT compiler that would be integrated into the JDK, it would be advantageous to consider AOT compilation for the JVM as well, the proposal states. This would give Galahad a ready platform for loading a precompiled compiler into the JVM.

Elaborating on success metrics, the proposal states that Java applications and libraries and pluggable JVM components written in Java such as JVMCI compilers should be able to be compiled ahead of time to native code, in either profiling or optimizing modes. These would be loaded in a matching JVM with high baseline performance, bypassing the interpreter. It is not a goal of the proposal to support AOT compilation for code that violates constraints placed by the Leyden project, which addresses slow startup, peak performance, and footprint issues in Java.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author