Skip to content
Permalink
Browse files
8251392: Consolidate Metaspace Statistics
Reviewed-by: coleenp, zgu
  • Loading branch information
tstuefe committed May 18, 2021
1 parent 3e97b07 commit 554caf33a01ac9ca2e3e9170557e8348750f3971
Showing with 289 additions and 400 deletions.
  1. +4 −3 src/hotspot/share/gc/epsilon/epsilonHeap.cpp
  2. +0 −1 src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp
  3. +1 −0 src/hotspot/share/gc/g1/g1HeapTransition.cpp
  4. +2 −2 src/hotspot/share/gc/g1/g1HeapTransition.hpp
  5. +0 −1 src/hotspot/share/gc/g1/g1MonitoringSupport.cpp
  6. +0 −1 src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
  7. +2 −15 src/hotspot/share/gc/shared/collectedHeap.cpp
  8. +6 −30 src/hotspot/share/gc/shared/gcHeapSummary.hpp
  9. +4 −6 src/hotspot/share/gc/shared/gcTraceSend.cpp
  10. +0 −2 src/hotspot/share/gc/shared/genCollectedHeap.cpp
  11. +6 −4 src/hotspot/share/gc/shared/preGCValues.hpp
  12. +2 −2 src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
  13. +0 −1 src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp
  14. +0 −1 src/hotspot/share/gc/z/zServiceability.cpp
  15. +4 −3 src/hotspot/share/gc/z/zStat.cpp
  16. +69 −12 src/hotspot/share/memory/metaspace.cpp
  17. +1 −4 src/hotspot/share/memory/metaspace.hpp
  18. +3 −0 src/hotspot/share/memory/metaspace/internalStats.hpp
  19. +0 −42 src/hotspot/share/memory/metaspace/metaspaceSizesSnapshot.cpp
  20. +0 −56 src/hotspot/share/memory/metaspace/metaspaceSizesSnapshot.hpp
  21. +21 −68 src/hotspot/share/memory/metaspaceCounters.cpp
  22. +3 −19 src/hotspot/share/memory/metaspaceCounters.hpp
  23. +76 −0 src/hotspot/share/memory/metaspaceStats.hpp
  24. +7 −1 src/hotspot/share/memory/metaspaceUtils.hpp
  25. +0 −1 src/hotspot/share/memory/universe.cpp
  26. +2 −1 src/hotspot/share/services/memBaseline.cpp
  27. +4 −3 src/hotspot/share/services/memBaseline.hpp
  28. +30 −52 src/hotspot/share/services/memReporter.cpp
  29. +7 −6 src/hotspot/share/services/memReporter.hpp
  30. +4 −4 src/hotspot/share/services/memoryPool.cpp
  31. +1 −32 src/hotspot/share/services/virtualMemoryTracker.cpp
  32. +2 −27 src/hotspot/share/services/virtualMemoryTracker.hpp
  33. +28 −0 test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp
@@ -331,9 +331,10 @@ void EpsilonHeap::print_heap_info(size_t used) const {
}

void EpsilonHeap::print_metaspace_info() const {
size_t reserved = MetaspaceUtils::reserved_bytes();
size_t committed = MetaspaceUtils::committed_bytes();
size_t used = MetaspaceUtils::used_bytes();
MetaspaceCombinedStats stats = MetaspaceUtils::get_combined_statistics();
size_t reserved = stats.reserved();
size_t committed = stats.committed();
size_t used = stats.used();

if (reserved != 0) {
log_info(gc, metaspace)("Metaspace: " SIZE_FORMAT "%s reserved, " SIZE_FORMAT "%s (%.2f%%) committed, "
@@ -111,7 +111,6 @@ void EpsilonMonitoringSupport::update_counters() {
_heap_counters->update_all();
_space_counters->update_all(capacity, used);
MetaspaceCounters::update_performance_counters();
CompressedClassSpaceCounters::update_performance_counters();
}
}

@@ -35,6 +35,7 @@ G1HeapTransition::Data::Data(G1CollectedHeap* g1_heap) :
_old_length(g1_heap->old_regions_count()),
_archive_length(g1_heap->archive_regions_count()),
_humongous_length(g1_heap->humongous_regions_count()),
_meta_sizes(MetaspaceUtils::get_combined_statistics()),
_eden_length_per_node(NULL),
_survivor_length_per_node(NULL) {

@@ -26,7 +26,7 @@
#define SHARE_GC_G1_G1HEAPTRANSITION_HPP

#include "gc/shared/plab.hpp"
#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
#include "memory/metaspaceStats.hpp"

class G1CollectedHeap;

@@ -37,7 +37,7 @@ class G1HeapTransition {
size_t _old_length;
size_t _archive_length;
size_t _humongous_length;
const metaspace::MetaspaceSizesSnapshot _meta_sizes;
const MetaspaceCombinedStats _meta_sizes;

// Only includes current eden regions.
uint* _eden_length_per_node;
@@ -303,7 +303,6 @@ void G1MonitoringSupport::update_sizes() {
_old_gen_counters->update_all();

MetaspaceCounters::update_performance_counters();
CompressedClassSpaceCounters::update_performance_counters();
}
}

@@ -184,7 +184,6 @@ void ParallelScavengeHeap::update_counters() {
young_gen()->update_counters();
old_gen()->update_counters();
MetaspaceCounters::update_performance_counters();
CompressedClassSpaceCounters::update_performance_counters();
}

size_t ParallelScavengeHeap::capacity() const {
@@ -128,25 +128,12 @@ GCHeapSummary CollectedHeap::create_heap_summary() {
}

MetaspaceSummary CollectedHeap::create_metaspace_summary() {
const MetaspaceSizes meta_space(
MetaspaceUtils::committed_bytes(),
MetaspaceUtils::used_bytes(),
MetaspaceUtils::reserved_bytes());
const MetaspaceSizes data_space(
MetaspaceUtils::committed_bytes(Metaspace::NonClassType),
MetaspaceUtils::used_bytes(Metaspace::NonClassType),
MetaspaceUtils::reserved_bytes(Metaspace::NonClassType));
const MetaspaceSizes class_space(
MetaspaceUtils::committed_bytes(Metaspace::ClassType),
MetaspaceUtils::used_bytes(Metaspace::ClassType),
MetaspaceUtils::reserved_bytes(Metaspace::ClassType));

const MetaspaceChunkFreeListSummary& ms_chunk_free_list_summary =
MetaspaceUtils::chunk_free_list_summary(Metaspace::NonClassType);
const MetaspaceChunkFreeListSummary& class_chunk_free_list_summary =
MetaspaceUtils::chunk_free_list_summary(Metaspace::ClassType);

return MetaspaceSummary(MetaspaceGC::capacity_until_GC(), meta_space, data_space, class_space,
return MetaspaceSummary(MetaspaceGC::capacity_until_GC(),
MetaspaceUtils::get_combined_statistics(),
ms_chunk_free_list_summary, class_chunk_free_list_summary);
}

@@ -26,6 +26,7 @@
#define SHARE_GC_SHARED_GCHEAPSUMMARY_HPP

#include "memory/allocation.hpp"
#include "memory/metaspaceStats.hpp"
#include "memory/metaspaceChunkFreeListSummary.hpp"

class VirtualSpaceSummary : public StackObj {
@@ -61,21 +62,6 @@ class SpaceSummary : public StackObj {
size_t size() const { return (uintptr_t)_end - (uintptr_t)_start; }
};

class MetaspaceSizes : public StackObj {
size_t _committed;
size_t _used;
size_t _reserved;

public:
MetaspaceSizes() : _committed(0), _used(0), _reserved(0) {}
MetaspaceSizes(size_t committed, size_t used, size_t reserved) :
_committed(committed), _used(used), _reserved(reserved) {}

size_t committed() const { return _committed; }
size_t used() const { return _used; }
size_t reserved() const { return _reserved; }
};

class GCHeapSummary;
class PSHeapSummary;
class G1HeapSummary;
@@ -147,39 +133,29 @@ class G1HeapSummary : public GCHeapSummary {

class MetaspaceSummary : public StackObj {
size_t _capacity_until_GC;
MetaspaceSizes _meta_space;
MetaspaceSizes _data_space;
MetaspaceSizes _class_space;
MetaspaceCombinedStats _stats;
MetaspaceChunkFreeListSummary _metaspace_chunk_free_list_summary;
MetaspaceChunkFreeListSummary _class_chunk_free_list_summary;

public:
MetaspaceSummary() :
_capacity_until_GC(0),
_meta_space(),
_data_space(),
_class_space(),
_stats(),
_metaspace_chunk_free_list_summary(),
_class_chunk_free_list_summary()
{}
MetaspaceSummary(size_t capacity_until_GC,
const MetaspaceSizes& meta_space,
const MetaspaceSizes& data_space,
const MetaspaceSizes& class_space,
const MetaspaceCombinedStats& stats,
const MetaspaceChunkFreeListSummary& metaspace_chunk_free_list_summary,
const MetaspaceChunkFreeListSummary& class_chunk_free_list_summary) :
_capacity_until_GC(capacity_until_GC),
_meta_space(meta_space),
_data_space(data_space),
_class_space(class_space),
_stats(stats),
_metaspace_chunk_free_list_summary(metaspace_chunk_free_list_summary),
_class_chunk_free_list_summary(class_chunk_free_list_summary)
{}

size_t capacity_until_GC() const { return _capacity_until_GC; }
const MetaspaceSizes& meta_space() const { return _meta_space; }
const MetaspaceSizes& data_space() const { return _data_space; }
const MetaspaceSizes& class_space() const { return _class_space; }
const MetaspaceCombinedStats& stats() const { return _stats; }

const MetaspaceChunkFreeListSummary& metaspace_chunk_free_list_summary() const {
return _metaspace_chunk_free_list_summary;
@@ -265,13 +265,11 @@ void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary
heap_summary.accept(&visitor);
}

static JfrStructMetaspaceSizes to_struct(const MetaspaceSizes& sizes) {
static JfrStructMetaspaceSizes to_struct(const MetaspaceStats& sizes) {
JfrStructMetaspaceSizes meta_sizes;

meta_sizes.set_committed(sizes.committed());
meta_sizes.set_used(sizes.used());
meta_sizes.set_reserved(sizes.reserved());

return meta_sizes;
}

@@ -281,9 +279,9 @@ void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceS
e.set_gcId(GCId::current());
e.set_when((u1) when);
e.set_gcThreshold(meta_space_summary.capacity_until_GC());
e.set_metaspace(to_struct(meta_space_summary.meta_space()));
e.set_dataSpace(to_struct(meta_space_summary.data_space()));
e.set_classSpace(to_struct(meta_space_summary.class_space()));
e.set_metaspace(to_struct(meta_space_summary.stats())); // total stats (class + nonclass)
e.set_dataSpace(to_struct(meta_space_summary.stats().non_class_space_stats())); // "dataspace" aka non-class space
e.set_classSpace(to_struct(meta_space_summary.stats().class_space_stats()));
e.commit();
}
}
@@ -57,7 +57,6 @@
#include "gc/shared/weakProcessor.hpp"
#include "gc/shared/workgroup.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
#include "memory/metaspaceCounters.hpp"
#include "memory/metaspaceUtils.hpp"
#include "memory/resourceArea.hpp"
@@ -1228,7 +1227,6 @@ void GenCollectedHeap::gc_epilogue(bool full) {
generation_iterate(&blk, false); // not old-to-young.

MetaspaceCounters::update_performance_counters();
CompressedClassSpaceCounters::update_performance_counters();
};

#ifndef PRODUCT
@@ -26,7 +26,8 @@
#ifndef SHARE_GC_SHARED_PREGCVALUES_HPP
#define SHARE_GC_SHARED_PREGCVALUES_HPP

#include "memory/metaspace/metaspaceSizesSnapshot.hpp"
#include "memory/metaspaceStats.hpp"
#include "memory/metaspaceUtils.hpp"

// Simple class for storing info about the heap at the start of GC, to be used
// after GC for comparison/printing.
@@ -47,7 +48,8 @@ class PreGenGCValues {
_from_used(from_used),
_from_capacity(from_capacity),
_old_gen_used(old_gen_used),
_old_gen_capacity(old_gen_capacity) { }
_old_gen_capacity(old_gen_capacity),
_meta_sizes(MetaspaceUtils::get_combined_statistics()){ }

size_t young_gen_used() const { return _young_gen_used; }
size_t young_gen_capacity() const { return _young_gen_capacity; }
@@ -57,7 +59,7 @@ class PreGenGCValues {
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; }
const MetaspaceCombinedStats& metaspace_sizes() const { return _meta_sizes; }

private:
const size_t _young_gen_used;
@@ -68,7 +70,7 @@ class PreGenGCValues {
const size_t _from_capacity;
const size_t _old_gen_used;
const size_t _old_gen_capacity;
const metaspace::MetaspaceSizesSnapshot _meta_sizes;
const MetaspaceCombinedStats _meta_sizes;
};

#endif // SHARE_GC_SHARED_PREGCVALUES_HPP
@@ -41,6 +41,7 @@
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspaceUtils.hpp"
#include "memory/metaspaceStats.hpp"
#include "memory/universe.hpp"
#include "runtime/atomic.hpp"

@@ -187,8 +188,7 @@ void ShenandoahControlThread::run_service() {

heap->reset_bytes_allocated_since_gc_start();

// Use default constructor to snapshot the Metaspace state before GC.
metaspace::MetaspaceSizesSnapshot meta_sizes;
MetaspaceCombinedStats meta_sizes = MetaspaceUtils::get_combined_statistics();

// If GC was requested, we are sampling the counters even without actual triggers
// from allocation machinery. This captures GC phases more accurately.
@@ -101,6 +101,5 @@ void ShenandoahMonitoringSupport::update_counters() {
_heap_region_counters->update();

MetaspaceCounters::update_performance_counters();
CompressedClassSpaceCounters::update_performance_counters();
}
}
@@ -89,7 +89,6 @@ void ZServiceabilityCounters::update_sizes() {
_space_counters.update_used(used);

MetaspaceCounters::update_performance_counters();
CompressedClassSpaceCounters::update_performance_counters();
}
}

@@ -1211,12 +1211,13 @@ void ZStatNMethods::print() {
// Stat metaspace
//
void ZStatMetaspace::print() {
MetaspaceCombinedStats stats = MetaspaceUtils::get_combined_statistics();
log_info(gc, metaspace)("Metaspace: "
SIZE_FORMAT "M used, "
SIZE_FORMAT "M committed, " SIZE_FORMAT "M reserved",
MetaspaceUtils::used_bytes() / M,
MetaspaceUtils::committed_bytes() / M,
MetaspaceUtils::reserved_bytes() / M);
stats.used() / M,
stats.committed() / M,
stats.reserved() / M);
}

//

0 comments on commit 554caf3

Please sign in to comment.