Skip to content

Commit cb9358b

Browse files
author
Ivan Walulya
committed
8362278: G1: Consolidate functions for recording pause start time
Reviewed-by: tschatzl, ayang
1 parent bc9ece9 commit cb9358b

File tree

6 files changed

+28
-45
lines changed

6 files changed

+28
-45
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ void G1ConcurrentMark::remark() {
13801380
}
13811381

13821382
G1Policy* policy = _g1h->policy();
1383-
policy->record_concurrent_mark_remark_start();
1383+
policy->record_pause_start_time();
13841384

13851385
double start = os::elapsedTime();
13861386

@@ -1516,7 +1516,7 @@ void G1ConcurrentMark::cleanup() {
15161516
}
15171517

15181518
G1Policy* policy = _g1h->policy();
1519-
policy->record_concurrent_mark_cleanup_start();
1519+
policy->record_pause_start_time();
15201520

15211521
double start = os::elapsedTime();
15221522

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ void G1GCPhaseTimes::reset() {
180180
_cur_post_evacuate_cleanup_2_time_ms = 0.0;
181181
_cur_resize_heap_time_ms = 0.0;
182182
_cur_ref_proc_time_ms = 0.0;
183-
_cur_collection_start_sec = 0.0;
184183
_root_region_scan_wait_time_ms = 0.0;
185184
_external_accounted_time_ms = 0.0;
186185
_recorded_prepare_heap_roots_time_ms = 0.0;

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
191191
double _cur_resize_heap_time_ms;
192192
double _cur_ref_proc_time_ms;
193193

194-
double _cur_collection_start_sec;
195194
// Not included in _gc_pause_time_ms
196195
double _root_region_scan_wait_time_ms;
197196

@@ -367,10 +366,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
367366
_recorded_prepare_for_mutator_time_ms = time_ms;
368367
}
369368

370-
void record_cur_collection_start_sec(double time_ms) {
371-
_cur_collection_start_sec = time_ms;
372-
}
373-
374369
void record_verify_before_time_ms(double time_ms) {
375370
_cur_verify_before_time_ms = time_ms;
376371
}
@@ -387,10 +382,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
387382
_recorded_prepare_heap_roots_time_ms = recorded_prepare_heap_roots_time_ms;
388383
}
389384

390-
double cur_collection_start_sec() {
391-
return _cur_collection_start_sec;
392-
}
393-
394385
double cur_distribute_log_buffers_time_ms() {
395386
return _cur_distribute_log_buffers_time_ms;
396387
}

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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ G1Policy::G1Policy(STWGCTimer* gc_timer) :
5858
_old_gen_alloc_tracker(),
5959
_ihop_control(create_ihop_control(&_old_gen_alloc_tracker, &_predictor)),
6060
_policy_counters(new GCPolicyCounters("GarbageFirst", 1, 2)),
61-
_full_collection_start_sec(0.0),
61+
_cur_pause_start_sec(0.0),
6262
_young_list_desired_length(0),
6363
_young_list_target_length(0),
6464
_eden_surv_rate_group(new G1SurvRateGroup()),
@@ -74,8 +74,6 @@ G1Policy::G1Policy(STWGCTimer* gc_timer) :
7474
_g1h(nullptr),
7575
_phase_times_timer(gc_timer),
7676
_phase_times(nullptr),
77-
_mark_remark_start_sec(0),
78-
_mark_cleanup_start_sec(0),
7977
_tenuring_threshold(MaxTenuringThreshold),
8078
_max_survivor_regions(0),
8179
_survivors_age_table(true)
@@ -572,7 +570,7 @@ void G1Policy::revise_young_list_target_length(size_t card_rs_length, size_t cod
572570
}
573571

574572
void G1Policy::record_full_collection_start() {
575-
_full_collection_start_sec = os::elapsedTime();
573+
record_pause_start_time();
576574
// Release the future to-space so that it is available for compaction into.
577575
collector_state()->set_in_young_only_phase(false);
578576
collector_state()->set_in_full_gc(true);
@@ -605,7 +603,8 @@ void G1Policy::record_full_collection_end() {
605603

606604
_old_gen_alloc_tracker.reset_after_gc(_g1h->humongous_regions_count() * G1HeapRegion::GrainBytes);
607605

608-
record_pause(G1GCPauseType::FullGC, _full_collection_start_sec, end_sec);
606+
double start_time_sec = cur_pause_start_sec();
607+
record_pause(G1GCPauseType::FullGC, start_time_sec, end_sec);
609608
}
610609

611610
static void log_refinement_stats(const char* kind, const G1ConcurrentRefineStats& stats) {
@@ -650,7 +649,7 @@ void G1Policy::record_concurrent_refinement_stats(size_t pending_cards,
650649

651650
// Record mutator's card logging rate.
652651
double mut_start_time = _analytics->prev_collection_pause_end_ms();
653-
double mut_end_time = phase_times()->cur_collection_start_sec() * MILLIUNITS;
652+
double mut_end_time = cur_pause_start_sec() * MILLIUNITS;
654653
double mut_time = mut_end_time - mut_start_time;
655654
// Unlike above for conc-refine rate, here we should not require a
656655
// non-empty sample, since an application could go some time with only
@@ -669,8 +668,13 @@ bool G1Policy::should_retain_evac_failed_region(uint index) const {
669668
return live_bytes < threshold;
670669
}
671670

672-
void G1Policy::record_young_collection_start() {
671+
void G1Policy::record_pause_start_time() {
673672
Ticks now = Ticks::now();
673+
_cur_pause_start_sec = now.seconds();
674+
}
675+
676+
void G1Policy::record_young_collection_start() {
677+
record_pause_start_time();
674678
// We only need to do this here as the policy will only be applied
675679
// to the GC we're about to start. so, no point is calculating this
676680
// every time we calculate / recalculate the target young length.
@@ -681,8 +685,6 @@ void G1Policy::record_young_collection_start() {
681685
max_survivor_regions(), _g1h->num_used_regions(), _g1h->max_num_regions());
682686
assert_used_and_recalculate_used_equal(_g1h);
683687

684-
phase_times()->record_cur_collection_start_sec(now.seconds());
685-
686688
// do that for any other surv rate groups
687689
_eden_surv_rate_group->stop_adding_regions();
688690
_survivors_age_table.clear();
@@ -695,19 +697,12 @@ void G1Policy::record_concurrent_mark_init_end() {
695697
collector_state()->set_in_concurrent_start_gc(false);
696698
}
697699

698-
void G1Policy::record_concurrent_mark_remark_start() {
699-
_mark_remark_start_sec = os::elapsedTime();
700-
}
701-
702700
void G1Policy::record_concurrent_mark_remark_end() {
703701
double end_time_sec = os::elapsedTime();
704-
double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0;
702+
double start_time_sec = cur_pause_start_sec();
703+
double elapsed_time_ms = (end_time_sec - start_time_sec) * 1000.0;
705704
_analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms);
706-
record_pause(G1GCPauseType::Remark, _mark_remark_start_sec, end_time_sec);
707-
}
708-
709-
void G1Policy::record_concurrent_mark_cleanup_start() {
710-
_mark_cleanup_start_sec = os::elapsedTime();
705+
record_pause(G1GCPauseType::Remark, start_time_sec, end_time_sec);
711706
}
712707

713708
G1CollectionSetCandidates* G1Policy::candidates() const {
@@ -795,7 +790,7 @@ double G1Policy::logged_cards_processing_time() const {
795790
void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mark, bool allocation_failure) {
796791
G1GCPhaseTimes* p = phase_times();
797792

798-
double start_time_sec = phase_times()->cur_collection_start_sec();
793+
double start_time_sec = cur_pause_start_sec();
799794
double end_time_sec = Ticks::now().seconds();
800795
double pause_time_ms = (end_time_sec - start_time_sec) * 1000.0;
801796

@@ -1321,10 +1316,11 @@ void G1Policy::record_concurrent_mark_cleanup_end(bool has_rebuilt_remembered_se
13211316
collector_state()->set_clear_bitmap_in_progress(true);
13221317

13231318
double end_sec = os::elapsedTime();
1324-
double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
1319+
double start_sec = cur_pause_start_sec();
1320+
double elapsed_time_ms = (end_sec - start_sec) * 1000.0;
13251321
_analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms);
13261322

1327-
record_pause(G1GCPauseType::Cleanup, _mark_cleanup_start_sec, end_sec);
1323+
record_pause(G1GCPauseType::Cleanup, start_sec, end_sec);
13281324
}
13291325

13301326
void G1Policy::abandon_collection_set_candidates() {

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class G1Policy: public CHeapObj<mtGC> {
7676

7777
GCPolicyCounters* _policy_counters;
7878

79-
double _full_collection_start_sec;
79+
double _cur_pause_start_sec;
8080

8181
// Desired young gen length without taking actually available free regions into
8282
// account.
@@ -134,6 +134,10 @@ class G1Policy: public CHeapObj<mtGC> {
134134
_card_rs_length = card_rs_length;
135135
}
136136

137+
double cur_pause_start_sec() const {
138+
return _cur_pause_start_sec;
139+
}
140+
137141
double predict_base_time_ms(size_t pending_cards) const;
138142

139143
double predict_base_time_ms(size_t pending_cards, size_t card_rs_length) const;
@@ -196,11 +200,6 @@ class G1Policy: public CHeapObj<mtGC> {
196200
// Lazily initialized
197201
mutable G1GCPhaseTimes* _phase_times;
198202

199-
// This set of variables tracks the collector efficiency, in order to
200-
// determine whether we should initiate a new marking.
201-
double _mark_remark_start_sec;
202-
double _mark_cleanup_start_sec;
203-
204203
// Updates the internal young gen maximum and target and desired lengths.
205204
// If no parameters are passed, predict pending cards, card set remset length and
206205
// code root remset length using the prediction model.
@@ -306,6 +305,7 @@ class G1Policy: public CHeapObj<mtGC> {
306305
bool about_to_start_mixed_phase() const;
307306

308307
// Record the start and end of the actual collection part of the evacuation pause.
308+
void record_pause_start_time();
309309
void record_young_collection_start();
310310
void record_young_collection_end(bool concurrent_operation_is_full_mark, bool allocation_failure);
311311

@@ -316,12 +316,9 @@ class G1Policy: public CHeapObj<mtGC> {
316316
// Must currently be called while the world is stopped.
317317
void record_concurrent_mark_init_end();
318318

319-
// Record start and end of remark.
320-
void record_concurrent_mark_remark_start();
321319
void record_concurrent_mark_remark_end();
322320

323321
// Record start, end, and completion of cleanup.
324-
void record_concurrent_mark_cleanup_start();
325322
void record_concurrent_mark_cleanup_end(bool has_rebuilt_remembered_sets);
326323

327324
bool next_gc_should_be_mixed() const;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,11 @@ void G1YoungCollector::evacuate_next_optional_regions(G1ParScanThreadStateSet* p
815815
}
816816

817817
void G1YoungCollector::evacuate_optional_collection_set(G1ParScanThreadStateSet* per_thread_states) {
818-
const double collection_start_time_ms = phase_times()->cur_collection_start_sec() * 1000.0;
818+
const double pause_start_time_ms = policy()->cur_pause_start_sec() * 1000.0;
819819

820820
while (!evacuation_alloc_failed() && collection_set()->num_optional_regions() > 0) {
821821

822-
double time_used_ms = os::elapsedTime() * 1000.0 - collection_start_time_ms;
822+
double time_used_ms = os::elapsedTime() * 1000.0 - pause_start_time_ms;
823823
double time_left_ms = MaxGCPauseMillis - time_used_ms;
824824

825825
if (time_left_ms < 0 ||

0 commit comments

Comments
 (0)