changeset 57767:7c606c26d02a

8237586: Shenandoah: provide option to disable periodic GC Reviewed-by: zgu
author shade
date Tue, 21 Jan 2020 20:58:48 +0100
parents 49a11875e369
children 24f7289e61e3 6500cac59d0f
files src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java
diffstat 3 files changed, 54 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp	Tue Jan 21 18:23:21 2020 -0800
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp	Tue Jan 21 20:58:48 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2020, Red Hat, Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -245,13 +245,16 @@
     return true;
   }
 
-  double last_time_ms = (os::elapsedTime() - _last_cycle_end) * 1000;
-  bool periodic_gc = (last_time_ms > ShenandoahGuaranteedGCInterval);
-  if (periodic_gc) {
-    log_info(gc)("Trigger: Time since last GC (%.0f ms) is larger than guaranteed interval (" UINTX_FORMAT " ms)",
-                  last_time_ms, ShenandoahGuaranteedGCInterval);
+  if (ShenandoahGuaranteedGCInterval > 0) {
+    double last_time_ms = (os::elapsedTime() - _last_cycle_end) * 1000;
+    if (last_time_ms > ShenandoahGuaranteedGCInterval) {
+      log_info(gc)("Trigger: Time since last GC (%.0f ms) is larger than guaranteed interval (" UINTX_FORMAT " ms)",
+                   last_time_ms, ShenandoahGuaranteedGCInterval);
+      return true;
+    }
   }
-  return periodic_gc;
+
+  return false;
 }
 
 bool ShenandoahHeuristics::should_degenerate_cycle() {
--- a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp	Tue Jan 21 18:23:21 2020 -0800
+++ b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp	Tue Jan 21 20:58:48 2020 +0100
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016, 2019, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2016, 2020, Red Hat, Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -141,10 +141,11 @@
           "to duration(marking)+duration(update-refs).")                    \
                                                                             \
   experimental(uintx, ShenandoahGuaranteedGCInterval, 5*60*1000,            \
-          "Adaptive and dynamic heuristics would guarantee a GC cycle "     \
-          "at least with this interval. This is useful when large idle"     \
-          " intervals are present, where GC can run without stealing "      \
-          "time from active application. Time is in milliseconds.")         \
+          "Most heuristics would guarantee a concurrent GC cycle at "       \
+          "least with this interval. This is useful when large idle "       \
+          "intervals are present, where GC can run without stealing "       \
+          "time from active application. Time is in milliseconds. "         \
+          "(Setting this interval to 0 disables this feature).")            \
                                                                             \
   experimental(bool, ShenandoahAlwaysClearSoftRefs, false,                  \
           "Clear soft references always, instead of using any smart "       \
--- a/test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java	Tue Jan 21 18:23:21 2020 -0800
+++ b/test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java	Tue Jan 21 20:58:48 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,17 @@
         };
 
         for (String h : enabled) {
-            testWith("Short period with " + h,
+            testWith("Zero interval with " + h,
+                    false,
+                    "-Xlog:gc",
+                    "-XX:+UnlockDiagnosticVMOptions",
+                    "-XX:+UnlockExperimentalVMOptions",
+                    "-XX:+UseShenandoahGC",
+                    "-XX:ShenandoahGCHeuristics=" + h,
+                    "-XX:ShenandoahGuaranteedGCInterval=0"
+            );
+
+            testWith("Short interval with " + h,
                     true,
                     "-Xlog:gc",
                     "-XX:+UnlockDiagnosticVMOptions",
@@ -78,7 +88,7 @@
                     "-XX:ShenandoahGuaranteedGCInterval=1000"
             );
 
-            testWith("Long period with " + h,
+            testWith("Long interval with " + h,
                     false,
                     "-Xlog:gc",
                     "-XX:+UnlockDiagnosticVMOptions",
@@ -89,7 +99,17 @@
             );
         }
 
-        testWith("Short period with traversal mode",
+        testWith("Zero interval with traversal mode",
+                 false,
+                 "-Xlog:gc",
+                 "-XX:+UnlockDiagnosticVMOptions",
+                 "-XX:+UnlockExperimentalVMOptions",
+                 "-XX:+UseShenandoahGC",
+                 "-XX:ShenandoahGCMode=traversal",
+                 "-XX:ShenandoahGuaranteedGCInterval=0"
+        );
+
+        testWith("Short interval with traversal mode",
                  true,
                  "-Xlog:gc",
                  "-XX:+UnlockDiagnosticVMOptions",
@@ -99,7 +119,7 @@
                  "-XX:ShenandoahGuaranteedGCInterval=1000"
         );
 
-        testWith("Long period with traversal mode",
+        testWith("Long interval with traversal mode",
                  false,
                  "-Xlog:gc",
                  "-XX:+UnlockDiagnosticVMOptions",
@@ -109,7 +129,7 @@
                  "-XX:ShenandoahGuaranteedGCInterval=100000" // deliberately too long
         );
 
-        testWith("Short period with aggressive",
+        testWith("Short interval with aggressive",
                  false,
                  "-Xlog:gc",
                  "-XX:+UnlockDiagnosticVMOptions",
@@ -118,7 +138,18 @@
                  "-XX:ShenandoahGCHeuristics=aggressive",
                  "-XX:ShenandoahGuaranteedGCInterval=1000"
         );
-        testWith("Short period with passive",
+
+        testWith("Zero interval with passive",
+                 false,
+                 "-Xlog:gc",
+                 "-XX:+UnlockDiagnosticVMOptions",
+                 "-XX:+UnlockExperimentalVMOptions",
+                 "-XX:+UseShenandoahGC",
+                 "-XX:ShenandoahGCMode=passive",
+                 "-XX:ShenandoahGuaranteedGCInterval=0"
+        );
+
+        testWith("Short interval with passive",
                  false,
                  "-Xlog:gc",
                  "-XX:+UnlockDiagnosticVMOptions",