RFR (M): 8014659: NPG: performance counters for compressed klass space

Erik Helin erik.helin at oracle.com
Tue Aug 20 09:12:41 UTC 2013


On 2013-08-19, Jon Masamitsu wrote:
> 
> On 8/19/13 2:41 AM, Erik Helin wrote:
> >On 2013-08-16, Jon Masamitsu wrote:
> >>Erik,
> >>
> >>Changes look good.
> >Thanks!
> >
> >On 2013-08-16, Jon Masamitsu wrote:
> >>Is it correct that MetaspaceCounters will include counters for ClassType
> >>and NonClassType metadata if UseCompressedClassPointers is false?
> >The class MetaspaceCounters (representing the counters in namespace
> >"sun.gc.metaspace") always includes both ClassType and NonClassType
> >metadata, regardless whether compressed class pointers are used or not.
> Would the count for ClassType in MetaspaceCounters always be 0 if
> compressed class pointers is turned "on", yes.

Looking at the code in http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/:

In src/share/vm/metaspace.cpp, assuming compressed class pointers:
  In Metaspace::initialize() _class_vm will be set to a new SpaceManager
  with metadata type ClassType.

  Then class_vsm()->add_chunk() is called which is SpaceManager::add_chunk.
  SpaceManager::add_chunk calls SpaceManager::inc_size_metric which will
  execute MetaspaceAux::inc_used(mdtype(), Metachunk::overhead()).
  mdtype() will here be ClassType for _class_vsm.

  MetaspaceAux::inc_used with mdtype ClassType will increment
  _allocated_used_words[ClassType].

In src/share/vm/metaspaceCounters.cpp:
  MetaspaceCounters::initialize_performance_counters will call
  MetaspaceAux::allocated_used_bytes. MetaspaceAux::allocated_used_bytes
  calls allocated_used_words which is implemented as:

    static size_t allocated_used_words() {
      return _allocated_used_words[Metaspace::NonClassType] +
             (Metaspace::using_class_space() ?
             _allocated_used_words[Metaspace::ClassType] : 0);
    }

  Metaspace::using_class_space() will return true and MetaspaceCounters
  will therefore report a non-zero count for ClassType metadata.

So, to summarize, the metaspace performance counters, sun.gc.metaspace.*,
will always report the total count for all of metadata, regardless
whether compressed class pointers are used or not.

Thanks,
Erik

> Jon
> >
> >On 2013-08-16, Jon Masamitsu wrote:
> >>And only for NonClassType if UseCompressedClassPointers is true?
> >No, the class MetaspaceCounters always include all kinds of metadata.
> >
> >The class CompressedClassCounters (representing the namespace
> >"sun.gc.compressedclassspace") only includes ClassType metadata if
> >compressed class pointers are used. If compressed class pointers are *not*
> >used, then these counters are always 0.
> >
> >
> >On 2013-08-16, Jon Masamitsu wrote:
> >>And that's the way the MemoryPools are also divided?
> >No :( Thanks for catching this Jon, this is wrong. I would like the
> >memory pools to follow the same pattern:
> >- MetaspaceMemoryPool: Always measures all kinds of metadata
> >- CompressedClassSpaceMemoryPool: Only measures compressed class space.
> >   Always zero or undefined in compressed class pointers aren't used.
> >
> >As of now, the MetaspaceMemoryPool only measures NonClassType metadata.
> >
> >I'll create a new bug and send out a patch fixing this.
> >
> >Again, thanks for reviewing Jon, really appreciate it.
> >
> >Erik
> >
> >>Jon
> >>
> >>On 8/14/2013 7:49 AM, Erik Helin wrote:
> >>>Hi all,
> >>>
> >>>this change adds performance counters for compressed class space.
> >>>
> >>>Webrev:
> >>>http://cr.openjdk.java.net/~ehelin/8014659/webrev.00/
> >>>
> >>>Changes to hotspot:
> >>>The main changes are in metaspaceCounters.hpp and metaspaceCounters.cpp,
> >>>where the class MetaspaceCounters has been split up into
> >>>MetaspaceCounters and MetaspacePerfCounters. MetaspaceCounters now owns
> >>>an instance of MetaspacePerfCounters. The class
> >>>CompressedClassSpaceCounters has been added which also has its own
> >>>instance of MetaspacePerfCounters. MetaspacePerfCounters initializes and
> >>>updates the actual performance counters.
> >>>
> >>>The changes in metaspace.hpp/cpp were needed to get some additional data
> >>>from the metaspace data structures. The method
> >>>free_chunks_in_total(mdtype) was made public and the method
> >>>free_bytes(mdtype) was added. Some common functionality was extracted
> >>>into get_space_list(mdtype) which got rid of some duplicated code.
> >>>
> >>>The changes in:
> >>>- g1MonitorinSupport.cpp
> >>>- parallelScavengeHeap.cpp
> >>>- genCollectedHeap.cpp
> >>>- universe.cpp
> >>>are only "one-liners" that either update or initialize the new performance
> >>>counters.
> >>>
> >>>Changes to the testlibrary:
> >>>- Added Asserts.java for writing asserts like "assertTrue",
> >>>   "assertEquals", etc.
> >>>- Added PerfCounter.java and PerfCounters.java to make it easy to
> >>>   inspect performance counters for the currently running VM.
> >>>- Added InputArguments.java so a test can check the arguments it got
> >>>   passed.
> >>>- Added InMemoryJavaCompiler.java for compiling a string into bytecode.
> >>>   Useful for loading classes generated at runtime without using files.
> >>>- Added ByteCodeLoader.java for defining a new class when you already
> >>>   have the bytecode.
> >>>
> >>>Testing:
> >>>- Added the new test TestMetaspacePerfCounters.java
> >>>- JPRT
> >>>
> >>>Bug:
> >>>http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8014659
> >>>
> >>>Thanks,
> >>>Erik
> 



More information about the hotspot-gc-dev mailing list