changeset 7948:83dc7e55f715 jdk8u102-b02

8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr Reviewed-by: jmasa, drwhite
author poonam
date Mon, 04 Apr 2016 10:59:22 -0700
parents 58fdc4a7c328
children 448a5dcf414f 01745e531a0a
files src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp test/TEST.groups test/gc/ergonomics/TestDynamicNumberOfGCThreads.java
diffstat 3 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp	Tue Mar 29 13:05:07 2016 +0100
+++ b/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp	Mon Apr 04 10:59:22 2016 -0700
@@ -193,8 +193,9 @@
      (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
     new_active_workers = total_workers;
   } else {
+    uintx min_workers = (total_workers == 1) ? 1 : 2;
     new_active_workers = calc_default_active_workers(total_workers,
-                                                     2, /* Minimum number of workers */
+                                                     min_workers,
                                                      active_workers,
                                                      application_workers);
   }
--- a/test/TEST.groups	Tue Mar 29 13:05:07 2016 +0100
+++ b/test/TEST.groups	Mon Apr 04 10:59:22 2016 -0700
@@ -215,6 +215,7 @@
   runtime/NMT \
   gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java \
   gc/class_unloading/TestG1ClassUnloadingHWM.java \
+  gc/ergonomics/TestDynamicNumberOfGCThreads.java \
   gc/g1/TestRegionAlignment.java \
   gc/g1/TestShrinkToOneRegion.java \
   gc/metaspace/G1AddMetaspaceDependency.java \
--- a/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java	Tue Mar 29 13:05:07 2016 +0100
+++ b/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java	Mon Apr 04 10:59:22 2016 -0700
@@ -44,14 +44,24 @@
   }
 
   private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output) {
+    output.shouldHaveExitValue(0); // test should run succesfully
     output.shouldContain("new_active_workers");
-    output.shouldHaveExitValue(0);
   }
 
   private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception {
     // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
-    ProcessBuilder pb_enabled =
-      ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-Xmx10M", "-XX:+PrintGCDetails",  "-XX:+UseDynamicNumberOfGCThreads", "-XX:+TraceDynamicGCThreads", GCTest.class.getName());
+    String[] baseArgs = {"-XX:+" + gcFlag, "-Xmx10M", "-XX:+PrintGCDetails",  "-XX:+UseDynamicNumberOfGCThreads", "-XX:+TraceDynamicGCThreads", GCTest.class.getName()};
+
+    // Base test with gc and +UseDynamicNumberOfGCThreads:
+    ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs);
+    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
+
+    // Ensure it also works on uniprocessors or if user specifies -XX:ParallelGCThreads=1:
+    String[] extraArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+ForceDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=1"};
+    String[] finalArgs = new String[baseArgs.length + extraArgs.length];
+    System.arraycopy(extraArgs, 0, finalArgs, 0,                extraArgs.length);
+    System.arraycopy(baseArgs,  0, finalArgs, extraArgs.length, baseArgs.length);
+    pb_enabled = ProcessTools.createJavaProcessBuilder(finalArgs);
     verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
   }