Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8328563

Store java.lang.ClassLoader::{packages, package2certs} into CDS archive

XMLWordPrintable

      When loading lots of classes from the CDS archive, we spend a lot of time calling CDSProtectionDomain::define_shared_package()

      https://github.com/openjdk/jdk/blob/269163d509ec3c80983f55c5b47f472fa76be26c/src/hotspot/share/cds/cdsProtectionDomain.cpp#L140C6-L162

      The effect of this call is to query and populate the packages and package2certs maps in java.lang.ClassLoader. These tables are used for various checks related to packages. For example, some sealed package checks are done here:

      https://github.com/openjdk/jdk/blob/269163d509ec3c80983f55c5b47f472fa76be26c/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java#L905-L915

      When the CDSLoadedClasses options is false (see JDK-8315737), the contents of these tables cannot be predetermined and must be populated incrementally, as classes are being loaded.

      However, when CDSLoadedClasses is enabled, the contents of those tables can be completely determined during CDS archive creation time. Therefore, we can save these tables into the CDS archive. At runtime, we can perform bulk loading of the archived classes, without calling CDSProtectionDomain::define_shared_package().

      For the Spring Pet-Clinic benchmark, with -XX:+CDSLoadedClasses [*], we load about 21000 classes at VM start-up. When the packages, package2certs tables are archived, the total time of loading these classes are reduced from about 250ms to about 220ms on Core(TM) i7-10700 CPU @ 2.90GHz


      ====

      [*] Note: as of 2024/03/19, the CDSLoadedClasses option is called PreloadSharedClasses in the Leyden repo.

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: