JDK-8202035 : Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-04-19
  • Updated: 2022-10-03
  • Resolved: 2018-07-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12
11.0.5Fixed 12 b02Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8205500 :  
Description
The module system bootstrap process creates a set of ModuleReference objects and ModuleDescriptor objects that constitute the observable system modules for the current execution environment based on the precomputed module information at jlink time. The time for creating the ModuleReference objects and ModuleDescriptor objects is a small but measurable portion of the JVM startup time. The goal of this enhancement is to archive the system ModuleReferences and ModuleDescriptors in 'open' archive heap region at CDS dump time, which allows reusing of the objects at runtime and completely bypass the process for creating the observable system ModuleDescriptors and ModuleReferences for startup improvement. 

Support archiving system module graph when the initial module is null (from -cp) currently.

Support G1 GC, 64-bit (non-Windows). Requires UseCompressedOops and UseCompressedClassPointers.

Dump time system module object archiving
=================================
At dump time, the following fields in ArchivedModuleGraph are set to record the system module information for archiving.

 private static SystemModules   archivedSystemModules;   
 private static ModuleFinder    archivedSystemModuleFinder;    
 private static String          archivedMainModule;

The archiving process starts from a given static field in ArchivedModuleGraph class instance (java mirror object). The process archives the complete network of java heap objects that are reachable directly or indirectly from the starting object by following references. 

1. Starts from a given static field within the Class instance (java mirror). If the static field is a refererence field and points to a non-null java object, proceed to the next step. The static field and it's value is recorded and stored outside the archived mirror.
2. Archives the referenced java object. If an archived copy of the current object already exists, updates the pointer in the archived copy of the referencing object to point to the current archived object. Otherwise, proceed to the next step.
3. Follows all references within the current java object and recursively archive the sub-graph of objects starting from each reference encountered within the object.
4. Updates the pointer in the archived copy of referecing object to point to the current archived object.
5. The Klass of the current java object is added to a list of Klasses for loading and initializing before any object in the archived graph can be accessed at runtime.

Runtime initialization from archived system module objects
===============================
VM.initializeFromArchive(<class>) is called from ArchivedModuleGraph's static initializer to initialize from the archived module information. Klasses in the recorded list are loaded, linked and initialized. The static fields in ArchivedModuleGraph class instance are initialized using the archived field values. After initialization, the archived system module objects can be used directly.

If the archived java heap data is not successfully mapped at runtime, or there is an error during VM.initializeFromArchive(), then all static fields in ArchivedModuleGraph are not initialized. System ModuleDescriptor and ModuleReference objects are created as normal.
Comments
This is the first changeset that introduced a configurable way or storing static fields in the CDS archive heap. https://github.com/openjdk/jdk/commit/9ba5bab86548fce7be08559abe2e4c604ad5f5f3
03-10-2022

Fix Request Backporting this patch can help further improve JDK 11 startup time when the default CDS archive is enabled. This patch is also a dependency for other planned CDS backports. Patch applies cleanly to 11u.
05-07-2019

URL: http://hg.openjdk.java.net/jdk/jdk/rev/b96466cdfc45 User: jiangli Date: 2018-07-08 16:52:37 +0000
08-07-2018