RFR: JDK-8236604: Optimize SystemDictionary::resolve_well_known_classes for CDS

Yumin Qi yumin.qi at oracle.com
Tue Feb 25 05:02:24 UTC 2020


Hi,

    Please review fix:

    Bug: https://bugs.openjdk.java.net/browse/JDK-8236604

    Webrev:http://cr.openjdk.java.net/~minqi/8236604/webrev-00

     Description: Optimize well known classes initialization for CDS 
during jvm startup.

     When run with CDS, initialize well known classes (95 classes) will 
call resolve_or_fail thus go though the resolve functions, locks etc. 
The initialization of well-known classes happens in fact in very early 
stage, those lock can be avoided. The fix is serializing 
SystemDictionay::_well_known_klasses into CDS  and in runtime restore 
them by avoiding call resolve_or_fail. Since Compile_lock has to be held 
for SystemDictionary::add_to_hierachy, the fix avoids calling it by 
copying the code from it in SytemDictionary::quick_resolve, but this way 
I have to remove two asserts which will assert on Compile_lock. The 
reminding usage of the lock was added as comments on the function 
declarations of Klass::append_to_sibling_list and 
InstanceKlass::add_implementor. The two functions calling paths have 
been checked to make sure they are not used in other places.

      Performance measured by take time before and after 
SystemDictionary::resolve_well_known_classes(manually modified 
orignal/new versions), since this is the most direct measurement and 
accurate(excluded in review code):

     + jlong s0 = os::javaTimeNanos();
      resolve_well_known_classes(CHECK);

      + jlong s1 = os::javaTimeNanos();

      // print out s1 - s0

      Run -version 2000 times for original/new versions respectively and 
took the averages. The saving is about 18% (2.9ms vs 2.4ms), it is not a 
big saving but still helps to improve the startup time.

     Testing: local jtreg test on linux-x86.

     pending mach5 hs-tier1-4


Thanks

Yumin



More information about the hotspot-runtime-dev mailing list