JEP 544: Ahead-of-Time Code Compilation
20 days ago
- JEP 544 improves Java startup and warmup by using ahead-of-time (AOT) compilation to generate optimized native code during a training run and storing it in an AOT cache for instant use in production.
- The feature extends the existing AOT cache to include compiled native code alongside pre-linked classes and profiling data from earlier JEPs (483 and 515).
- Peak performance is achieved faster, and applications sustain performance under changing workloads by dynamically deoptimizing and reoptimizing with JIT compilation when needed.
- No changes to application code or HotSpot configuration are required beyond enabling the AOT cache; support is provided for AArch64 and x64 architectures and several garbage collectors.
- AOT and JIT code coexist seamlessly; HotSpot automatically transitions between them, and benchmarks show 65–80% startup time reduction and significant warmup improvements.
- Differences between AOT and JIT code arise from class initialization order and unknown static final field values in training runs, but these are handled transparently.
- Training and production runs must have the same CPU features and garbage collector for AOT code to be usable; otherwise, HotSpot falls back to JIT compilation.
- Options like PrintCompilation and AOTMode=required help observe and control AOT code usage, and diagnostic options allow disabling AOT code caching.