JDK-8251392 : Consolidate Metaspace Statistics
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-08-11
  • Updated: 2021-05-24
  • Resolved: 2021-05-18
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 17
17 b23Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
There is a lot of duplicate coding when it comes to the consumption of Metaspace Statistics. 

Metaspace offers statistical APIs via `MetaspaceUtils::(reserved|committed|used)_(words|bytes)` for either the whole metaspace or non-class/class space separately. But many callers need some sort of combination of these values, which they keep in various data holder structures which all are named somewhat similarly and all do a very similar job. In particular, we have:

- MetaspaceSizesSnapshot (used for gc logs)
- MetaspaceSnapshot (used in NMT)
- MetaspaceSizes, MetaspaceSummary, JFRMetaspaceSummary (JFR)
- MetaspaceCounters, CompressedClassSpaceCounters, MetaspacePerfCounters (jstat performance counters)
- CompressedKlassSpacePool and MetaspacePool (used for MXBeans)

As much as possible coding should be unified.

In addition to that, all these callers share a common problem, in that retrieving individual statistical values via `MetaspaceUtils::(reserved|committed|used)_(words|bytes)` may yield inconsistent values. For example, "reserved" < "committed", or "committed" < "used". This is the cause of a variety of rare intermittent test errors in different areas, e.g. Performance counters (JDK-8163413, JDK-8153323), the gc log, the MemoryPoolMXBean and NMT (JDK-8237872).

Therefore an API should be added to retrieve statistical values (reserved, committed, used) in one go, and the returned values should be guaranteed to be in sync.
Comments
Changeset: 554caf33 Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2021-05-18 06:35:17 +0000 URL: https://git.openjdk.java.net/jdk/commit/554caf33a01ac9ca2e3e9170557e8348750f3971
18-05-2021

This is a cleanup change; while good to have, its not urgent for 16.
03-12-2020