8227225: ParallelGC: add subspace transitions for young gen for gc+heap=info log lines
authortonyp
Tue, 06 Aug 2019 15:03:48 -0400
changeset 57662 f81dbe27a7b1
parent 57661 5cc8f9225a6d
child 57663 bf8e76d86d05
8227225: ParallelGC: add subspace transitions for young gen for gc+heap=info log lines Reviewed-by: tschatzl, kbarrett
src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp
src/hotspot/share/gc/parallel/psMarkSweep.cpp
src/hotspot/share/gc/parallel/psOldGen.cpp
src/hotspot/share/gc/parallel/psOldGen.hpp
src/hotspot/share/gc/parallel/psParallelCompact.cpp
src/hotspot/share/gc/parallel/psParallelCompact.hpp
src/hotspot/share/gc/parallel/psScavenge.cpp
src/hotspot/share/gc/parallel/psYoungGen.cpp
src/hotspot/share/gc/parallel/psYoungGen.hpp
src/hotspot/share/gc/shared/preGCValues.hpp
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp	Tue Aug 06 15:03:48 2019 -0400
@@ -616,6 +616,55 @@
       UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweepProxy::accumulated_time()->seconds());
 }
 
+PreGenGCValues ParallelScavengeHeap::get_pre_gc_values() const {
+  const PSYoungGen* const young = young_gen();
+  const MutableSpace* const eden = young->eden_space();
+  const MutableSpace* const from = young->from_space();
+  const MutableSpace* const to = young->to_space();
+  const PSOldGen* const old = old_gen();
+
+  return PreGenGCValues(young->used_in_bytes(),
+                        young->capacity_in_bytes(),
+                        eden->used_in_bytes(),
+                        eden->capacity_in_bytes(),
+                        from->used_in_bytes(),
+                        from->capacity_in_bytes(),
+                        old->used_in_bytes(),
+                        old->capacity_in_bytes());
+}
+
+void ParallelScavengeHeap::print_heap_change(const PreGenGCValues& pre_gc_values) const {
+  const PSYoungGen* const young = young_gen();
+  const MutableSpace* const eden = young->eden_space();
+  const MutableSpace* const from = young->from_space();
+  const PSOldGen* const old = old_gen();
+
+  log_info(gc, heap)(HEAP_CHANGE_FORMAT" "
+                     HEAP_CHANGE_FORMAT" "
+                     HEAP_CHANGE_FORMAT,
+                     HEAP_CHANGE_FORMAT_ARGS(young->name(),
+                                             pre_gc_values.young_gen_used(),
+                                             pre_gc_values.young_gen_capacity(),
+                                             young->used_in_bytes(),
+                                             young->capacity_in_bytes()),
+                     HEAP_CHANGE_FORMAT_ARGS("Eden",
+                                             pre_gc_values.eden_used(),
+                                             pre_gc_values.eden_capacity(),
+                                             eden->used_in_bytes(),
+                                             eden->capacity_in_bytes()),
+                     HEAP_CHANGE_FORMAT_ARGS("From",
+                                             pre_gc_values.from_used(),
+                                             pre_gc_values.from_capacity(),
+                                             from->used_in_bytes(),
+                                             from->capacity_in_bytes()));
+  log_info(gc, heap)(HEAP_CHANGE_FORMAT,
+                     HEAP_CHANGE_FORMAT_ARGS(old->name(),
+                                             pre_gc_values.old_gen_used(),
+                                             pre_gc_values.old_gen_capacity(),
+                                             old->used_in_bytes(),
+                                             old->capacity_in_bytes()));
+  MetaspaceUtils::print_metaspace_change(pre_gc_values.metaspace_sizes());
+}
 
 void ParallelScavengeHeap::verify(VerifyOption option /* ignored */) {
   // Why do we need the total_collections()-filter below?
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp	Tue Aug 06 15:03:48 2019 -0400
@@ -33,12 +33,12 @@
 #include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/gcPolicyCounters.hpp"
 #include "gc/shared/gcWhen.hpp"
+#include "gc/shared/preGCValues.hpp"
 #include "gc/shared/referenceProcessor.hpp"
 #include "gc/shared/softRefPolicy.hpp"
 #include "gc/shared/strongRootsScope.hpp"
 #include "logging/log.hpp"
 #include "memory/metaspace.hpp"
-#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/ostream.hpp"
 
@@ -224,6 +224,9 @@
   virtual void gc_threads_do(ThreadClosure* tc) const;
   virtual void print_tracing_info() const;
 
+  PreGenGCValues get_pre_gc_values() const;
+  void print_heap_change(const PreGenGCValues& pre_gc_values) const;
+
   void verify(VerifyOption option /* ignored */);
 
   // Resize the young generation.  The reserved space for the
@@ -251,27 +254,6 @@
   GCMemoryManager* young_gc_manager() const { return _young_manager; }
 };
 
-// Simple class for storing info about the heap at the start of GC, to be used
-// after GC for comparison/printing.
-class PreGCValues {
-public:
-  PreGCValues(ParallelScavengeHeap* heap) :
-      _heap_used(heap->used()),
-      _young_gen_used(heap->young_gen()->used_in_bytes()),
-      _old_gen_used(heap->old_gen()->used_in_bytes()) { }
-
-  size_t heap_used() const      { return _heap_used; }
-  size_t young_gen_used() const { return _young_gen_used; }
-  size_t old_gen_used() const   { return _old_gen_used; }
-  const metaspace::MetaspaceSizesSnapshot& metaspace_sizes() const { return _meta_sizes; }
-
-private:
-  size_t _heap_used;
-  size_t _young_gen_used;
-  size_t _old_gen_used;
-  const metaspace::MetaspaceSizesSnapshot _meta_sizes;
-};
-
 // Class that can be used to print information about the
 // adaptive size policy at intervals specified by
 // AdaptiveSizePolicyOutputInterval.  Only print information
--- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Tue Aug 06 15:03:48 2019 -0400
@@ -193,7 +193,7 @@
 
     BiasedLocking::preserve_marks();
 
-    const PreGCValues pre_gc_values(heap);
+    const PreGenGCValues pre_gc_values = heap->get_pre_gc_values();
 
     allocate_stacks();
 
@@ -348,9 +348,7 @@
       accumulated_time()->stop();
     }
 
-    young_gen->print_used_change(pre_gc_values.young_gen_used());
-    old_gen->print_used_change(pre_gc_values.old_gen_used());
-    MetaspaceUtils::print_metaspace_change(pre_gc_values.metaspace_sizes());
+    heap->print_heap_change(pre_gc_values);
 
     // Track memory usage and detect low memory
     MemoryService::track_memory_usage();
--- a/src/hotspot/share/gc/parallel/psOldGen.cpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psOldGen.cpp	Tue Aug 06 15:03:48 2019 -0400
@@ -443,11 +443,6 @@
   st->print("  object"); object_space()->print_on(st);
 }
 
-void PSOldGen::print_used_change(size_t prev_used) const {
-  log_info(gc, heap)("%s: "  SIZE_FORMAT "K->" SIZE_FORMAT "K("  SIZE_FORMAT "K)",
-      name(), prev_used / K, used_in_bytes() / K, capacity_in_bytes() / K);
-}
-
 void PSOldGen::update_counters() {
   if (UsePerfData) {
     _space_counters->update_all();
--- a/src/hotspot/share/gc/parallel/psOldGen.hpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psOldGen.hpp	Tue Aug 06 15:03:48 2019 -0400
@@ -198,7 +198,6 @@
   // Debugging - do not use for time critical operations
   virtual void print() const;
   virtual void print_on(outputStream* st) const;
-  void print_used_change(size_t prev_used) const;
 
   void verify();
   void verify_object_start_array();
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Tue Aug 06 15:03:48 2019 -0400
@@ -1779,7 +1779,7 @@
   // miscellaneous bookkeeping.
   pre_compact();
 
-  const PreGCValues pre_gc_values(heap);
+  const PreGenGCValues pre_gc_values = heap->get_pre_gc_values();
 
   // Get the compaction manager reserved for the VM thread.
   ParCompactionManager* const vmthread_cm =
@@ -1923,9 +1923,7 @@
       accumulated_time()->stop();
     }
 
-    young_gen->print_used_change(pre_gc_values.young_gen_used());
-    old_gen->print_used_change(pre_gc_values.old_gen_used());
-    MetaspaceUtils::print_metaspace_change(pre_gc_values.metaspace_sizes());
+    heap->print_heap_change(pre_gc_values);
 
     // Track memory usage and detect low memory
     MemoryService::track_memory_usage();
--- a/src/hotspot/share/gc/parallel/psParallelCompact.hpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.hpp	Tue Aug 06 15:03:48 2019 -0400
@@ -42,7 +42,6 @@
 class PSParallelCompact;
 class GCTaskManager;
 class GCTaskQueue;
-class PreGCValues;
 class MoveAndUpdateClosure;
 class RefProcTaskExecutor;
 class ParallelOldTracer;
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp	Tue Aug 06 15:03:48 2019 -0400
@@ -328,7 +328,7 @@
     reference_processor()->enable_discovery();
     reference_processor()->setup_policy(false);
 
-    const PreGCValues pre_gc_values(heap);
+    const PreGenGCValues pre_gc_values = heap->get_pre_gc_values();
 
     // Reset our survivor overflow.
     set_survivor_overflow(false);
@@ -598,9 +598,7 @@
       accumulated_time()->stop();
     }
 
-    young_gen->print_used_change(pre_gc_values.young_gen_used());
-    old_gen->print_used_change(pre_gc_values.old_gen_used());
-    MetaspaceUtils::print_metaspace_change(pre_gc_values.metaspace_sizes());
+    heap->print_heap_change(pre_gc_values);
 
     // Track memory usage and detect low memory
     MemoryService::track_memory_usage();
--- a/src/hotspot/share/gc/parallel/psYoungGen.cpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psYoungGen.cpp	Tue Aug 06 15:03:48 2019 -0400
@@ -766,12 +766,6 @@
   st->print("  to  "); to_space()->print_on(st);
 }
 
-// Note that a space is not printed before the [NAME:
-void PSYoungGen::print_used_change(size_t prev_used) const {
-  log_info(gc, heap)("%s: "  SIZE_FORMAT "K->" SIZE_FORMAT "K("  SIZE_FORMAT "K)",
-      name(), prev_used / K, used_in_bytes() / K, capacity_in_bytes() / K);
-}
-
 size_t PSYoungGen::available_for_expansion() {
   ShouldNotReachHere();
   return 0;
--- a/src/hotspot/share/gc/parallel/psYoungGen.hpp	Tue Aug 06 11:40:23 2019 -0400
+++ b/src/hotspot/share/gc/parallel/psYoungGen.hpp	Tue Aug 06 15:03:48 2019 -0400
@@ -180,7 +180,6 @@
   // Debugging - do not use for time critical operations
   void print() const;
   void print_on(outputStream* st) const;
-  void print_used_change(size_t prev_used) const;
   virtual const char* name() const { return "PSYoungGen"; }
 
   void verify();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/preGCValues.hpp	Tue Aug 06 15:03:48 2019 -0400
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, Twitter, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_GC_SHARED_PREGCVALUES_HPP
+#define SHARE_GC_SHARED_PREGCVALUES_HPP
+
+#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
+
+// Simple class for storing info about the heap at the start of GC, to be used
+// after GC for comparison/printing.
+class PreGenGCValues {
+public:
+  PreGenGCValues(size_t young_gen_used,
+                 size_t young_gen_capacity,
+                 size_t eden_used,
+                 size_t eden_capacity,
+                 size_t from_used,
+                 size_t from_capacity,
+                 size_t old_gen_used,
+                 size_t old_gen_capacity)
+      : _young_gen_used(young_gen_used),
+        _young_gen_capacity(young_gen_capacity),
+        _eden_used(eden_used),
+        _eden_capacity(eden_capacity),
+        _from_used(from_used),
+        _from_capacity(from_capacity),
+        _old_gen_used(old_gen_used),
+        _old_gen_capacity(old_gen_capacity) { }
+
+  size_t young_gen_used()     const { return _young_gen_used;     }
+  size_t young_gen_capacity() const { return _young_gen_capacity; }
+  size_t eden_used()          const { return _eden_used;          }
+  size_t eden_capacity()      const { return _eden_capacity;      }
+  size_t from_used()          const { return _from_used;          }
+  size_t from_capacity()      const { return _from_capacity;      }
+  size_t old_gen_used()       const { return _old_gen_used;       }
+  size_t old_gen_capacity()   const { return _old_gen_capacity;   }
+  const metaspace::MetaspaceSizesSnapshot& metaspace_sizes() const { return _meta_sizes; }
+
+private:
+  const size_t _young_gen_used;
+  const size_t _young_gen_capacity;
+  const size_t _eden_used;
+  const size_t _eden_capacity;
+  const size_t _from_used;
+  const size_t _from_capacity;
+  const size_t _old_gen_used;
+  const size_t _old_gen_capacity;
+  const metaspace::MetaspaceSizesSnapshot _meta_sizes;
+};
+
+#endif // SHARE_GC_SHARED_PREGCVALUES_HPP