RFR: Patch for JDK-8225216: gc/logging/TestMetaSpaceLog.java doesn't work for Shenandoah

Nilsen, Kelvin kdnilsen at amazon.com
Thu Mar 12 05:14:03 UTC 2020


 The original problem report is available at https://bugs.openjdk.java.net/browse/JDK-8225216

I have confirmed that, with this patch, I can build the patched tip and the following regression test now succeeds:

  $ make images run-test TEST=gc/logging/TestMetaSpaceLog.java TEST_VM_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC" 
  
The draft patch consists of the following.   I am not authorized to directly apply this patch so will need a "sponsor" to apply the patch when it is judged ready.

--- old/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp	2020-03-11 22:10:58.000000000 -0700
+++ new/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp	2020-03-11 22:10:58.000000000 -0700
@@ -178,6 +178,9 @@
     if (gc_requested) {
       heap->reset_bytes_allocated_since_gc_start();
 
+      // Use default constructor to snapshot the Metaspace state before GC.
+      metaspace::MetaspaceSizesSnapshot meta_sizes;
+
       // If GC was requested, we are sampling the counters even without actual triggers
       // from allocation machinery. This captures GC phases more accurately.
       set_forced_counters_update(true);
@@ -187,28 +190,24 @@
         ShenandoahHeapLocker locker(heap->lock());
         heap->free_set()->log_status();
       }
-    }
 
-    switch (mode) {
-      case none:
-        break;
-      case concurrent_traversal:
-        service_concurrent_traversal_cycle(cause);
-        break;
-      case concurrent_normal:
-        service_concurrent_normal_cycle(cause);
-        break;
-      case stw_degenerated:
-        service_stw_degenerated_cycle(cause, degen_point);
-        break;
-      case stw_full:
-        service_stw_full_cycle(cause);
-        break;
-      default:
-        ShouldNotReachHere();
-    }
+      switch (mode) {
+        case concurrent_traversal:
+          service_concurrent_traversal_cycle(cause);
+          break;
+        case concurrent_normal:
+          service_concurrent_normal_cycle(cause);
+          break;
+        case stw_degenerated:
+          service_stw_degenerated_cycle(cause, degen_point);
+          break;
+        case stw_full:
+          service_stw_full_cycle(cause);
+          break;
+        default:
+          ShouldNotReachHere();
+      }
 
-    if (gc_requested) {
       // If this was the requested GC cycle, notify waiters about it
       if (explicit_gc_requested || implicit_gc_requested) {
         notify_gc_waiters();
@@ -244,6 +243,9 @@
         heuristics->clear_metaspace_oom();
       }
 
+      // Print Metaspace change following GC (if logging is enabled).
+      MetaspaceUtils::print_metaspace_change(meta_sizes);
+
       // GC is over, we are at idle now
       if (ShenandoahPacing) {
         heap->pacer()->setup_for_idle();
--- old/test/hotspot/jtreg/TEST.groups	2020-03-11 22:10:59.000000000 -0700
+++ new/test/hotspot/jtreg/TEST.groups	2020-03-11 22:10:59.000000000 -0700
@@ -243,6 +243,7 @@
   gc/ergonomics/TestInitialGCThreadLogging.java \
   gc/ergonomics/TestDynamicNumberOfGCThreads.java \
   gc/logging/TestGCId.java \
+  gc/logging/TestMetaSpaceLog.java \
   gc/metaspace/TestMetaspacePerfCounters.java \
   gc/metaspace/TestMetaspacePerfCounters.java \
   gc/startup_warnings/TestShenandoah.java \
--- old/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java	2020-03-11 22:11:00.000000000 -0700
+++ new/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java	2020-03-11 22:11:00.000000000 -0700
@@ -45,7 +45,6 @@
  *          java.management
  * @requires vm.gc != "Epsilon"
  * @requires vm.gc != "Z"
- * @requires vm.gc != "Shenandoah"
  *
  * @compile TestMetaSpaceLog.java
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox



More information about the shenandoah-dev mailing list