JDK-8213587 : Speed up CDS dump time by using resizable hashtables
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-11-09
  • Updated: 2019-05-28
  • Resolved: 2018-11-21
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 12
12 b21Fixed
Related Reports
Blocks :  
Relates :  
Description
CDS dumping uses ResourceHashtable, for example, to store the relocated address of every archived MetaspaceObj. See 

http://hg.openjdk.java.net/jdk/jdk/file/f1bb77833b59/src/hotspot/share/memory/metaspaceShared.cpp#l1087

  typedef ResourceHashtable<
      address, address,
      ArchiveCompactor::my_hash,
      ArchiveCompactor::my_equals, 
      16384, ResourceObj::C_HEAP> RelocationTable;

However, the template class ResourceHashtable requires the size to be statically specified in the source code. Currently we pick the size 16384 because it's not too big and it is sufficient for up to a few thousand classes.

However, if we dump all the classes in the system modules (about 35000 classes), the RelocationTable would need to store about 2,000,000 records, making each bucket over 100 entries. This causes drastic slow down with CDS dumping.

Test case -- LotsOfClasses.classlist is in attachment

 java \
    -XX:MaxRAM=8g -Xshare:dump \
    -Xlog:cds,cds+hashtables -Xlog:hashtables \
    -XX:SharedArchiveFile=LotsOfClasses.jsa \
    -XX:ExtraSharedClassListFile=LotsOfClasses.classlist \
    --add-modules ALL-SYSTEM

-----

First draft: http://cr.openjdk.java.net/~iklam/jdk12/8213587-configurable-resource-hash.v01/

BEFORE: 93.971 sec
AFTER:    34.761 sec
Comments
Verified by test/hotspot/jtreg/runtime/appcds/LotsOfClasses.java
27-03-2019

First draft: http://cr.openjdk.java.net/~iklam/jdk12/8213587-configurable-resource-hash.v01/
09-11-2018

JDK-8213574 causes deadlock with the test case for validating the current bug (JDK-8123587)
09-11-2018