JDK-8201572 : Improve Metaspace reporting
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-04-16
  • Updated: 2018-06-06
  • Resolved: 2018-05-07
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 11 JDK 12
11 b13Fixed 12Resolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Metaspace reporting and the underlying coding can be improved in a number of ways:

- The number of times we have to walk the CLDG or other metaspace structures can be reduced. The existing code walks the data structures often to retrieve single values. That is often inefficient, it would be better to collect all values in a single walk.

- There are a lot of redundant reporting code which produces identical or similar output.

- The jcmd VM.metaspace command can be made much more useful than it is now, by showing more details about class loaders, metaspace types etc.

---------------

Update: the final form of this patch greatly extends the capabilities of the "VM.metaspace" diagnostic command:

<quote>
VM.metaspace
Prints the statistics for the metaspace
....
Options: (options must be specified using the <key> or <key>=<value> syntax)
        basic : [optional] Prints a basic summary (does not need a safepoint). (BOOLEAN, false)
        show-loaders : [optional] Shows usage by class loader. (BOOLEAN, false)
        by-chunktype : [optional] Break down numbers by chunk type. (BOOLEAN, false)
        by-spacetype : [optional] Break down numbers by loader type. (BOOLEAN, false)
        vslist : [optional] Shows details about the underlying virtual space. (BOOLEAN, false)
        vsmap : [optional] Shows chunk composition of the underlying virtual spaces (BOOLEAN, false)
        scale : [optional] Memory usage in which to scale. Valid values are: 1, KB, MB or GB (fixed scale) or "dynamic" for a dynamically choosen scale. (STRING, dynamic)
</quote>

- a new sub option "by-chunktype" allows to optionally get statistics by metaspace chunk type.
- a new sub option "by-spacetype" allows to optionally get statistics by metaspace space type. This allows for easier accounting of metaspace usage to e.g. reflection, anonymous classes etc
- a new sub option "show-loaders" was added to optionally print metaspace consumption by loader.
- a new sub option "vslist" was added to print out details about the underlying virtual space mapping lists
- a new sub option "vsmap" was added to print out an ascii map detailing the chunk composition of the various space nodes.
- a new sub option "basic" was added to print out basic details of metaspace consumption which can be collected without safepoint and without drawing a lock. That report can be used in places where a "normal" metaspace report is considered too dangerous (a normal report walks the CLDG and draws metaspace locks). For example, as part of logging in case of a Metaspace OOM, or as part of the hs-err log file.

In addition to these new options, the following improvements and corrections were added:
- a new output section was added, "Metaspace Waste", which tries to detail typical metaspace waste scenarios. That makes it easier for support to quickly pinpoint typical pathological cases.
- a new section was added to print chunk freelists.
- the existing sub option "scale" was extended by a value "0" which means "dynamic scaling". That means, the most fitting scale is choosen by the report (e.g "KB" for values smaller than 1MB).
- printout was made clearer in the face of rounding errors
- printout contains percentages.



Comments
hgupdate HG Updates added a comment - 3 days ago URL: http://hg.openjdk.java.net/jdk/jdk/rev/57dd7b4ba338 User: stuefe Date: 2018-05-04 06:41:16 +0000 Fix was pushed while main bug was targeted to '12'. Reset the main bug to fixed in '11' and copied the hgupdater entry here.
07-05-2018