The OpenJDK has reached a milestone with the announcement of the Early Access (EA) build for Project Leyden, which is now available for download. This build represents over a year of development efforts aimed at enhancing Java application performance, particularly focusing on start-up times. The preliminary testing has shown impressive results, with popular application frameworks experiencing a 2-3x improvement in start-up times.
The Leyden EA build introduces numerous innovative features designed to optimize Java applications by shifting workload from runtime to earlier experimental executions, known as training runs. During these training runs, various kinds of information, such as bytecode pre-compilation to native code, are pre-computed based on the application's behavior.
The Unified Cache Data Store (CDS) Archive is foundational to the other features. This enhancement allows the CDS to store class metadata, heap objects, profiling data, and compiled code. It is accessed using the -XX:CacheDataStore
flag, simplifying the creation and testing of the CDS archive.
The Loaded Classes in CDS Archives feature, enabled by the -XX:+PreloadSharedClasses
flag, allows classes to be preloaded into the loaded state as soon as the application starts. This facilitates various time-shifting optimizations, making the start-up process faster.
Method Profiles in CDS Archives store method profiles from training runs in the CDS archive, allowing the Just-In-Time (JIT) compiler to start compiling earlier during warm-up. This enables Java applications to reach peak performance faster. This feature is enabled by the -XX:+RecordTraining
and -XX:+ReplayTraining
flags.
Ahead-of-time (AOT) Resolution of Constant Pool Entries resolves many constant pool entries during the training run, improving start-up times and enabling better code generation by the AOT compiler. This optimization is enabled by flags such as -XX:+ArchiveFieldReferences
, -XX:+ArchiveMethodReferences
, and -XX:+ArchiveInvokeDynamic
.
The AOT Compilation of Java Methods identifies frequently used methods during the training run, compiles them, and stores them with the CDS archive. This allows immediate native execution upon application start-up. The -XX:+StoreCachedCode, -XX:+LoadCachedCode,
and -XX:CachedCodeFile
flags manage this feature.
The AOT Generation of Dynamic Proxies and Reflection Data reduces start-up times by generating dynamic proxies and reflection data, commonly used by popular application frameworks, ahead of time. The -XX:+ArchiveDynamicProxies
and -XX:+ArchiveReflectionData
flags enable these features, respectively.
The Class Loader Lookup Cache speeds up repeated class lookups, which are common in application frameworks, by caching them. This feature is accessed with the -XX:+ArchiveLoaderLookupCache
flag.
To experiment with Leyden features, developers can use the java program from the Leyden EA Release with the -XX:CacheDataStore
flag.
The Leyden EA build significantly advances optimizing Java applications, particularly regarding start-up times. Developers can expect notable performance improvements with features like AOT compilation, unified CDS archives, and archived method profiles. The community’s continued engagement will be vital in refining these features and ensuring their successful integration into future Java releases.
Ongoing feedback from the community is crucial for further refinements. Developers are encouraged to try out the Leyden EA build and share their experiences via email at leyden-dev at openjdk.org.
Developers who want to experiment with Leyden features and learn more about the project can refer to the release notes for detailed information and instructions on using the Leyden EA build.
By staying updated on Project Leyden developments through resources such as design notes, presentations, and the official repository, Java developers can leverage these optimizations to enhance their applications' performance and efficiency. As previously reported by InfoQ, Project Leyden has been addressing various challenges, including delays in implementing ahead-of-time compilation, which this release aims to mitigate.