OpenJDK Proposal Enhances Class Data Sharing for Faster Startups, Aligns with Project Leyden
Efforts to improve Java program startup times and performance are set to include enhancing support for archived Java heap objects in Class Data Sharing (CDS). This initiative is part of a broader strategy to make Java applications more efficient, particularly in terms of their startup times and overall performance.
The plan, publicized by Ioi Lam of Oracle in an OpenJDK community RFC last month, aligns closely with Project Leyden. Project Leyden aims to improve not only startup times for Java applications but also the times to reach peak performance and the overall footprint of these programs. Lam emphasized that Project Leyden will likely rely heavily on the use of archived Java heap objects to achieve its goals.
The primary goals of the CDS improvement plan include providing uniform support of CDS for all garbage collectors and minimizing the code required for each collector to support CDS. CDS is designed to reduce application startup times, especially for smaller applications, by sharing class data between Java Virtual Machine (JVM) instances. Currently, CDS is supported only with the Java HotSpot client VM and the serial garbage collector.
Key elements of the CDS improvement plan are:
- Removing the G1 Garbage Collector Dependency: The plan involves eliminating the dependency on the G1 garbage collector for writing the archive heap. A working prototype for this has already been developed.
- Consolidating the Archive Heap: This step involves combining the archive heap into a contiguous block, making it easier to memory map (mmap) the archive heap into different collectors. As part of this step, the G1 archive region types will also be removed.
- Implementing mmap for Other Collectors: The implementation of mmap for the archive region for collectors other than G1 is anticipated to be relatively straightforward.
As of Java Development Kit (JDK) 20, set for production release in March, implementers of the CDS improvement plan must address several limitations. These include CDS archive dumping being supported only by the G1 collector, G1 having a unique allocation routine for space in the heap, and mmap support being exclusive to G1.
The impetus for the CDS proposal came from a broader Java development plan aimed at establishing uniform APIs for using archived regions. This proposal was initiated in November of the previous year and forms part of the ongoing efforts to standardize and enhance Java’s performance capabilities.
In summary, the proposed enhancements to CDS, as part of the larger Project Leyden effort, promise significant improvements in the startup performance of Java applications. By making CDS more universally applicable across different garbage collectors and simplifying the necessary code, these efforts aim to make Java an even more robust and efficient platform for developers.