Skip to content

Commit 833e2bb

Browse files
committed
8291753: Add JFR event for GC CPU Time
Reviewed-by: phh Backport-of: 14eb5ad0dc987ffe3621f4eeeebeb6b5a2cd691b
1 parent f221ff3 commit 833e2bb

File tree

23 files changed

+215
-54
lines changed

23 files changed

+215
-54
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ bool G1CollectedHeap::do_full_collection(bool explicit_gc,
11101110

11111111
G1FullGCMark gc_mark;
11121112
GCTraceTime(Info, gc) tm("Pause Full", NULL, gc_cause(), true);
1113-
G1FullCollector collector(this, explicit_gc, do_clear_all_soft_refs, do_maximum_compaction);
1113+
G1FullCollector collector(this, explicit_gc, do_clear_all_soft_refs, do_maximum_compaction, gc_mark.tracer());
11141114

11151115
collector.prepare_collection();
11161116
collector.collect();
@@ -2981,7 +2981,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
29812981

29822982
// Inner scope for scope based logging, timers, and stats collection
29832983
{
2984-
GCTraceCPUTime tcpu;
2984+
GCTraceCPUTime tcpu(_gc_tracer_stw);
29852985

29862986
char young_gc_name[MaxYoungGCNameLength];
29872987
set_young_gc_name(young_gc_name);

src/hotspot/share/gc/g1/g1ConcurrentMark.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ class G1ConcurrentMark : public CHeapObj<mtGC> {
595595

596596
ConcurrentGCTimer* gc_timer_cm() const { return _gc_timer_cm; }
597597

598+
G1OldTracer* gc_tracer_cm() const { return _gc_tracer_cm; }
599+
598600
private:
599601
// Rebuilds the remembered sets for chosen regions in parallel and concurrently to the application.
600602
void rebuild_rem_set_concurrently();

src/hotspot/share/gc/g1/g1FullCollector.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ uint G1FullCollector::calc_active_workers() {
112112
G1FullCollector::G1FullCollector(G1CollectedHeap* heap,
113113
bool explicit_gc,
114114
bool clear_soft_refs,
115-
bool do_maximum_compaction) :
115+
bool do_maximum_compaction,
116+
G1FullGCTracer* tracer) :
116117
_heap(heap),
117-
_scope(heap->g1mm(), explicit_gc, clear_soft_refs, do_maximum_compaction),
118+
_scope(heap->g1mm(), explicit_gc, clear_soft_refs, do_maximum_compaction, tracer),
118119
_num_workers(calc_active_workers()),
119120
_oop_queue_set(_num_workers),
120121
_array_queue_set(_num_workers),

src/hotspot/share/gc/g1/g1FullCollector.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ class G1FullGCSubjectToDiscoveryClosure: public BoolObjectClosure {
6262
// to have the same structure as the Young GC logging.
6363
class G1FullGCMark : StackObj {
6464
GCIdMark _gc_id;
65+
G1FullGCTracer _tracer;
6566
GCTraceCPUTime _cpu_time;
6667
public:
67-
G1FullGCMark() : _gc_id(), _cpu_time() { }
68+
G1FullGCMark() : _gc_id(), _tracer(), _cpu_time(&_tracer) { }
69+
G1FullGCTracer* tracer() { return &_tracer; }
6870
};
6971

7072
// The G1FullCollector holds data associated with the current Full GC.
@@ -93,7 +95,8 @@ class G1FullCollector : StackObj {
9395
G1FullCollector(G1CollectedHeap* heap,
9496
bool explicit_gc,
9597
bool clear_soft_refs,
96-
bool do_maximum_compaction);
98+
bool do_maximum_compaction,
99+
G1FullGCTracer* tracer);
97100
~G1FullCollector();
98101

99102
void prepare_collection();

src/hotspot/share/gc/g1/g1FullGCScope.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ G1FullGCJFRTracerMark::~G1FullGCJFRTracerMark() {
3838
G1FullGCScope::G1FullGCScope(G1MonitoringSupport* monitoring_support,
3939
bool explicit_gc,
4040
bool clear_soft,
41-
bool do_maximum_compaction) :
41+
bool do_maximum_compaction,
42+
G1FullGCTracer* tracer) :
4243
_rm(),
4344
_explicit_gc(explicit_gc),
4445
_g1h(G1CollectedHeap::heap()),
4546
_svc_marker(SvcGCMarker::FULL),
4647
_timer(),
47-
_tracer(),
48+
_tracer(tracer),
4849
_active(),
49-
_tracer_mark(&_timer, &_tracer),
50+
_tracer_mark(&_timer, _tracer),
5051
_soft_refs(clear_soft, _g1h->soft_ref_policy()),
5152
_monitoring_scope(monitoring_support, true /* full_gc */, true /* all_memory_pools_affected */),
5253
_heap_printer(_g1h),
@@ -75,7 +76,7 @@ STWGCTimer* G1FullGCScope::timer() {
7576
}
7677

7778
G1FullGCTracer* G1FullGCScope::tracer() {
78-
return &_tracer;
79+
return _tracer;
7980
}
8081

8182
size_t G1FullGCScope::region_compaction_threshold() {

src/hotspot/share/gc/g1/g1FullGCScope.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class G1FullGCScope : public StackObj {
5151
G1CollectedHeap* _g1h;
5252
SvcGCMarker _svc_marker;
5353
STWGCTimer _timer;
54-
G1FullGCTracer _tracer;
54+
G1FullGCTracer* _tracer;
5555
IsGCActiveMark _active;
5656
G1FullGCJFRTracerMark _tracer_mark;
5757
ClearedAllSoftRefs _soft_refs;
@@ -63,7 +63,8 @@ class G1FullGCScope : public StackObj {
6363
G1FullGCScope(G1MonitoringSupport* monitoring_support,
6464
bool explicit_gc,
6565
bool clear_soft,
66-
bool do_maximal_compaction);
66+
bool do_maximal_compaction,
67+
G1FullGCTracer* tracer);
6768
~G1FullGCScope();
6869

6970
bool is_explicit_gc();

src/hotspot/share/gc/g1/g1VMOperations.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
2727
#include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
2828
#include "gc/g1/g1Policy.hpp"
2929
#include "gc/g1/g1VMOperations.hpp"
30+
#include "gc/g1/g1Trace.hpp"
3031
#include "gc/shared/concurrentGCBreakpoints.hpp"
3132
#include "gc/shared/gcCause.hpp"
3233
#include "gc/shared/gcId.hpp"
@@ -161,8 +162,8 @@ void VM_G1CollectForAllocation::doit() {
161162

162163
void VM_G1PauseConcurrent::doit() {
163164
GCIdMark gc_id_mark(_gc_id);
164-
GCTraceCPUTime tcpu;
165165
G1CollectedHeap* g1h = G1CollectedHeap::heap();
166+
GCTraceCPUTime tcpu(g1h->concurrent_mark()->gc_tracer_cm());
166167

167168
// GCTraceTime(...) only supports sub-phases, so a more verbose version
168169
// is needed when we report the top-level pause phase.

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
17671767
Threads::number_of_non_daemon_threads());
17681768
ParallelScavengeHeap::heap()->workers().update_active_workers(active_workers);
17691769

1770-
GCTraceCPUTime tcpu;
1770+
GCTraceCPUTime tcpu(&_gc_tracer);
17711771
GCTraceTime(Info, gc) tm("Pause Full", NULL, gc_cause, true);
17721772

17731773
heap->pre_full_gc_dump(&_gc_timer);

src/hotspot/share/gc/parallel/psScavenge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ bool PSScavenge::invoke_no_policy() {
421421
{
422422
ResourceMark rm;
423423

424-
GCTraceCPUTime tcpu;
424+
GCTraceCPUTime tcpu(&_gc_tracer);
425425
GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true);
426426
TraceCollectorStats tcs(counters());
427427
TraceMemoryManagerStats tms(heap->young_gc_manager(), gc_cause, "end of minor GC");

src/hotspot/share/gc/serial/defNewGeneration.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ DefNewGeneration::DefNewGeneration(ReservedSpace rs,
182182
_pretenure_size_threshold_words = PretenureSizeThreshold >> LogHeapWordSize;
183183

184184
_gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
185+
186+
_gc_tracer = new (ResourceObj::C_HEAP, mtGC) DefNewTracer();
185187
}
186188

187189
void DefNewGeneration::compute_space_boundaries(uintx minimum_eden_size,
@@ -531,8 +533,7 @@ void DefNewGeneration::collect(bool full,
531533
SerialHeap* heap = SerialHeap::heap();
532534

533535
_gc_timer->register_gc_start();
534-
DefNewTracer gc_tracer;
535-
gc_tracer.report_gc_start(heap->gc_cause(), _gc_timer->gc_start());
536+
_gc_tracer->report_gc_start(heap->gc_cause(), _gc_timer->gc_start());
536537

537538
_old_gen = heap->old_gen();
538539

@@ -550,7 +551,7 @@ void DefNewGeneration::collect(bool full,
550551

551552
GCTraceTime(Trace, gc, phases) tm("DefNew", NULL, heap->gc_cause());
552553

553-
heap->trace_heap_before_gc(&gc_tracer);
554+
heap->trace_heap_before_gc(_gc_tracer);
554555

555556
// These can be shared for all code paths
556557
IsAliveClosure is_alive(this);
@@ -594,8 +595,8 @@ void DefNewGeneration::collect(bool full,
594595
ReferenceProcessorPhaseTimes pt(_gc_timer, rp->max_num_queues());
595596
SerialGCRefProcProxyTask task(is_alive, keep_alive, evacuate_followers);
596597
const ReferenceProcessorStats& stats = rp->process_discovered_references(task, pt);
597-
gc_tracer.report_gc_reference_stats(stats);
598-
gc_tracer.report_tenuring_threshold(tenuring_threshold());
598+
_gc_tracer->report_gc_reference_stats(stats);
599+
_gc_tracer->report_tenuring_threshold(tenuring_threshold());
599600
pt.print_all_references();
600601

601602
assert(heap->no_allocs_since_save_marks(), "save marks have not been newly set.");
@@ -647,19 +648,19 @@ void DefNewGeneration::collect(bool full,
647648

648649
// Inform the next generation that a promotion failure occurred.
649650
_old_gen->promotion_failure_occurred();
650-
gc_tracer.report_promotion_failed(_promotion_failed_info);
651+
_gc_tracer->report_promotion_failed(_promotion_failed_info);
651652

652653
// Reset the PromotionFailureALot counters.
653654
NOT_PRODUCT(heap->reset_promotion_should_fail();)
654655
}
655656
// We should have processed and cleared all the preserved marks.
656657
_preserved_marks_set.reclaim();
657658

658-
heap->trace_heap_after_gc(&gc_tracer);
659+
heap->trace_heap_after_gc(_gc_tracer);
659660

660661
_gc_timer->register_gc_end();
661662

662-
gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
663+
_gc_tracer->report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
663664
}
664665

665666
void DefNewGeneration::init_assuming_no_promotion_failure() {

0 commit comments

Comments
 (0)