RFR (S): 8195115: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results

mandy chung mandy.chung at oracle.com
Fri Jan 26 20:53:39 UTC 2018

Hi Erik,

The proposal you outline below is reasonable.  The API was designed to
allow any number of memory pools managed by a memory manager that
can represent different phases of a garbage collector or other
resource manager to expose various metrics.  How G1 exposes these
monitoring metrics is implementation specific.

More comments inlined below.

On 1/25/18, 5:27 AM, "Erik Helin" <erik.helin at oracle.com> wrote:

>      Hi Paul,
>      thanks for your interest in this area and for your patch! The
>      GarbageCollectorMXBean and MemoryPoolMXBean support for G1 is in need of
>      some updates, so thanks for working on this.
>      Looking at your patch, I'm not sure that this is the direction we want
>      to go in. I discussed this a bit with Thomas and Stefan J, and our
>      current line of thinking is the following:
>      - Memory pools (MemoryMXBean):
>         - "G1 Eden Regions"
>         - "G1 Survivor Regions"
>         - "G1 Old Regions"
>         - "G1 Humongous Regions"
>         - "G1 Archive Regions" (if CDS and/or AppCDS is used)

Can you describe more about G1 archive regions?  Is it an immutable region
that no object will be added or removed?

>      `init` for these pools would be 0, `used` would be total size of the
>      "live" objects in the used regions of that type, `committed` the total
>      size of the used regions of that that type and `max` would be
>      MaxHeapSize. Note that "live" here means live from the GCs point of
>      view, i.e. an object might be dead in an old region but the GC will
>      consider that object live until a concurrent cycle has marked through
>      the heap and deemed it dead.

As specified in MemoryPoolMXBean spec, for MemoryPoolMXBean::getUsage of
a garbage-collected memory pool, the amount of used memory includes the
memory occupied by all objects in the pool including both reachable
and unreachable objects.

OTOH, getCollectionUsage returns the memory usage after JVM most recently
expended effort in recycling unused objects in this memory pool.  It
would depend on what a GC cycle is defined for G1 and at what phase
G1 can record the "collection usage" with low overhead.  Definitely
the API does not request G1 to perform any GC-like action and "collection
usage" reports how much memory is used at most recent GC cycle after some
memory has been reclaimed.

>      - Collectors (GarbageCollectorMXBean):
>         - "G1 Young Collector" with the pools
>           - "G1 Eden Regions"
>           - "G1 Survivor Regions"
>           - "G1 Humongous Regions" (due to early reclamation)
>         - "G1 Mixed Collector" with the pools
>           - "G1 Eden Regions"
>           - "G1 Survivor Regions"
>           - "G1 Old Regions"
>           - "G1 Humongous Regions" (due to early reclamation)
>         - "G1 Full Collector" with the pools
>           - "G1 Eden Regions"
>           - "G1 Survivor Regions"
>           - "G1 Old Regions"
>           - "G1 Humongous Regions" (can collect empty humongous regions)
>         - "G1 Concurrent Cycle" with the pools
>           - "G1 Old Regions" (can collect empty old regions)
>           - "G1 Humongous Regions" (can collect empty humongous regions)
>      Note that with this design, the
>      GarbageCollectorMXBean::getCollectionTime() method for "G1 Concurrent
>      Cycle" would be the wall clock time from start of the first initial mark
>      to end of the last cleanup (also including the time of any eventual
>      young collection during the concurrent cycle). So
>      GarbageCollectorMXBean::getCollectionTime() would be a mix of concurrent
>      and STW time for the GarbageCollectorMXBean with name "G1 Concurrent Cycle".

GarbageCollectorMXBean API was defined prior to G1.  It's a future
enhancement to investigate how to represent the concurrent garbage
collection metrics for better monitoring purpose.  Do you have any
thought for monitoring of G1 GC metrics besides memory usage?

>      Also note that the MemoryPoolMXBean with name "G1 Archive Regions" will
>      not be attached to any GarbageCollectorMXBean, since those regions will
>      never be collected.
>      What do you think about this design, would it work for your use case?
>      If we want to go ahead with this design, then I think we might have to
>      file a CSR. David (who is the HotSpot CSR representative), do we have to
>      file a CSR for changing the names of MemoryPoolMXBeans and
>      GarbageCollectorMXBeans?

The names are not a supported interface but I'm not surprised applications
may depend on the names.  CSR as well as a release note to document
this change is reasonable.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20180126/025ed999/attachment.htm>

More information about the hotspot-gc-dev mailing list