8201487: Do not rebalance reference processing queues if not doing parallel reference processing
authortschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49808 f1dcdc3cd6b7
parent 49807 fe4156ef739b
child 49809 ef5220d644e3
8201487: Do not rebalance reference processing queues if not doing parallel reference processing Reviewed-by: sangheki, kbarrett
src/hotspot/share/gc/shared/referenceProcessor.cpp
test/hotspot/jtreg/gc/logging/TestPrintReferences.java
--- a/src/hotspot/share/gc/shared/referenceProcessor.cpp	Wed Apr 18 11:36:48 2018 +0200
+++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp	Wed Apr 18 11:36:48 2018 +0200
@@ -794,16 +794,7 @@
 
   phase_times->set_processing_is_mt(mt_processing);
 
-  // If discovery used MT and a dynamic number of GC threads, then
-  // the queues must be balanced for correctness if fewer than the
-  // maximum number of queues were used.  The number of queue used
-  // during discovery may be different than the number to be used
-  // for processing so don't depend of _num_q < _max_num_q as part
-  // of the test.
-  bool must_balance = _discovery_is_mt;
-
-  if ((mt_processing && ParallelRefProcBalancingEnabled) ||
-      must_balance) {
+  if (mt_processing && ParallelRefProcBalancingEnabled) {
     RefProcBalanceQueuesTimeTracker tt(phase_times);
     balance_queues(refs_lists);
   }
--- a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java	Wed Apr 18 11:36:48 2018 +0200
+++ b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java	Wed Apr 18 11:36:48 2018 +0200
@@ -54,30 +54,36 @@
   static final String gcLogTimeRegex = ".* GC\\([0-9]+\\) ";
 
   public static void main(String[] args) throws Exception {
-    ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder("-Xlog:gc+phases+ref=debug",
-                                                                      "-XX:+UseG1GC",
-                                                                      "-Xmx32M",
-                                                                      // Explicit thread setting is required to avoid using only 1 thread
-                                                                      "-XX:ParallelGCThreads=2",
-                                                                      GCTest.class.getName());
-    OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start());
-
-    checkLogFormat(output);
-    checkLogValue(output);
-
-    output.shouldHaveExitValue(0);
+    test(true);
+    test(false);
   }
 
   static String indent(int count) {
     return " {" + count + "}";
   }
 
+  public static void test(boolean parallelRefProcEnabled) throws Exception {
+    ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder("-Xlog:gc+phases+ref=debug",
+                                                                      "-XX:+UseG1GC",
+                                                                      "-Xmx32M",
+                                                                      // Explicit thread setting is required to avoid using only 1 thread
+                                                                      "-XX:" + (parallelRefProcEnabled ? "+" : "-") + "ParallelRefProcEnabled",
+                                                                      "-XX:ParallelGCThreads=2",
+                                                                      GCTest.class.getName());
+    OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start());
+
+    checkLogFormat(output, parallelRefProcEnabled);
+    checkLogValue(output);
+
+    output.shouldHaveExitValue(0);
+  }
+
   // Find the first Reference Processing log and check its format.
-  public static void checkLogFormat(OutputAnalyzer output) {
+  public static void checkLogFormat(OutputAnalyzer output, boolean parallelRefProcEnabled) {
     String countRegex = "[0-9]+";
     String timeRegex = doubleRegex + "ms";
     String totalRegex = gcLogTimeRegex + indent(4) + referenceProcessing + ": " + timeRegex + "\n";
-    String balanceRegex = gcLogTimeRegex + indent(8) + "Balance queues: " + timeRegex + "\n";
+    String balanceRegex = parallelRefProcEnabled ? gcLogTimeRegex + indent(8) + "Balance queues: " + timeRegex + "\n" : "";
     String softRefRegex = gcLogTimeRegex + indent(6) + softReference + ": " + timeRegex + "\n";
     String weakRefRegex = gcLogTimeRegex + indent(6) + weakReference + ": " + timeRegex + "\n";
     String finalRefRegex = gcLogTimeRegex + indent(6) + finalReference + ": " + timeRegex + "\n";