8232001: ZGC: Ignore metaspace GC threshold until GC is warm
authorpliden
Mon, 21 Oct 2019 09:51:24 +0200
changeset 58701 5d10ba4a0468
parent 58700 f87353679927
child 58702 215308c0d5e8
8232001: ZGC: Ignore metaspace GC threshold until GC is warm Reviewed-by: eosterlund
src/hotspot/share/gc/z/zDirector.cpp
src/hotspot/share/gc/z/zDirector.hpp
src/hotspot/share/gc/z/zDriver.cpp
src/hotspot/share/gc/z/zStat.cpp
src/hotspot/share/gc/z/zStat.hpp
--- a/src/hotspot/share/gc/z/zDirector.cpp	Mon Oct 21 14:04:16 2019 +0800
+++ b/src/hotspot/share/gc/z/zDirector.cpp	Mon Oct 21 09:51:24 2019 +0200
@@ -48,14 +48,6 @@
                        ZStatAllocRate::avg_sd() / M);
 }
 
-bool ZDirector::is_first() const {
-  return ZStatCycle::ncycles() == 0;
-}
-
-bool ZDirector::is_warm() const {
-  return ZStatCycle::ncycles() >= 3;
-}
-
 bool ZDirector::rule_timer() const {
   if (ZCollectionInterval == 0) {
     // Rule disabled
@@ -73,7 +65,7 @@
 }
 
 bool ZDirector::rule_warmup() const {
-  if (is_warm()) {
+  if (ZStatCycle::is_warm()) {
     // Rule disabled
     return false;
   }
@@ -93,7 +85,7 @@
 }
 
 bool ZDirector::rule_allocation_rate() const {
-  if (is_first()) {
+  if (ZStatCycle::is_first()) {
     // Rule disabled
     return false;
   }
@@ -140,7 +132,7 @@
 }
 
 bool ZDirector::rule_proactive() const {
-  if (!ZProactive || !is_warm()) {
+  if (!ZProactive || !ZStatCycle::is_warm()) {
     // Rule disabled
     return false;
   }
--- a/src/hotspot/share/gc/z/zDirector.hpp	Mon Oct 21 14:04:16 2019 +0800
+++ b/src/hotspot/share/gc/z/zDirector.hpp	Mon Oct 21 09:51:24 2019 +0200
@@ -36,9 +36,6 @@
 
   void sample_allocation_rate() const;
 
-  bool is_first() const;
-  bool is_warm() const;
-
   bool rule_timer() const;
   bool rule_warmup() const;
   bool rule_allocation_rate() const;
--- a/src/hotspot/share/gc/z/zDriver.cpp	Mon Oct 21 14:04:16 2019 +0800
+++ b/src/hotspot/share/gc/z/zDriver.cpp	Mon Oct 21 09:51:24 2019 +0200
@@ -250,11 +250,17 @@
   case GCCause::_z_allocation_stall:
   case GCCause::_z_proactive:
   case GCCause::_z_high_usage:
-  case GCCause::_metadata_GC_threshold:
     // Start asynchronous GC
     _gc_cycle_port.send_async(cause);
     break;
 
+  case GCCause::_metadata_GC_threshold:
+    // Start asynchronous GC, but only if the GC is warm
+    if (ZStatCycle::is_warm()) {
+      _gc_cycle_port.send_async(cause);
+    }
+    break;
+
   case GCCause::_gc_locker:
     // Restart VM operation previously blocked by the GC locker
     _gc_locker_port.signal();
--- a/src/hotspot/share/gc/z/zStat.cpp	Mon Oct 21 14:04:16 2019 +0800
+++ b/src/hotspot/share/gc/z/zStat.cpp	Mon Oct 21 09:51:24 2019 +0200
@@ -1049,6 +1049,14 @@
   _normalized_duration.add(normalized_duration);
 }
 
+bool ZStatCycle::is_first() {
+  return _ncycles == 0;
+}
+
+bool ZStatCycle::is_warm() {
+  return _ncycles >= 3;
+}
+
 uint64_t ZStatCycle::ncycles() {
   return _ncycles;
 }
--- a/src/hotspot/share/gc/z/zStat.hpp	Mon Oct 21 14:04:16 2019 +0800
+++ b/src/hotspot/share/gc/z/zStat.hpp	Mon Oct 21 09:51:24 2019 +0200
@@ -374,6 +374,8 @@
   static void at_start();
   static void at_end(double boost_factor);
 
+  static bool is_first();
+  static bool is_warm();
   static uint64_t ncycles();
   static const AbsSeq& normalized_duration();
   static double time_since_last();