Skip to content

Commit

Permalink
Unify message path
Browse files Browse the repository at this point in the history
  • Loading branch information
stefank committed May 4, 2023
1 parent d1792bb commit 52e9fe8
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/epsilon/epsilonHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class EpsilonHeap : public CollectedHeap {
static EpsilonHeap* heap();

EpsilonHeap() :
_memory_manager("Epsilon Heap", ""),
_memory_manager("Epsilon Heap"),
_space(nullptr) {};

Name kind() const override {
Expand Down
18 changes: 12 additions & 6 deletions src/hotspot/share/gc/g1/g1MonitoringSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class G1OldGenerationCounters : public G1GenerationCounters {

G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
_g1h(g1h),
_young_gc_memory_manager("G1 Young Generation", "end of minor GC"),
_full_gc_memory_manager("G1 Old Generation", "end of major GC"),
_conc_gc_memory_manager("G1 Concurrent GC", "end of concurrent GC pause"),
_young_gc_memory_manager("G1 Young Generation"),
_full_gc_memory_manager("G1 Old Generation"),
_conc_gc_memory_manager("G1 Concurrent GC"),
_eden_space_pool(nullptr),
_survivor_space_pool(nullptr),
_old_gen_pool(nullptr),
Expand Down Expand Up @@ -351,11 +351,14 @@ MemoryUsage G1MonitoringSupport::old_gen_memory_usage(size_t initial_size, size_
G1MonitoringScope::G1MonitoringScope(G1MonitoringSupport* monitoring_support,
CollectorCounters* collection_counters,
GCMemoryManager* gc_memory_manager,
const char* end_message,
bool all_memory_pools_affected) :
_monitoring_support(monitoring_support),
_tcs(collection_counters),
_tms(gc_memory_manager,
G1CollectedHeap::heap()->gc_cause(), all_memory_pools_affected) {
G1CollectedHeap::heap()->gc_cause(),
end_message,
all_memory_pools_affected) {
}

G1MonitoringScope::~G1MonitoringScope() {
Expand All @@ -369,17 +372,20 @@ G1YoungGCMonitoringScope::G1YoungGCMonitoringScope(G1MonitoringSupport* monitori
G1MonitoringScope(monitoring_support,
monitoring_support->_young_collection_counters,
&monitoring_support->_young_gc_memory_manager,
"end of minor GC",
all_memory_pools_affected) {
}

G1FullGCMonitoringScope::G1FullGCMonitoringScope(G1MonitoringSupport* monitoring_support) :
G1MonitoringScope(monitoring_support,
monitoring_support->_full_collection_counters,
&monitoring_support->_full_gc_memory_manager) {
&monitoring_support->_full_gc_memory_manager,
"end of major GC") {
}

G1ConcGCMonitoringScope::G1ConcGCMonitoringScope(G1MonitoringSupport* monitoring_support) :
G1MonitoringScope(monitoring_support,
monitoring_support->_conc_collection_counters,
&monitoring_support->_conc_gc_memory_manager) {
&monitoring_support->_conc_gc_memory_manager,
"end of concurrent GC pause") {
}
1 change: 1 addition & 0 deletions src/hotspot/share/gc/g1/g1MonitoringSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class G1MonitoringScope : public StackObj {
G1MonitoringScope(G1MonitoringSupport* monitoring_support,
CollectorCounters* collection_counters,
GCMemoryManager* gc_memory_manager,
const char* end_message,
bool all_memory_pools_affected = true);
~G1MonitoringScope();
};
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ void ParallelScavengeHeap::initialize_serviceability() {
"PS Old Gen",
true /* support_usage_threshold */);

_young_manager = new GCMemoryManager("PS Scavenge", "end of minor GC");
_old_manager = new GCMemoryManager("PS MarkSweep", "end of major GC");
_young_manager = new GCMemoryManager("PS Scavenge");
_old_manager = new GCMemoryManager("PS MarkSweep");

_old_manager->add_pool(_eden_pool);
_old_manager->add_pool(_survivor_pool);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/parallel/psParallelCompact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
heap->pre_full_gc_dump(&_gc_timer);

TraceCollectorStats tcs(counters());
TraceMemoryManagerStats tms(heap->old_gc_manager(), gc_cause);
TraceMemoryManagerStats tms(heap->old_gc_manager(), gc_cause, "end of major GC");

if (log_is_enabled(Debug, gc, heap, exit)) {
accumulated_time()->start();
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/parallel/psScavenge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ bool PSScavenge::invoke_no_policy() {
GCTraceCPUTime tcpu(&_gc_tracer);
GCTraceTime(Info, gc) tm("Pause Young", nullptr, gc_cause, true);
TraceCollectorStats tcs(counters());
TraceMemoryManagerStats tms(heap->young_gc_manager(), gc_cause);
TraceMemoryManagerStats tms(heap->young_gc_manager(), gc_cause, "end of minor GC");

if (log_is_enabled(Debug, gc, heap, exit)) {
accumulated_time()->start();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/serial/serialHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ SerialHeap::SerialHeap() :
_eden_pool(nullptr),
_survivor_pool(nullptr),
_old_pool(nullptr) {
_young_manager = new GCMemoryManager("Copy", "end of minor GC");
_old_manager = new GCMemoryManager("MarkSweepCompact", "end of major GC");
_young_manager = new GCMemoryManager("Copy");
_old_manager = new GCMemoryManager("MarkSweepCompact");
}

void SerialHeap::initialize_serviceability() {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/genCollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t siz
FormatBuffer<> title("Collect gen: %s", gen->short_name());
GCTraceTime(Trace, gc, phases) t1(title);
TraceCollectorStats tcs(gen->counters());
TraceMemoryManagerStats tmms(gen->gc_manager(), gc_cause());
TraceMemoryManagerStats tmms(gen->gc_manager(), gc_cause(), heap()->is_young_gen(gen) ? "end of minor GC" : "end of major GC");

gen->stat_record()->invocations++;
gen->stat_record()->accumulated_time.start();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) :
_phase_timings(nullptr),
_monitoring_support(nullptr),
_memory_pool(nullptr),
_stw_memory_manager("Shenandoah Pauses", "end of GC pause"),
_cycle_memory_manager("Shenandoah Cycles", "end of GC cycle"),
_stw_memory_manager("Shenandoah Pauses"),
_cycle_memory_manager("Shenandoah Cycles"),
_gc_timer(new ConcurrentGCTimer()),
_soft_ref_policy(),
_log_min_obj_alignment_in_bytes(LogMinObjAlignmentInBytes),
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ShenandoahGCSession::ShenandoahGCSession(GCCause::Cause cause) :
_heap->shenandoah_policy()->record_cycle_start();
_heap->heuristics()->record_cycle_start();
_trace_cycle.initialize(_heap->cycle_memory_manager(), cause,
"end of GC cycle",
/* allMemoryPoolsAffected */ true,
/* recordGCBeginTime = */ true,
/* recordPreGCUsage = */ true,
Expand All @@ -76,15 +77,15 @@ ShenandoahGCSession::~ShenandoahGCSession() {
ShenandoahGCPauseMark::ShenandoahGCPauseMark(uint gc_id, const char* notification_message, SvcGCMarker::reason_type type) :
_heap(ShenandoahHeap::heap()), _gc_id_mark(gc_id), _svc_gc_mark(type), _is_gc_active_mark() {
_trace_pause.initialize(_heap->stw_memory_manager(), _heap->gc_cause(),
notification_message,
/* allMemoryPoolsAffected */ true,
/* recordGCBeginTime = */ true,
/* recordPreGCUsage = */ false,
/* recordPeakUsage = */ false,
/* recordPostGCUsage = */ false,
/* recordAccumulatedGCTime = */ true,
/* recordGCEndTime = */ true,
/* countCollection = */ true,
/* notificationMessage = */ notification_message
/* countCollection = */ true
);
}

Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/gc/z/zServiceability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ ZServiceability::ZServiceability(size_t min_capacity, size_t max_capacity) :
_min_capacity(min_capacity),
_max_capacity(max_capacity),
_memory_pool(_min_capacity, _max_capacity),
_cycle_memory_manager("ZGC Cycles", "end of GC cycle", &_memory_pool),
_pause_memory_manager("ZGC Pauses", "end of GC pause", &_memory_pool),
_cycle_memory_manager("ZGC Cycles", &_memory_pool),
_pause_memory_manager("ZGC Pauses", &_memory_pool),
_counters(NULL) {}

void ZServiceability::initialize() {
Expand All @@ -147,6 +147,7 @@ ZServiceabilityCounters* ZServiceability::counters() {
ZServiceabilityCycleTracer::ZServiceabilityCycleTracer() :
_memory_manager_stats(ZHeap::heap()->serviceability_cycle_memory_manager(),
ZCollectedHeap::heap()->gc_cause(),
"end of GC cycle",
true /* allMemoryPoolsAffected */,
true /* recordGCBeginTime */,
true /* recordPreGCUsage */,
Expand All @@ -161,6 +162,7 @@ ZServiceabilityPauseTracer::ZServiceabilityPauseTracer() :
_counters_stats(ZHeap::heap()->serviceability_counters()->collector_counters()),
_memory_manager_stats(ZHeap::heap()->serviceability_pause_memory_manager(),
ZCollectedHeap::heap()->gc_cause(),
"end of GC pause",
true /* allMemoryPoolsAffected */,
true /* recordGCBeginTime */,
false /* recordPreGCUsage */,
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/gc/z/zServiceability.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ZServiceabilityMemoryPool : public CollectedMemoryPool {
class ZServiceabilityMemoryManager : public GCMemoryManager {
public:
ZServiceabilityMemoryManager(const char* name,
const char* end_message,
ZServiceabilityMemoryPool* pool);
};

Expand Down
11 changes: 6 additions & 5 deletions src/hotspot/share/services/memoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ void GCStatInfo::clear() {
}


GCMemoryManager::GCMemoryManager(const char* name, const char* gc_end_message) :
MemoryManager(name), _gc_end_message(gc_end_message) {
GCMemoryManager::GCMemoryManager(const char* name) :
MemoryManager(name) {
_num_collections = 0;
_last_gc_stat = nullptr;
_last_gc_lock = new Mutex(Mutex::nosafepoint, "GCMemoryManager_lock");
Expand Down Expand Up @@ -241,9 +241,11 @@ void GCMemoryManager::gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
// to ensure the current gc stat is placed in _last_gc_stat.
void GCMemoryManager::gc_end(bool recordPostGCUsage,
bool recordAccumulatedGCTime,
bool recordGCEndTime, bool countCollection,
bool recordGCEndTime,
bool countCollection,
GCCause::Cause cause,
bool allMemoryPoolsAffected, const char* notificationMessage) {
bool allMemoryPoolsAffected,
const char* message) {
if (recordAccumulatedGCTime) {
_accumulated_timer.stop();
}
Expand Down Expand Up @@ -293,7 +295,6 @@ void GCMemoryManager::gc_end(bool recordPostGCUsage,
}

if (is_notification_enabled()) {
const char* message = notificationMessage != nullptr ? notificationMessage : _gc_end_message;
GCNotifier::pushNotification(this, message, GCCause::to_string(cause));
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/services/memoryManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,10 @@ class GCMemoryManager : public MemoryManager {
GCStatInfo* _current_gc_stat;
int _num_gc_threads;
volatile bool _notification_enabled;
const char* _gc_end_message;
bool _pool_always_affected_by_gc[MemoryManager::max_num_pools];

public:
GCMemoryManager(const char* name, const char* gc_end_message);
GCMemoryManager(const char* name);
~GCMemoryManager();

void add_pool(MemoryPool* pool);
Expand All @@ -167,7 +166,7 @@ class GCMemoryManager : public MemoryManager {
bool recordAccumulatedGCTime);
void gc_end(bool recordPostGCUsage, bool recordAccumulatedGCTime,
bool recordGCEndTime, bool countCollection, GCCause::Cause cause,
bool allMemoryPoolsAffected, const char* notificationMessage = nullptr);
bool allMemoryPoolsAffected, const char* message);

void reset_gc_stat() { _num_collections = 0; _accumulated_timer.reset(); }

Expand Down
26 changes: 13 additions & 13 deletions src/hotspot/share/services/memoryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ void MemoryService::gc_end(GCMemoryManager* manager, bool recordPostGCUsage,
bool recordAccumulatedGCTime,
bool recordGCEndTime, bool countCollection,
GCCause::Cause cause,
bool allMemoryPoolsAffected, const char* notificationMessage) {
bool allMemoryPoolsAffected, const char* message) {
// register the GC end statistics and memory usage
manager->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
countCollection, cause, allMemoryPoolsAffected, notificationMessage);
countCollection, cause, allMemoryPoolsAffected, message);
}

bool MemoryService::set_verbose(bool verbose) {
Expand Down Expand Up @@ -220,35 +220,37 @@ Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {

TraceMemoryManagerStats::TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager,
GCCause::Cause cause,
const char* end_message,
bool allMemoryPoolsAffected,
bool recordGCBeginTime,
bool recordPreGCUsage,
bool recordPeakUsage,
bool recordPostGCUsage,
bool recordAccumulatedGCTime,
bool recordGCEndTime,
bool countCollection,
const char* notificationMessage) {
initialize(gc_memory_manager, cause, allMemoryPoolsAffected,
recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
countCollection, notificationMessage);
bool countCollection) {
initialize(gc_memory_manager, cause, end_message,
allMemoryPoolsAffected, recordGCBeginTime, recordPreGCUsage,
recordPeakUsage, recordPostGCUsage, recordAccumulatedGCTime,
recordGCEndTime, countCollection);
}

// for a subclass to create then initialize an instance before invoking
// the MemoryService
void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_memory_manager,
GCCause::Cause cause,
const char* end_message,
bool allMemoryPoolsAffected,
bool recordGCBeginTime,
bool recordPreGCUsage,
bool recordPeakUsage,
bool recordPostGCUsage,
bool recordAccumulatedGCTime,
bool recordGCEndTime,
bool countCollection,
const char* notificationMessage) {
bool countCollection) {
_gc_memory_manager = gc_memory_manager;
_cause = cause;
_end_message = end_message;
_allMemoryPoolsAffected = allMemoryPoolsAffected;
_recordGCBeginTime = recordGCBeginTime;
_recordPreGCUsage = recordPreGCUsage;
Expand All @@ -257,8 +259,6 @@ void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_memory_manager,
_recordAccumulatedGCTime = recordAccumulatedGCTime;
_recordGCEndTime = recordGCEndTime;
_countCollection = countCollection;
_cause = cause;
_notificationMessage = notificationMessage;

MemoryService::gc_begin(_gc_memory_manager, _recordGCBeginTime, _recordAccumulatedGCTime,
_recordPreGCUsage, _recordPeakUsage);
Expand All @@ -267,5 +267,5 @@ void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_memory_manager,
TraceMemoryManagerStats::~TraceMemoryManagerStats() {
MemoryService::gc_end(_gc_memory_manager, _recordPostGCUsage, _recordAccumulatedGCTime,
_recordGCEndTime, _countCollection, _cause, _allMemoryPoolsAffected,
_notificationMessage);
_end_message);
}
28 changes: 14 additions & 14 deletions src/hotspot/share/services/memoryService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,41 +116,41 @@ class MemoryService : public AllStatic {
class TraceMemoryManagerStats : public StackObj {
private:
GCMemoryManager* _gc_memory_manager;
bool _allMemoryPoolsAffected;
bool _recordGCBeginTime;
bool _recordPreGCUsage;
bool _recordPeakUsage;
bool _recordPostGCUsage;
bool _recordAccumulatedGCTime;
bool _recordGCEndTime;
bool _countCollection;
GCCause::Cause _cause;
const char* _notificationMessage;
GCCause::Cause _cause;
const char* _end_message;
bool _allMemoryPoolsAffected;
bool _recordGCBeginTime;
bool _recordPreGCUsage;
bool _recordPeakUsage;
bool _recordPostGCUsage;
bool _recordAccumulatedGCTime;
bool _recordGCEndTime;
bool _countCollection;
public:
TraceMemoryManagerStats() {}
TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager,
GCCause::Cause cause,
const char* end_message,
bool allMemoryPoolsAffected = true,
bool recordGCBeginTime = true,
bool recordPreGCUsage = true,
bool recordPeakUsage = true,
bool recordPostGCUsage = true,
bool recordAccumulatedGCTime = true,
bool recordGCEndTime = true,
bool countCollection = true,
const char* notificationMessage = nullptr);
bool countCollection = true);

void initialize(GCMemoryManager* gc_memory_manager,
GCCause::Cause cause,
const char* end_message,
bool allMemoryPoolsAffected,
bool recordGCBeginTime,
bool recordPreGCUsage,
bool recordPeakUsage,
bool recordPostGCUsage,
bool recordAccumulatedGCTime,
bool recordGCEndTime,
bool countCollection,
const char* notificationMessage = nullptr);
bool countCollection);

~TraceMemoryManagerStats();
};
Expand Down

0 comments on commit 52e9fe8

Please sign in to comment.