Skip to content

Commit 7e4868d

Browse files
author
Thomas Schatzl
committed
8294847: Fix calculation of G1 effective scanned cards prediction
Reviewed-by: kbarrett, ayang
1 parent 2f60675 commit 7e4868d

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,9 @@ double G1Analytics::predict_dirtied_cards_rate_ms() const {
241241
return predict_zero_bounded(_dirtied_cards_rate_ms_seq);
242242
}
243243

244-
double G1Analytics::predict_young_card_merge_to_scan_ratio() const {
245-
return predict_in_unit_interval(_young_card_merge_to_scan_ratio_seq);
246-
}
247-
248244
size_t G1Analytics::predict_scan_card_num(size_t rs_length, bool for_young_gc) const {
249245
if (for_young_gc || !enough_samples_available(_mixed_card_merge_to_scan_ratio_seq)) {
250-
return (size_t)(rs_length * predict_young_card_merge_to_scan_ratio());
246+
return (size_t)(rs_length * predict_in_unit_interval(_young_card_merge_to_scan_ratio_seq));
251247
} else {
252248
return (size_t)(rs_length * predict_in_unit_interval(_mixed_card_merge_to_scan_ratio_seq));
253249
}

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@ class G1Analytics: public CHeapObj<mtGC> {
139139

140140
double predict_concurrent_refine_rate_ms() const;
141141
double predict_dirtied_cards_rate_ms() const;
142-
double predict_young_card_merge_to_scan_ratio() const;
143-
144-
double predict_mixed_card_merge_to_scan_ratio() const;
145142

143+
// Predict how many cards in a remembered set of length rs_length will need to
144+
// be scanned in addition to the pending log buffer cards.
146145
size_t predict_scan_card_num(size_t rs_length, bool for_young_gc) const;
147146

148147
double predict_card_merge_time_ms(size_t card_num, bool for_young_gc) const;

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

+12-5
Original file line numberDiff line numberDiff line change
@@ -1010,17 +1010,24 @@ void G1Policy::record_young_gc_pause_end(bool evacuation_failed) {
10101010

10111011
double G1Policy::predict_base_time_ms(size_t pending_cards,
10121012
size_t rs_length) const {
1013-
size_t effective_scanned_cards = _analytics->predict_scan_card_num(rs_length, collector_state()->in_young_only_phase());
1013+
bool in_young_only_phase = collector_state()->in_young_only_phase();
10141014

1015-
double card_merge_time = _analytics->predict_card_merge_time_ms(pending_cards + rs_length, collector_state()->in_young_only_phase());
1016-
double card_scan_time = _analytics->predict_card_scan_time_ms(effective_scanned_cards, collector_state()->in_young_only_phase());
1015+
size_t unique_cards_from_rs = _analytics->predict_scan_card_num(rs_length, in_young_only_phase);
1016+
// Assume that all cards from the log buffers will be scanned, i.e. there are no
1017+
// duplicates in that set.
1018+
size_t effective_scanned_cards = unique_cards_from_rs + pending_cards;
1019+
1020+
double card_merge_time = _analytics->predict_card_merge_time_ms(pending_cards + rs_length, in_young_only_phase);
1021+
double card_scan_time = _analytics->predict_card_scan_time_ms(effective_scanned_cards, in_young_only_phase);
10171022
double constant_other_time = _analytics->predict_constant_other_time_ms();
10181023
double survivor_evac_time = predict_survivor_regions_evac_time();
10191024

10201025
double total_time = card_merge_time + card_scan_time + constant_other_time + survivor_evac_time;
10211026

1022-
log_trace(gc, ergo, heap)("Predicted base time: total %f lb_cards %zu rs_length %zu effective_scanned_cards %zu card_merge_time %f card_scan_time %f constant_other_time %f survivor_evac_time %f",
1023-
total_time, pending_cards, rs_length, effective_scanned_cards, card_merge_time, card_scan_time, constant_other_time, survivor_evac_time);
1027+
log_trace(gc, ergo, heap)("Predicted base time: total %f lb_cards %zu rs_length %zu effective_scanned_cards %zu "
1028+
"card_merge_time %f card_scan_time %f constant_other_time %f survivor_evac_time %f",
1029+
total_time, pending_cards, rs_length, effective_scanned_cards,
1030+
card_merge_time, card_scan_time, constant_other_time, survivor_evac_time);
10241031
return total_time;
10251032
}
10261033

0 commit comments

Comments
 (0)