8294847: Fix calculation of G1 effective scanned cards prediction

Reviewed-by: kbarrett, ayang
This commit is contained in:
Thomas Schatzl 2022-10-13 12:00:01 +00:00
parent 2f60675e06
commit 7e4868de7b
3 changed files with 15 additions and 13 deletions

View File

@ -241,13 +241,9 @@ double G1Analytics::predict_dirtied_cards_rate_ms() const {
return predict_zero_bounded(_dirtied_cards_rate_ms_seq);
}
double G1Analytics::predict_young_card_merge_to_scan_ratio() const {
return predict_in_unit_interval(_young_card_merge_to_scan_ratio_seq);
}
size_t G1Analytics::predict_scan_card_num(size_t rs_length, bool for_young_gc) const {
if (for_young_gc || !enough_samples_available(_mixed_card_merge_to_scan_ratio_seq)) {
return (size_t)(rs_length * predict_young_card_merge_to_scan_ratio());
return (size_t)(rs_length * predict_in_unit_interval(_young_card_merge_to_scan_ratio_seq));
} else {
return (size_t)(rs_length * predict_in_unit_interval(_mixed_card_merge_to_scan_ratio_seq));
}

View File

@ -139,10 +139,9 @@ public:
double predict_concurrent_refine_rate_ms() const;
double predict_dirtied_cards_rate_ms() const;
double predict_young_card_merge_to_scan_ratio() const;
double predict_mixed_card_merge_to_scan_ratio() const;
// Predict how many cards in a remembered set of length rs_length will need to
// be scanned in addition to the pending log buffer cards.
size_t predict_scan_card_num(size_t rs_length, bool for_young_gc) const;
double predict_card_merge_time_ms(size_t card_num, bool for_young_gc) const;

View File

@ -1010,17 +1010,24 @@ void G1Policy::record_young_gc_pause_end(bool evacuation_failed) {
double G1Policy::predict_base_time_ms(size_t pending_cards,
size_t rs_length) const {
size_t effective_scanned_cards = _analytics->predict_scan_card_num(rs_length, collector_state()->in_young_only_phase());
bool in_young_only_phase = collector_state()->in_young_only_phase();
double card_merge_time = _analytics->predict_card_merge_time_ms(pending_cards + rs_length, collector_state()->in_young_only_phase());
double card_scan_time = _analytics->predict_card_scan_time_ms(effective_scanned_cards, collector_state()->in_young_only_phase());
size_t unique_cards_from_rs = _analytics->predict_scan_card_num(rs_length, in_young_only_phase);
// Assume that all cards from the log buffers will be scanned, i.e. there are no
// duplicates in that set.
size_t effective_scanned_cards = unique_cards_from_rs + pending_cards;
double card_merge_time = _analytics->predict_card_merge_time_ms(pending_cards + rs_length, in_young_only_phase);
double card_scan_time = _analytics->predict_card_scan_time_ms(effective_scanned_cards, in_young_only_phase);
double constant_other_time = _analytics->predict_constant_other_time_ms();
double survivor_evac_time = predict_survivor_regions_evac_time();
double total_time = card_merge_time + card_scan_time + constant_other_time + survivor_evac_time;
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",
total_time, pending_cards, rs_length, effective_scanned_cards, card_merge_time, card_scan_time, constant_other_time, survivor_evac_time);
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",
total_time, pending_cards, rs_length, effective_scanned_cards,
card_merge_time, card_scan_time, constant_other_time, survivor_evac_time);
return total_time;
}