8223575: add subspace transitions to gc+metaspace=info log lines
Reviewed-by: stuefe, tschatzl
--- a/src/hotspot/share/gc/g1/g1HeapTransition.cpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1HeapTransition.cpp Wed Jul 03 15:46:48 2019 -0400
@@ -35,7 +35,6 @@
_old_length = g1_heap->old_regions_count();
_archive_length = g1_heap->archive_regions_count();
_humongous_length = g1_heap->humongous_regions_count();
- _metaspace_used_bytes = MetaspaceUtils::used_bytes();
}
G1HeapTransition::G1HeapTransition(G1CollectedHeap* g1_heap) : _g1_heap(g1_heap), _before(g1_heap) { }
@@ -131,5 +130,5 @@
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
usage._humongous_used / K, ((after._humongous_length * HeapRegion::GrainBytes) - usage._humongous_used) / K);
- MetaspaceUtils::print_metaspace_change(_before._metaspace_used_bytes);
+ MetaspaceUtils::print_metaspace_change(_before._meta_sizes);
}
--- a/src/hotspot/share/gc/g1/g1HeapTransition.hpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1HeapTransition.hpp Wed Jul 03 15:46:48 2019 -0400
@@ -26,6 +26,7 @@
#define SHARE_GC_G1_G1HEAPTRANSITION_HPP
#include "gc/shared/plab.hpp"
+#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
class G1CollectedHeap;
@@ -36,7 +37,7 @@
size_t _old_length;
size_t _archive_length;
size_t _humongous_length;
- size_t _metaspace_used_bytes;
+ const metaspace::MetaspaceSizesSnapshot _meta_sizes;
Data(G1CollectedHeap* g1_heap);
};
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp Wed Jul 03 15:46:48 2019 -0400
@@ -38,6 +38,7 @@
#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"
@@ -257,19 +258,18 @@
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()),
- _metadata_used(MetaspaceUtils::used_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; }
- size_t metadata_used() const { return _metadata_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;
- size_t _metadata_used;
+ const metaspace::MetaspaceSizesSnapshot _meta_sizes;
};
// Class that can be used to print information about the
--- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp Wed Jul 03 15:46:48 2019 -0400
@@ -193,11 +193,7 @@
BiasedLocking::preserve_marks();
- // Capture metadata size before collection for sizing.
- size_t metadata_prev_used = MetaspaceUtils::used_bytes();
-
- size_t old_gen_prev_used = old_gen->used_in_bytes();
- size_t young_gen_prev_used = young_gen->used_in_bytes();
+ const PreGCValues pre_gc_values(heap);
allocate_stacks();
@@ -352,9 +348,9 @@
accumulated_time()->stop();
}
- young_gen->print_used_change(young_gen_prev_used);
- old_gen->print_used_change(old_gen_prev_used);
- MetaspaceUtils::print_metaspace_change(metadata_prev_used);
+ 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());
// Track memory usage and detect low memory
MemoryService::track_memory_usage();
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp Wed Jul 03 15:46:48 2019 -0400
@@ -1779,7 +1779,7 @@
// miscellaneous bookkeeping.
pre_compact();
- PreGCValues pre_gc_values(heap);
+ const PreGCValues pre_gc_values(heap);
// Get the compaction manager reserved for the VM thread.
ParCompactionManager* const vmthread_cm =
@@ -1925,7 +1925,7 @@
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.metadata_used());
+ MetaspaceUtils::print_metaspace_change(pre_gc_values.metaspace_sizes());
// Track memory usage and detect low memory
MemoryService::track_memory_usage();
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp Wed Jul 03 15:46:48 2019 -0400
@@ -328,7 +328,7 @@
reference_processor()->enable_discovery();
reference_processor()->setup_policy(false);
- PreGCValues pre_gc_values(heap);
+ const PreGCValues pre_gc_values(heap);
// Reset our survivor overflow.
set_survivor_overflow(false);
@@ -601,7 +601,7 @@
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.metadata_used());
+ MetaspaceUtils::print_metaspace_change(pre_gc_values.metaspace_sizes());
// Track memory usage and detect low memory
MemoryService::track_memory_usage();
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp Wed Jul 03 15:46:48 2019 -0400
@@ -575,9 +575,6 @@
ClearedAllSoftRefs casr(do_clear_all_soft_refs, soft_ref_policy());
- const size_t metadata_prev_used = MetaspaceUtils::used_bytes();
-
-
FlagSetting fl(_is_gc_active, true);
bool complete = full && (max_generation == OldGen);
@@ -586,6 +583,7 @@
size_t young_prev_used = _young_gen->used();
size_t old_prev_used = _old_gen->used();
+ const metaspace::MetaspaceSizesSnapshot prev_meta_sizes;
bool run_verification = total_collections() >= VerifyGCStartAt;
bool prepared_for_verification = false;
@@ -628,7 +626,7 @@
_young_gen->compute_new_size();
print_heap_change(young_prev_used, old_prev_used);
- MetaspaceUtils::print_metaspace_change(metadata_prev_used);
+ MetaspaceUtils::print_metaspace_change(prev_meta_sizes);
// Track memory usage and detect low memory after GC finishes
MemoryService::track_memory_usage();
@@ -687,7 +685,7 @@
update_full_collections_completed();
print_heap_change(young_prev_used, old_prev_used);
- MetaspaceUtils::print_metaspace_change(metadata_prev_used);
+ MetaspaceUtils::print_metaspace_change(prev_meta_sizes);
// Track memory usage and detect low memory after GC finishes
MemoryService::track_memory_usage();
--- a/src/hotspot/share/memory/metaspace.cpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/memory/metaspace.cpp Wed Jul 03 15:46:48 2019 -0400
@@ -471,9 +471,36 @@
return cm->chunk_free_list_summary();
}
-void MetaspaceUtils::print_metaspace_change(size_t prev_metadata_used) {
- log_info(gc, metaspace)("Metaspace: " SIZE_FORMAT "K->" SIZE_FORMAT "K(" SIZE_FORMAT "K)",
- prev_metadata_used/K, used_bytes()/K, reserved_bytes()/K);
+void MetaspaceUtils::print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values) {
+ const metaspace::MetaspaceSizesSnapshot meta_values;
+
+ if (Metaspace::using_class_space()) {
+ log_info(gc, metaspace)(HEAP_CHANGE_FORMAT" "
+ HEAP_CHANGE_FORMAT" "
+ HEAP_CHANGE_FORMAT,
+ HEAP_CHANGE_FORMAT_ARGS("Metaspace",
+ pre_meta_values.used(),
+ pre_meta_values.committed(),
+ meta_values.used(),
+ meta_values.committed()),
+ HEAP_CHANGE_FORMAT_ARGS("NonClass",
+ pre_meta_values.non_class_used(),
+ pre_meta_values.non_class_committed(),
+ meta_values.non_class_used(),
+ meta_values.non_class_committed()),
+ HEAP_CHANGE_FORMAT_ARGS("Class",
+ pre_meta_values.class_used(),
+ pre_meta_values.class_committed(),
+ meta_values.class_used(),
+ meta_values.class_committed()));
+ } else {
+ log_info(gc, metaspace)(HEAP_CHANGE_FORMAT,
+ HEAP_CHANGE_FORMAT_ARGS("Metaspace",
+ pre_meta_values.used(),
+ pre_meta_values.committed(),
+ meta_values.used(),
+ meta_values.committed()));
+ }
}
void MetaspaceUtils::print_on(outputStream* out) {
--- a/src/hotspot/share/memory/metaspace.hpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/memory/metaspace.hpp Wed Jul 03 15:46:48 2019 -0400
@@ -28,6 +28,7 @@
#include "memory/memRegion.hpp"
#include "memory/metaspaceChunkFreeListSummary.hpp"
#include "memory/virtualspace.hpp"
+#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
#include "utilities/exceptions.hpp"
// Metaspace
@@ -410,8 +411,8 @@
static bool has_chunk_free_list(Metaspace::MetadataType mdtype);
static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype);
- // Print change in used metadata.
- static void print_metaspace_change(size_t prev_metadata_used);
+ // Log change in used metadata.
+ static void print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values);
static void print_on(outputStream * out);
// Prints an ASCII representation of the given space.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceSizesSnapshot.cpp Wed Jul 03 15:46:48 2019 -0400
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ *
+ */
+
+#include "precompiled.hpp"
+
+#include "memory/metaspace.hpp"
+#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
+
+namespace metaspace {
+
+MetaspaceSizesSnapshot::MetaspaceSizesSnapshot()
+ : _used(MetaspaceUtils::used_bytes()),
+ _committed(MetaspaceUtils::committed_bytes()),
+ _non_class_used(MetaspaceUtils::used_bytes(Metaspace::NonClassType)),
+ _non_class_committed(MetaspaceUtils::committed_bytes(Metaspace::NonClassType)),
+ _class_used(MetaspaceUtils::used_bytes(Metaspace::ClassType)),
+ _class_committed(MetaspaceUtils::committed_bytes(Metaspace::ClassType)) { }
+
+} // namespace metaspace
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/memory/metaspace/metaspaceSizesSnapshot.hpp Wed Jul 03 15:46:48 2019 -0400
@@ -0,0 +1,53 @@
+/*
+ * 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_MEMORY_METASPACE_METASPACESIZESSNAPSHOT_HPP
+#define SHARE_MEMORY_METASPACE_METASPACESIZESSNAPSHOT_HPP
+
+namespace metaspace {
+
+class MetaspaceSizesSnapshot {
+public:
+ MetaspaceSizesSnapshot();
+
+ size_t used() const { return _used; }
+ size_t committed() const { return _committed; }
+ size_t non_class_used() const { return _non_class_used; }
+ size_t non_class_committed() const { return _non_class_committed; }
+ size_t class_used() const { return _class_used; }
+ size_t class_committed() const { return _class_committed; }
+
+private:
+ const size_t _used;
+ const size_t _committed;
+ const size_t _non_class_used;
+ const size_t _non_class_committed;
+ const size_t _class_used;
+ const size_t _class_committed;
+};
+
+} // namespace metaspace
+
+#endif // SHARE_MEMORY_METASPACE_METASPACESIZESSNAPSHOT_HPP
--- a/src/hotspot/share/utilities/globalDefinitions.hpp Wed Jul 03 16:30:19 2019 +0000
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp Wed Jul 03 15:46:48 2019 -0400
@@ -308,6 +308,13 @@
return s;
}
+// Memory size transition formatting.
+
+#define HEAP_CHANGE_FORMAT "%s: " SIZE_FORMAT "K(" SIZE_FORMAT "K)->" SIZE_FORMAT "K(" SIZE_FORMAT "K)"
+
+#define HEAP_CHANGE_FORMAT_ARGS(_name_, _prev_used_, _prev_capacity_, _used_, _capacity_) \
+ (_name_), (_prev_used_) / K, (_prev_capacity_) / K, (_used_) / K, (_capacity_) / K
+
//----------------------------------------------------------------------------------------------------
// VM type definitions