JDK-8233887 : Archived class pre-resolution and pre-initialization
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 14
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2019-11-10
  • Updated: 2024-07-17
  • Resolved: 2024-01-10
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8232222 :  
JDK-8245858 :  
JDK-8245859 :  
Description
During the execution of a Java application, the used Java classes must be loaded, linked (JVMS [1] §5.4), resolved (optionally, JVMS [1] §5.4.3) and initialized (JVMS [1] §5.5). These operations are relatively expensive, and are repeated for the same set of classes within different JVM processes when running the same Java application. Some of the JDK classes may be commonly used for all Java applications. The loading/linking/resolution/initialization work are repeated for those classes in every JVM process.

Class Data Sharing supports archiving (caching) loaded class metadata and some of the selected Java heap objects in an archive image (.jsa). When that is being used, it avoids repeated classloading work for Java applications and improves performance. Good performance improvements have been observed when enabling archive in some use cases. However, the resolution, initialization and some of the linking work is still repeated during application runtime. The total runtime cost for those operations can be as high as class loading and verification. The cost can be substantially higher for large Java applications.

This umbrella RFE seeks to extend the archiving mechanism for pre-resolving and pre-initializing classes, and preserving the processed data as part of the archive to achieve additional savings. The pre-resolving and pre-initializing work may be applied to selected targets only, rather than applying to all constant pool entries and static fields.

This RFE is served as a place holder for investigation and work in this area. There are still open-ended questions related to this area.

References
[1] https://docs.oracle.com/javase/specs/jvms/se8/jvms8.pdf
[2] https://cr.openjdk.org/~jiangli/Leyden/Java%20Class%20Pre-resolution%20and%20Pre-initialization%20(OpenJDK).pdf

Comments
Runtime Triage: This is not on our current list of priorities. We will consider this feature if we receive additional customer requirements.
10-01-2024

Prototype: https://github.com/adoptium/jdk11u-fast-startup-incubator/pull/33
29-12-2021

Would like to get input/feedback on the prototype linked in above comments. mark.reinhold@, would it be possible to set up an initial discussion meeting for Leyden, class pre-initialization, AOT related topics? Thanks!
10-11-2020

Here is a link to more general class pre-initialization with enhanced heap archiving support that I've working on: http://cr.openjdk.java.net/~jiangli/Leyden/general_class_pre_initialization_core_mechanism. The core mechanism is flexible and has the capability of extending to support keyword driven or input driven (e.g. classlist) class pre-initialization. It is a raw patch created on top of JDK 11 (not in webrev format). Testing and Review ================== The changes have gone through initial internal testing and reviewed by jonathanjoo@google.com, martinrb@google.com and rasbold@google.com. Notes =========== The changes in this patch use annotation guided class pre-initialization approach. Individual classes and static fields in JDK can be annotated with @Preserve for pre-initialization. Smaller adjustments can be done to support classlist guided class pre-initialization approach. Longer term, keyword can be used to tag classes and static fields for pre-initialization, with spec modifications. This patch stores pre-initialized static field values within the related class mirror objects, instead of storing them separately in the ArchivedKlassSubGraphInfoRecords for fully pre-initialized classes. For real world applications, the involved application classes and static fields are on the scale of tens of thousands or hundreds of thousands. With large number of application classes involved, the impact of separate ArchivedKlassSubGraphInfoRecord can be large for both memory and runtime CPU costs. Measurements should be done to quantify the memory and runtime CPU costs for storing pre-initialized static field values separately.
10-11-2020

Here are the links to the initial design doc. I can try attaching again. Design doc: http://cr.openjdk.java.net/~jiangli/Leyden/Java%20Class%20Pre-resolution%20and%20Pre-initialization%20(OpenJDK).pdf Slides: http://cr.openjdk.java.net/~jiangli/Leyden/Selectively%20Pre-initializing%20and%20Preserving%20Java%20Classes%20(OpenJDK).pdf
22-05-2020

Attachment <Selectively Pre-initializing and Preserving Java Classes (OpenJDK).pdf> anti-virus scan found a possible virus. The system has removed attachment. Please check the file before attempting to upload it again
22-05-2020

Attachment <Java Class Pre-resolution and Pre-initialization (OpenJDK).pdf> anti-virus scan found a possible virus. The system has removed attachment. Please check the file before attempting to upload it again
22-05-2020