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



   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.


   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:

     -> 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.


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

I am waiting to run RBT tests on other platforms.

- Ioi

More information about the hotspot-runtime-dev mailing list