8154745: Move default G1 pause time target setup to argument parsing
authormgerdin
Tue, 19 Apr 2016 14:53:32 +0200
changeset 38012 69916710bfed
parent 38011 74a6871d896b
child 38013 89b93eb018fb
8154745: Move default G1 pause time target setup to argument parsing Reviewed-by: ehelin, sjohanss
hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
hotspot/src/share/vm/runtime/globals.hpp
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Thu Apr 21 10:19:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Tue Apr 19 14:53:32 2016 +0200
@@ -47,43 +47,6 @@
   // unaligned values for the heap.
   HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
   HeapRegionRemSet::setup_remset_size();
-
-  // Below, we might need to calculate the pause time target based on
-  // the pause interval. When we do so we are going to give G1 maximum
-  // flexibility and allow it to do pauses when it needs to. So, we'll
-  // arrange that the pause interval to be pause time target + 1 to
-  // ensure that a) the pause time target is maximized with respect to
-  // the pause interval and b) we maintain the invariant that pause
-  // time target < pause interval. If the user does not want this
-  // maximum flexibility, they will have to set the pause interval
-  // explicitly.
-
-  // First make sure that, if either parameter is set, its value is
-  // reasonable.
-  guarantee(MaxGCPauseMillis >= 1, "Range checking for MaxGCPauseMillis should guarantee that value is >= 1");
-
-  // Then, if the pause time target parameter was not set, set it to
-  // the default value.
-  if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
-    if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
-      // The default pause time target in G1 is 200ms
-      FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
-    } else {
-      // We do not allow the pause interval to be set without the
-      // pause time target
-      vm_exit_during_initialization("GCPauseIntervalMillis cannot be set "
-                                    "without setting MaxGCPauseMillis");
-    }
-  }
-
-  // Then, if the interval parameter was not set, set it according to
-  // the pause time target (this will also deal with the case when the
-  // pause time target is the default value).
-  if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
-    FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
-  }
-  guarantee(GCPauseIntervalMillis >= 1, "Constraint for GCPauseIntervalMillis should guarantee that value is >= 1");
-  guarantee(GCPauseIntervalMillis > MaxGCPauseMillis, "Constraint for GCPauseIntervalMillis should guarantee that GCPauseIntervalMillis > MaxGCPauseMillis");
 }
 
 void G1CollectorPolicy::initialize_alignments() {
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Thu Apr 21 10:19:00 2016 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Tue Apr 19 14:53:32 2016 +0200
@@ -2116,6 +2116,28 @@
     FLAG_SET_DEFAULT(GCTimeRatio, 12);
   }
 
+  // Below, we might need to calculate the pause time interval based on
+  // the pause target. When we do so we are going to give G1 maximum
+  // flexibility and allow it to do pauses when it needs to. So, we'll
+  // arrange that the pause interval to be pause time target + 1 to
+  // ensure that a) the pause time target is maximized with respect to
+  // the pause interval and b) we maintain the invariant that pause
+  // time target < pause interval. If the user does not want this
+  // maximum flexibility, they will have to set the pause interval
+  // explicitly.
+
+  if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
+    // The default pause time target in G1 is 200ms
+    FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
+  }
+
+  // Then, if the interval parameter was not set, set it according to
+  // the pause time target (this will also deal with the case when the
+  // pause time target is the default value).
+  if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
+    FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
+  }
+
   log_trace(gc)("MarkStackSize: %uk  MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
   log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);
 }
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Thu Apr 21 10:19:00 2016 +0200
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Tue Apr 19 14:53:32 2016 +0200
@@ -599,6 +599,14 @@
                                 value);
         return Flag::VIOLATES_CONSTRAINT;
       }
+
+      if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
+        CommandLineError::print(verbose,
+                                "GCPauseIntervalMillis cannot be set "
+                                "without setting MaxGCPauseMillis\n");
+        return Flag::VIOLATES_CONSTRAINT;
+      }
+
       if (value <= MaxGCPauseMillis) {
         CommandLineError::print(verbose,
                                 "GCPauseIntervalMillis (" UINTX_FORMAT ") must be "
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu Apr 21 10:19:00 2016 +0200
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Tue Apr 19 14:53:32 2016 +0200
@@ -2221,11 +2221,11 @@
           "Adaptive size policy maximum GC pause time goal in millisecond, "\
           "or (G1 Only) the maximum GC time per MMU time slice")            \
           range(1, max_uintx - 1)                                           \
-          constraint(MaxGCPauseMillisConstraintFunc,AfterMemoryInit)        \
+          constraint(MaxGCPauseMillisConstraintFunc,AfterErgo)              \
                                                                             \
   product(uintx, GCPauseIntervalMillis, 0,                                  \
           "Time slice for MMU specification")                               \
-          constraint(GCPauseIntervalMillisConstraintFunc,AfterMemoryInit)   \
+          constraint(GCPauseIntervalMillisConstraintFunc,AfterErgo)         \
                                                                             \
   product(uintx, MaxGCMinorPauseMillis, max_uintx,                          \
           "Adaptive size policy maximum GC minor pause time goal "          \