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

Make MetaspaceReclaimPolicy a diagnostic switch

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • hotspot
    • behavioral
    • low
    • Hide
      Customers using this may find it not working anymore without unlock option. But I don't think anyone really uses this switch.

      A cursory Google search showed no meaningful mentioning of this switch, in particular no findings at all for setting it to the non-default modes. Ditto for Github.
      Show
      Customers using this may find it not working anymore without unlock option. But I don't think anyone really uses this switch. A cursory Google search showed no meaningful mentioning of this switch, in particular no findings at all for setting it to the non-default modes. Ditto for Github.
    • add/remove/modify command line option
    • JDK

      Summary

      Make MetaspaceReclaimPolicy a diagnostic switch

      Problem

      JEP-387 revamped Metaspace and, among other things, introduced the product switch MetaspaceReclaimPolicy. The switch switches between three different behavioral modes:

      1) MetaspaceReclaimPolicy=balanced (default) attempts to reclaim Metaspace upon class loader death

      2) MetaspaceReclaimPolicy=aggressive does the same but more enthusiastically;

      The difference between them is minor; Metaspace has an inbuilt granularity with which memory is committed and uncommitted - 64K by default, 16K in aggressive mode. In practice, it did not matter much: aggressive mode would lead to slightly more reclaimed memory at the cost of slightly more VMA fragmentation.

      3) MetaspaceReclaimPolicy=none forfeits memory reclamation altogether. This is a larger break from the other two modes and leads to a bunch of special-path coding in metaspace.

      These three modes lead to different code paths that all need to get tested separately to prevent regressions. MetaspaceReclaimPolicy=none, in particular, also makes the code more complex.

      The original purpose of this switch, especially the "none" mode, was to have a fallback in case of errors. But post-JEP-387-Metaspace has been very stable and robust; there was never a need for this fallback.

      Solution

      I would like to make MetaspaceReclaimPolicy a diagnostic switch, with the expressed freedom to decrease later the number of permutations and/or to completely remove the switch as a user-facing control, without further CSRs.

      Specification

      --- a/src/hotspot/share/runtime/globals.hpp
      +++ b/src/hotspot/share/runtime/globals.hpp
      @@ -1423,7 +1423,7 @@ const int ObjectAlignmentInBytes = 8;
                 "Force the class space to be allocated at this address or "       \
                 "fails VM initialization (requires -Xshare=off.")                 \
                                                                                   \
      -  product(ccstr, MetaspaceReclaimPolicy, "balanced",                        \
      +  product(ccstr, MetaspaceReclaimPolicy, "balanced", DIAGNOSTIC,            \
                 "options: balanced, aggressive, none")                            \
                                                                                   \
         product(bool, PrintMetaspaceStatisticsAtExit, false, DIAGNOSTIC,          \

            stuefe Thomas Stuefe
            stuefe Thomas Stuefe
            Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: