JDK-8213346 : Re-implement shared dictionary using CompactHashtable
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-03
  • Updated: 2019-05-28
  • Resolved: 2018-11-14
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 b20Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Description
The current implementation of SharedDictionary is quite awkward. There's a lot of ad-hoc calculation for various sizes such as number of bytes used in the buckets. See:

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

We should change it to be based on CompactHashtable to take advantage of existing code that already deal with various hashtables in the CDS archive. That will also use less space.

While on this, we should also implement the following FIXME for a little space saving.

http://hg.openjdk.java.net/jdk/jdk/file/ca309ee4fd92/src/hotspot/share/classfile/systemDictionaryShared.cpp#l886

int SharedDictionaryEntry::finalize_verification_constraints() {
      ....
      // FIXME: change this to be done after relocation, so we can use symbol offset??
 
Comments
http://cr.openjdk.java.net/~iklam/jdk12/8213346-shared-dict-using-compact-hashtable.v01/ [1] Use CompactHashtable which is more space efficient than Dictionary. [2] Space saving: + For each shared class, we used to store a fixed-size record in SharedDictionaryEntry. That information is now stored in a variable-length structure (see RunTimeSharedClassInfo). + Verifier constraints are now stored using u4 instead of Symbol*. Total space saving is about 45KB for the default CDS archive. [4] We had scattered code that checked whether a class should be archived or not. E.g., checking for code signers, JFR, etc. Now this is checked inside a consolidated function SystemDictionaryShared::should_be_excluded() [5] Now we have 2 separate hashtable to look up shared classes: one for the built-in classes and the other for unregistered classes. This simplifies the lookup logic and is also faster. [6] A lot of old code was deleted. There's a net change of about -250 lines of C code.
09-11-2018