8205024: ZGC: Worker threads boost mode not always enabled when is should be
authorpliden
Fri, 15 Jun 2018 13:31:36 +0200
changeset 50583 f0ff230e2546
parent 50582 6464882498b5
child 50584 0eae3ed86296
8205024: ZGC: Worker threads boost mode not always enabled when is should be Reviewed-by: stefank, eosterlund
src/hotspot/share/gc/z/zDriver.cpp
--- a/src/hotspot/share/gc/z/zDriver.cpp	Fri Jun 15 13:31:27 2018 +0200
+++ b/src/hotspot/share/gc/z/zDriver.cpp	Fri Jun 15 13:31:36 2018 +0200
@@ -146,6 +146,27 @@
   return false;
 }
 
+static bool should_boost_worker_threads() {
+  // Boost worker threads if one or more allocations have stalled
+  const bool stalled = ZHeap::heap()->is_alloc_stalled();
+  if (stalled) {
+    // Boost
+    return true;
+  }
+
+  // Boost worker threads if implied by the GC cause
+  const GCCause::Cause cause = ZCollectedHeap::heap()->gc_cause();
+  if (cause == GCCause::_wb_full_gc ||
+      cause == GCCause::_java_lang_system_gc ||
+      cause == GCCause::_metadata_GC_clear_soft_refs) {
+    // Boost
+    return true;
+  }
+
+  // Don't boost
+  return false;
+}
+
 class ZMarkStartClosure : public ZOperationClosure {
 public:
   virtual const char* name() const {
@@ -164,6 +185,10 @@
     const bool clear = should_clear_soft_references();
     ZHeap::heap()->set_soft_reference_policy(clear);
 
+    // Setup boost mode
+    const bool boost = should_boost_worker_threads();
+    ZHeap::heap()->set_boost_worker_threads(boost);
+
     ZCollectedHeap::heap()->increment_total_collections(true /* full */);
 
     ZHeap::heap()->mark_start();
@@ -277,11 +302,6 @@
   GCCauseSetter _gc_cause_setter;
   ZStatTimer    _timer;
 
-  bool should_boost_worker_threads(GCCause::Cause cause) const {
-    return cause == GCCause::_java_lang_system_gc ||
-           cause == GCCause::_z_allocation_stall;
-  }
-
 public:
   ZDriverCycleScope(GCCause::Cause cause) :
       _gc_id(),
@@ -289,10 +309,6 @@
       _timer(ZPhaseCycle) {
     // Update statistics
     ZStatCycle::at_start();
-
-    // Set boost mode
-    const bool boost = should_boost_worker_threads(cause);
-    ZHeap::heap()->set_boost_worker_threads(boost);
   }
 
   ~ZDriverCycleScope() {