RFR (L) 8072061: Automatically determine optimal sizes for the CDS regions

Ioi Lam ioi.lam at oracle.com
Thu Jun 29 22:55:04 UTC 2017


https://bugs.openjdk.java.net/browse/JDK-8072061
http://cr.openjdk.java.net/~iklam/jdk10/8072061-auto-size-cds-region.v10/

------------------------------------------------------------------------------
Motivation:

   The CDS archive is divided in several regions such as RO, RW, etc. In
   JDK 9, when you are dumping with a custom classlist, you must manually
   specify the region sizes using flags such as -XX:SharedReadOnlySize.
   This is error prone and cumbersome.

   This RFE makes it possible to automatically determine the optimal sizes
   of the regions.

Overview:

   With this RFE, during CDS dump time, all class metadata are first
   allocated outside of the shared regions. Then, we scan all of the
   reachable metadata objects, determine whether they are RO or RW, and
   then copy them into the destination regions.

   After all objects are copied, we scan and relocate all the pointers to
   point to the new copies.

Notes to reviewers:

   To implement the copy and relocation operations, we have added the new
   MetaspaceClosure API for walking all the reachablemetadata objects, and
   scanning all the pointers embedded in these objects.

   Please start in metaspaceShared.cppand follow the code path:

     ArchiveCompactor::copy_and_compact()
     -> iterate_roots()
       -> SystemDictionary::classes_do(it)
         -> Dictionary::classes_do(MetaspaceClosure* it)
-> it->push(probe->klass_addr())

   At this point you will get into metaspaceClosure.hpp. Please read the
   comments around MetaspaceClosure::Ref about the (lack of) C++ vtables,
   and why the template classes ObjectRef, PrimitiveArrayRef and
   PointerArrayRef are needed.

   Once you understand how ObjectRefand PointerArrayRef work, you can
   see that the above it->push(probe->klass_addr()) call will be invoking
   this template method:

      template <class T> void push(T** mpp, Writability w = _default) {
        ObjectRef<T> ref(mpp);
        push_impl(&ref, w);
      }

   which will eventually call into Klass::metaspace_pointers_do(), which
   will eventually recursively iterate over all the Klasses, Methods,
   ConstantPools and other types of MetaspaceObj.

Testingstatus:

   All CDS tests have passed locally on Linux. All new tests have been
implemented.

I am waiting to run RBT tests on other platforms.

Thanks
- Ioi


More information about the hotspot-runtime-dev mailing list