changeset 13044:710d02eae915

ShenandoahMinRegionSize should be 256K to allow small heaps.
author shade
date Fri, 03 Mar 2017 13:28:37 +0100
parents b1d87ff3b89a
children f8a19195242b
files src/share/vm/gc/shenandoah/shenandoahHeapRegion.cpp src/share/vm/gc/shenandoah/shenandoah_globals.hpp test/gc/shenandoah/TestRegionSizeArgs.java
diffstat 3 files changed, 49 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/shenandoah/shenandoahHeapRegion.cpp	Mon Feb 27 13:57:51 2017 +0100
+++ b/src/share/vm/gc/shenandoah/shenandoahHeapRegion.cpp	Fri Mar 03 13:28:37 2017 +0100
@@ -279,19 +279,30 @@
   uintx region_size;
   if (FLAG_IS_DEFAULT(ShenandoahHeapRegionSize)) {
     if (ShenandoahMinRegionSize > initial_heap_size / MIN_NUM_REGIONS) {
-      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option");
+      err_msg message("Initial heap size (" SIZE_FORMAT "K) is too low to afford the minimum number "
+                      "of regions (" SIZE_FORMAT ") of minimum region size (" SIZE_FORMAT "K).",
+                      initial_heap_size/K, MIN_NUM_REGIONS, ShenandoahMinRegionSize/K);
+      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message);
     }
     if (ShenandoahMinRegionSize < MIN_REGION_SIZE) {
-      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option");
+      err_msg message("" SIZE_FORMAT "K should not be lower than minimum region size (" SIZE_FORMAT "K).",
+                      ShenandoahMinRegionSize/K,  MIN_REGION_SIZE/K);
+      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message);
     }
     if (ShenandoahMinRegionSize < MinTLABSize) {
-      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option");
+      err_msg message("" SIZE_FORMAT "K should not be lower than TLAB size size (" SIZE_FORMAT "K).",
+                      ShenandoahMinRegionSize/K,  MinTLABSize/K);
+      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message);
     }
     if (ShenandoahMaxRegionSize < MIN_REGION_SIZE) {
-      vm_exit_during_initialization("Invalid -XX:ShenandoahMaxRegionSize option");
+      err_msg message("" SIZE_FORMAT "K should not be lower than min region size (" SIZE_FORMAT "K).",
+                      ShenandoahMaxRegionSize/K,  MIN_REGION_SIZE/K);
+      vm_exit_during_initialization("Invalid -XX:ShenandoahMaxRegionSize option", message);
     }
     if (ShenandoahMinRegionSize > ShenandoahMaxRegionSize) {
-      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize or -XX:ShenandoahMaxRegionSize");
+      err_msg message("Minimum (" SIZE_FORMAT "K) should be larger than maximum (" SIZE_FORMAT "K).",
+                      ShenandoahMinRegionSize/K, ShenandoahMaxRegionSize/K);
+      vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize or -XX:ShenandoahMaxRegionSize", message);
     }
     size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
     region_size = MAX2(average_heap_size / ShenandoahTargetNumRegions,
@@ -303,10 +314,15 @@
 
   } else {
     if (ShenandoahHeapRegionSize > initial_heap_size / MIN_NUM_REGIONS) {
-      vm_exit_during_initialization("Invalid -XX:ShenandoahHeapRegionSize option");
+      err_msg message("Initial heap size (" SIZE_FORMAT "K) is too low to afford the minimum number "
+                              "of regions (" SIZE_FORMAT ") of requested size (" SIZE_FORMAT "K).",
+                      initial_heap_size/K, MIN_NUM_REGIONS, ShenandoahHeapRegionSize/K);
+      vm_exit_during_initialization("Invalid -XX:ShenandoahHeapRegionSize option", message);
     }
     if (ShenandoahHeapRegionSize < MIN_REGION_SIZE) {
-      vm_exit_during_initialization("Invalid -XX:ShenandoahHeapRegionSize option");
+      err_msg message("" SIZE_FORMAT " should not be lower than min region size (" SIZE_FORMAT "K).",
+                      ShenandoahHeapRegionSize/K,  MIN_REGION_SIZE/K);
+      vm_exit_during_initialization("Invalid -XX:ShenandoahHeapRegionSize option", message);
     }
     region_size = ShenandoahHeapRegionSize;
   }
--- a/src/share/vm/gc/shenandoah/shenandoah_globals.hpp	Mon Feb 27 13:57:51 2017 +0100
+++ b/src/share/vm/gc/shenandoah/shenandoah_globals.hpp	Fri Mar 03 13:28:37 2017 +0100
@@ -52,7 +52,7 @@
           "Size of the Shenandoah regions. "                                \
           "Determined automatically by default.")                           \
                                                                             \
-  experimental(size_t, ShenandoahMinRegionSize, 1 * M,                      \
+  experimental(size_t, ShenandoahMinRegionSize, 256 * K,                    \
           "Minimum heap region size. ")                                     \
                                                                             \
   experimental(size_t, ShenandoahMaxRegionSize, 32 * M,                     \
--- a/test/gc/shenandoah/TestRegionSizeArgs.java	Mon Feb 27 13:57:51 2017 +0100
+++ b/test/gc/shenandoah/TestRegionSizeArgs.java	Fri Mar 03 13:28:37 2017 +0100
@@ -45,6 +45,31 @@
 
         {
             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",
+                                                                      "-Xms2m",
+                                                                      "-version");
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+            output.shouldMatch("Initial heap size");
+            output.shouldHaveExitValue(1);
+        }
+
+        {
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",
+                                                                      "-Xms4m",
+                                                                      "-version");
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+            output.shouldHaveExitValue(0);
+        }
+
+        {
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",
+                                                                      "-Xms8m",
+                                                                      "-version");
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+            output.shouldHaveExitValue(0);
+        }
+
+        {
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseShenandoahGC",
                                                                       "-Xms100m",
                                                                       "-XX:ShenandoahHeapRegionSize=200m",
                                                                       "-version");