changeset 59248:ef2f2bc93009

8244759: Shenandoah: print verbose class unloading counters Reviewed-by: zgu
author shade
date Tue, 12 May 2020 08:25:17 +0200
parents addc5830cb79
children 41eda049431b
files src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp src/hotspot/share/gc/shenandoah/shenandoahUnload.hpp
diffstat 4 files changed, 63 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Tue May 12 00:47:27 2020 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Tue May 12 08:25:17 2020 +0200
@@ -2878,7 +2878,7 @@
 
 void ShenandoahHeap::entry_class_unloading() {
   static const char* msg = "Concurrent class unloading";
-  ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_class_unloading);
+  ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_class_unload);
   EventMark em("%s", msg);
 
   ShenandoahWorkerScope scope(workers(),
--- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Tue May 12 00:47:27 2020 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Tue May 12 08:25:17 2020 +0200
@@ -93,7 +93,16 @@
   f(conc_weak_roots,                                "Concurrent Weak Roots")           \
   SHENANDOAH_PAR_PHASE_DO(conc_weak_roots_,         "  CWR: ", f)                      \
   f(conc_cleanup_early,                             "Concurrent Cleanup")              \
-  f(conc_class_unloading,                           "Concurrent Class Unloading")      \
+  f(conc_class_unload,                              "Concurrent Class Unloading")      \
+  f(conc_class_unload_unlink,                       "  Unlink Stale")                  \
+  f(conc_class_unload_unlink_sd,                    "    System Dictionary")           \
+  f(conc_class_unload_unlink_weak_klass,            "    Weak Class Links")            \
+  f(conc_class_unload_unlink_code_roots,            "    Code Roots")                  \
+  f(conc_class_unload_rendezvous,                   "  Rendezvous")                    \
+  f(conc_class_unload_purge,                        "  Purge Unlinked")                \
+  f(conc_class_unload_purge_coderoots,              "    Code Roots")                  \
+  f(conc_class_unload_purge_cldg,                   "    CLDG")                        \
+  f(conc_class_unload_purge_ec,                     "    Exception Caches")            \
   f(conc_strong_roots,                              "Concurrent Strong Roots")         \
   SHENANDOAH_PAR_PHASE_DO(conc_strong_roots_,       "  CSR: ", f)                      \
   f(conc_evac,                                      "Concurrent Evacuation")           \
--- a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp	Tue May 12 00:47:27 2020 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp	Tue May 12 08:25:17 2020 +0200
@@ -37,6 +37,7 @@
 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
 #include "gc/shenandoah/shenandoahLock.hpp"
+#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
 #include "gc/shenandoah/shenandoahRootProcessor.hpp"
 #include "gc/shenandoah/shenandoahUnload.hpp"
 #include "gc/shenandoah/shenandoahVerifier.hpp"
@@ -135,30 +136,6 @@
   DependencyContext::cleaning_start();
 }
 
-void ShenandoahUnload::unlink() {
-  SuspendibleThreadSetJoiner sts;
-  bool unloading_occurred;
-  ShenandoahHeap* const heap = ShenandoahHeap::heap();
-  {
-    MutexLocker cldg_ml(ClassLoaderDataGraph_lock);
-    unloading_occurred = SystemDictionary::do_unloading(heap->gc_timer());
-  }
-
-  Klass::clean_weak_klass_links(unloading_occurred);
-  ShenandoahCodeRoots::unlink(ShenandoahHeap::heap()->workers(), unloading_occurred);
-  DependencyContext::cleaning_end();
-}
-
-void ShenandoahUnload::purge() {
-  {
-    SuspendibleThreadSetJoiner sts;
-    ShenandoahCodeRoots::purge(ShenandoahHeap::heap()->workers());
-  }
-
-  ClassLoaderDataGraph::purge();
-  CodeCache::purge_exception_caches();
-}
-
 class ShenandoahUnloadRendezvousClosure : public HandshakeClosure {
 public:
   ShenandoahUnloadRendezvousClosure() : HandshakeClosure("ShenandoahUnloadRendezvous") {}
@@ -167,19 +144,65 @@
 
 void ShenandoahUnload::unload() {
   assert(ShenandoahConcurrentRoots::can_do_concurrent_class_unloading(), "Why we here?");
-  if (!ShenandoahHeap::heap()->is_concurrent_weak_root_in_progress()) {
+
+  ShenandoahHeap* heap = ShenandoahHeap::heap();
+
+  if (!heap->is_concurrent_weak_root_in_progress()) {
     return;
   }
 
   // Unlink stale metadata and nmethods
-  unlink();
+  {
+    ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_unlink);
+
+    SuspendibleThreadSetJoiner sts;
+    bool unloadingOccurred;
+    {
+      ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_unlink_sd);
+      MutexLocker cldgMl(ClassLoaderDataGraph_lock);
+      unloadingOccurred = SystemDictionary::do_unloading(heap->gc_timer());
+    }
+
+    {
+      ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_unlink_weak_klass);
+      Klass::clean_weak_klass_links(unloadingOccurred);
+    }
+
+    {
+      ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_unlink_code_roots);
+      ShenandoahCodeRoots::unlink(heap->workers(), unloadingOccurred);
+    }
+
+    DependencyContext::cleaning_end();
+  }
 
   // Make sure stale metadata and nmethods are no longer observable
-  ShenandoahUnloadRendezvousClosure cl;
-  Handshake::execute(&cl);
+  {
+    ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_rendezvous);
+    ShenandoahUnloadRendezvousClosure cl;
+    Handshake::execute(&cl);
+  }
 
   // Purge stale metadata and nmethods that were unlinked
-  purge();
+  {
+    ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_purge);
+
+    {
+      ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_purge_coderoots);
+      SuspendibleThreadSetJoiner sts;
+      ShenandoahCodeRoots::purge(heap->workers());
+    }
+
+    {
+      ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_purge_cldg);
+      ClassLoaderDataGraph::purge();
+    }
+
+    {
+      ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_purge_ec);
+      CodeCache::purge_exception_caches();
+    }
+  }
 }
 
 void ShenandoahUnload::finish() {
--- a/src/hotspot/share/gc/shenandoah/shenandoahUnload.hpp	Tue May 12 00:47:27 2020 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUnload.hpp	Tue May 12 08:25:17 2020 +0200
@@ -35,9 +35,6 @@
   void prepare();
   void unload();
   void finish();
-private:
-  void unlink();
-  void purge();
 };
 
 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCLASSUNLOAD_HPP