8207756: ZGC: jstat should show CGC STW phases
authorpliden
Thu, 09 Aug 2018 11:24:30 +0200 (2018-08-09)
changeset 51343 da5b0111c93c
parent 51342 2b3b7db9b889
child 51344 7504e7937183
8207756: ZGC: jstat should show CGC STW phases Reviewed-by: pliden, ysuenaga, eosterlund Contributed-by: yasuenag@gmail.com, per.liden@oracle.com
src/hotspot/share/gc/shared/vmGCOperations.hpp
src/hotspot/share/gc/z/zDriver.cpp
src/hotspot/share/gc/z/zServiceability.cpp
src/hotspot/share/gc/z/zServiceability.hpp
--- a/src/hotspot/share/gc/shared/vmGCOperations.hpp	Thu Aug 09 15:42:48 2018 +0800
+++ b/src/hotspot/share/gc/shared/vmGCOperations.hpp	Thu Aug 09 11:24:30 2018 +0200
@@ -227,7 +227,7 @@
  private:
   JvmtiGCMarker _jgcm;
  public:
-  typedef enum { MINOR, FULL, CONCURRENT, OTHER } reason_type;
+  typedef enum { MINOR, FULL, CONCURRENT } reason_type;
 
   SvcGCMarker(reason_type reason ) {
     VM_GC_Operation::notify_gc_begin(reason == FULL);
--- a/src/hotspot/share/gc/z/zDriver.cpp	Thu Aug 09 15:42:48 2018 +0800
+++ b/src/hotspot/share/gc/z/zDriver.cpp	Thu Aug 09 11:24:30 2018 +0200
@@ -98,7 +98,7 @@
     ZStatSample(ZSamplerJavaThreads, Threads::number_of_threads());
 
     // JVMTI support
-    SvcGCMarker sgcm(SvcGCMarker::OTHER);
+    SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
 
     // Setup GC id
     GCIdMark gcid(_gc_id);
--- a/src/hotspot/share/gc/z/zServiceability.cpp	Thu Aug 09 15:42:48 2018 +0800
+++ b/src/hotspot/share/gc/z/zServiceability.cpp	Thu Aug 09 11:24:30 2018 +0200
@@ -33,13 +33,13 @@
 class ZOldGenerationCounters : public GenerationCounters {
 public:
   ZOldGenerationCounters(const char* name, size_t min_capacity, size_t max_capacity) :
-    // The "1, 1" parameters are for the n-th generation (=1) with 1 space.
-    GenerationCounters(name,
-                       1 /* ordinal */,
-                       1 /* spaces */,
-                       min_capacity /* min_capacity */,
-                       max_capacity /* max_capacity */,
-                       min_capacity /* curr_capacity */) {}
+      // The "1, 1" parameters are for the n-th generation (=1) with 1 space.
+      GenerationCounters(name,
+                         1 /* ordinal */,
+                         1 /* spaces */,
+                         min_capacity /* min_capacity */,
+                         max_capacity /* max_capacity */,
+                         min_capacity /* curr_capacity */) {}
 
   virtual void update_all() {
     size_t committed = ZHeap::heap()->capacity();
@@ -50,26 +50,36 @@
 // Class to expose perf counters used by jstat.
 class ZServiceabilityCounters : public CHeapObj<mtGC> {
 private:
-  ZOldGenerationCounters _old_collection_counters;
+  ZOldGenerationCounters _old_generation_counters;
   HSpaceCounters         _old_space_counters;
+  CollectorCounters      _collector_counters;
 
 public:
   ZServiceabilityCounters(size_t min_capacity, size_t max_capacity);
 
+  CollectorCounters* collector_counters();
+
   void update_sizes();
 };
 
 ZServiceabilityCounters::ZServiceabilityCounters(size_t min_capacity, size_t max_capacity) :
     // generation.1
-    _old_collection_counters("old",
+    _old_generation_counters("old",
                              min_capacity,
                              max_capacity),
     // generation.1.space.0
-    _old_space_counters(_old_collection_counters.name_space(),
+    _old_space_counters(_old_generation_counters.name_space(),
                         "space",
                         0 /* ordinal */,
                         max_capacity /* max_capacity */,
-                        min_capacity /* init_capacity */) {}
+                        min_capacity /* init_capacity */),
+    // gc.collector.2
+    _collector_counters("stop-the-world",
+                        2 /* ordinal */) {}
+
+CollectorCounters* ZServiceabilityCounters::collector_counters() {
+  return &_collector_counters;
+}
 
 void ZServiceabilityCounters::update_sizes() {
   if (UsePerfData) {
@@ -79,7 +89,7 @@
     _old_space_counters.update_capacity(capacity);
     _old_space_counters.update_used(used);
 
-    _old_collection_counters.update_all();
+    _old_generation_counters.update_all();
 
     MetaspaceCounters::update_performance_counters();
     CompressedClassSpaceCounters::update_performance_counters();
@@ -147,10 +157,8 @@
            is_gc_end   /* recordGCEndTime */,
            is_gc_end   /* countCollection */) {}
 
-ZServiceabilityCountersTracer::ZServiceabilityCountersTracer() {
-  // Nothing to trace with TraceCollectorStats, since ZGC has
-  // neither a young collector nor a full collector.
-}
+ZServiceabilityCountersTracer::ZServiceabilityCountersTracer() :
+    _stats(ZHeap::heap()->serviceability_counters()->collector_counters()) {}
 
 ZServiceabilityCountersTracer::~ZServiceabilityCountersTracer() {
   ZHeap::heap()->serviceability_counters()->update_sizes();
--- a/src/hotspot/share/gc/z/zServiceability.hpp	Thu Aug 09 15:42:48 2018 +0800
+++ b/src/hotspot/share/gc/z/zServiceability.hpp	Thu Aug 09 11:24:30 2018 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #ifndef SHARE_GC_Z_ZSERVICEABILITY_HPP
 #define SHARE_GC_Z_ZSERVICEABILITY_HPP
 
+#include "gc/shared/collectorCounters.hpp"
 #include "memory/allocation.hpp"
 #include "services/memoryManager.hpp"
 #include "services/memoryPool.hpp"
@@ -76,6 +77,9 @@
 };
 
 class ZServiceabilityCountersTracer {
+private:
+  TraceCollectorStats _stats;
+
 public:
   ZServiceabilityCountersTracer();
   ~ZServiceabilityCountersTracer();