Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8196991

Revamp G1 JMX MemoryPool and GarbageCollector MXBean definitions

    Details

    • Type: CSR
    • Status: Draft
    • Priority: P4
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      gc
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Other
    • Scope:
      JDK

      Description

      Summary

      The current JMX memory pool and collector definitions for the G1 collector don't reflect reality well, thus should be replaced with ones that do. I expect to ask for a backport to a JDK 11 update release, and possibly JDK 8, so users can transition their code independent of a JDK 8/10 to JDK 11 migration.

      Problem

      See Summary.

      Solution

      An attempt was made to merge old and new definitions in a compatible way, but foundered on the problem of iterating over G1s GarbageCollectorMXBeans: old and new versions would overlap functionality in ways that cannot be reconciled. The new definitions will be the default, but for compatibility, a new -XX:+G1UseLegacyMonitoring Hotspot switch will revert to the current definitions.

      The three existing MemoryPoolMXBeans

      "G1 Eden Space"      : eden
      "G1 Survivor Space"  : survivor space
      "G1 Old Gen"         : old generation, including humongous regions

      are replaced with six

      "G1 Eden Space"     : eden
      "G1 Survivor Space" : survivor space
      "G1 Old Space"      : old generation (now a "space" rather than a "gen", and does not include regions containing humongous or archive objects)
      "G1 Humongous Space": humongous space (regions containing humongous objects)
      "G1 Archive Space"  : class data sharing metadata space, a read-only space
      "G1 Free Space"     : free space

      These six spaces are address-wise disjoint, though logically the "G1 Archive Space" is part of the "G1 Old Space". All existing code assumes that memory pools are address-wise disjoint.

      The new "G1 Humongous Space" has usage thresholds enabled. Only the "G1 Old Space" has thresholds enabled in the legacy model.

      The new "G1 Archive Space"' Usage property's init, committed and used sub-attributes are all the same value, and its max sub-attribute is -1.

      The new "G1 Free Space" represents the part of the heap that is not in the other five spaces. The six spaces cover the entire heap address range, just as for the other collectors. Its Usage init, committed, and used sub-attributes are respectively its initial size (most of the heap), its committed size, and its current virtual size. Its max sub-attribute is -1.

      Memory pool Usage.max sub-attributes are the maximum heap size (-Xmx) for the "G1 Old Space" and -1 (undefined) for the other memory pools. For all collectors (Serial, Parallel, and G1), the sum of all heap memory pools' positive Usage.max values is the maximum heap size. Also for all collectors, the sum of positive "max" values minus the sum of "committed" values results in the total uncommitted memory.

      For G1, "committed" and "used" values for all spaces other than the "G1 Free Space" will be the same, net of allocation regions' internal free space. I.e., "used" values do not include internal allocation region free space and are thus always less than or equal to "committed" values, which latter are an integral multiple of the region size. Inversely, the "G1 Free Space"'s "used" value includes allocation regions' internal free space, and will always be greater than or equal to its "committed" value.

      For collectors other than G1, the sum of all heap memory pools' positive "max" values minus the sum of "used" values results in the total free memory. For G1, the total free memory is the "G1 Free Space"'s "used" value.


      The two existing GarbageCollectorMXBeans

      "G1 Young Generation" : incremental collector, pure young and mixed collections
      "G1 Old Generation"   : stop-the-world full heap collector

      are replaced with four. They and the memory pools they affect are

      "G1 Young" : incremental pure young generation collector
          "G1 Eden Space"
          "G1 Survivor Space"
          "G1 Humongous Space"
          "G1 Free Space"
      "G1 Mixed" : incremental young + partially old collector
          "G1 Eden Space"
          "G1 Survivor Space"
          "G1 Humongous Space"
          "G1 Old Space"
          "G1 Free Space"
      "G1 Full" : stop-the-world full heap collector
          "G1 Eden Space"
          "G1 Survivor Space"
          "G1 Humongous Space"
          "G1 Old Space"
          "G1 Archive Space"
          "G1 Free Space"
      "G1 Concurrent Cycle" : a concurrent cycle
          "G1 Humongous Space"
          "G1 Old Space"
          "G1 Free Space"

      The CollectionTime attribute for the "G1 Concurrent Cycle" collector is the total of a concurrent cycle's stop-the-world wall clock time. An associated young collection is reported as a separate event.

      Because the "G1 Archive Space" is logically part of the old generation, it is associated with the "G1 Full" GarbageCollector, but it will never be collected.


      JFR currently identifies three garbage collectors, New, Old, and Full. These correspond to the "G1 Young", "G1 Mixed", and "G1 Full" collectors, respectively. There are no changes to JFR event definitions.

      Specification

      No JMX specification change is necessary, since the per-JVM ManagementFactory and per-collector GarbageCollector MXBeans MemoryPools are left undefined by the specification.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                phh Paul Hohensee
                Reporter:
                phh Paul Hohensee
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: