The OpenJDK community has released JEP 544, a proposal to improve Java application startup and warmup times by integrating ahead-of-time (AOT) compilation into the HotSpot Java Virtual Machine (JVM). This approach compiles application code into optimized native code during a training run, storing it in an AOT cache for use in subsequent production runs. When workloads shift, HotSpot can dynamically recompile code to maintain peak performance, combining the benefits of both AOT and just-in-time (JIT) compilation.

Java applications running on HotSpot typically experience three phases: startup, warmup, and peak performance. Initially, code runs interpreted, which is slow, while HotSpot profiles execution to identify frequently used methods. These methods are compiled with increasing optimization levels over time. This process, however, consumes CPU and memory resources and delays reaching peak performance.

JEP 544 builds on previous efforts (JEP 483 and JEP 515) that shifted class loading and profiling work earlier by storing pre-linked classes and profiling data in the AOT cache. Now, optimized native code generated during training runs is also stored, allowing HotSpot to load this code immediately during production runs, significantly reducing startup and warmup delays.

Unlike static compilation, which compiles an entire application ahead of time and cannot adapt to changing workloads, this approach retains Java's dynamic compilation advantages. It supports runtime adaptation to workload changes, portability across hardware and software environments, and compatibility with Java’s dynamic features such as class loading and reflection.

The AOT cache is created in two steps: first, a training run records application behavior; second, the cache is assembled with compiled native code. Developers can generate and use the AOT cache with standard HotSpot options without modifying application code or JVM configuration beyond specifying the cache.

Performance benchmarks show that using the AOT cache with compiled native code can reduce startup times by up to 80% and warmup times by approximately 75% in typical Java applications and microservice scenarios.

The feature currently supports x64 and AArch64 architectures and integrates with existing garbage collectors. If the production environment differs significantly from the training environment, HotSpot falls back to interpreter and JIT compilation to ensure correctness.

JEP 544 also provides diagnostic options to monitor AOT code usage and control cache generation. Future work includes exploring greater reliance on AOT code, tuning compiler options for AOT scenarios, and investigating portability enhancements across processor feature sets.

This development is significant for Java developers and organizations aiming to improve application responsiveness and efficiency, especially in cloud and microservice deployments where startup latency is critical.