Skip to content

Commit d6c4be6

Browse files
author
Thomas Schatzl
committed
8350758: G1: Use actual last prediction in accumulated survivor rate prediction too
Reviewed-by: ayang, iwalulya
1 parent 2019f44 commit d6c4be6

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,23 @@ void G1SurvRateGroup::stop_adding_regions() {
6868
_accum_surv_rate_pred = REALLOC_C_HEAP_ARRAY(double, _accum_surv_rate_pred, _num_added_regions, mtGC);
6969
_surv_rate_predictors = REALLOC_C_HEAP_ARRAY(TruncatedSeq*, _surv_rate_predictors, _num_added_regions, mtGC);
7070

71-
// Assume that the prediction for the newly added regions is the same as the
72-
// ones at the (current) end of the array. Particularly predictions at the end
73-
// of this array fairly seldom get updated, so having a better initial value
74-
// that is at least somewhat related to the actual application is preferable.
75-
double new_pred = _stats_arrays_length > 1
76-
? _accum_surv_rate_pred[_stats_arrays_length - 1] - _accum_surv_rate_pred[_stats_arrays_length - 2]
77-
: InitialSurvivorRate;
78-
7971
for (uint i = _stats_arrays_length; i < _num_added_regions; ++i) {
8072
// Initialize predictors and accumulated survivor rate predictions.
8173
_surv_rate_predictors[i] = new TruncatedSeq(10);
8274
if (i == 0) {
8375
_surv_rate_predictors[i]->add(InitialSurvivorRate);
84-
_accum_surv_rate_pred[i] = 0.0;
76+
_accum_surv_rate_pred[i] = InitialSurvivorRate;
8577
} else {
86-
_surv_rate_predictors[i]->add(_surv_rate_predictors[i-1]->last());
87-
_accum_surv_rate_pred[i] = _accum_surv_rate_pred[i-1] + new_pred;
78+
// Assume that the prediction for the newly added regions is the same as the
79+
// ones at the (current) end of the array. Particularly predictions at the end
80+
// of this array fairly seldom get updated, so having a better initial value
81+
// that is at least somewhat related to the actual application is preferable.
82+
double next_pred = _surv_rate_predictors[i-1]->last();
83+
_surv_rate_predictors[i]->add(next_pred);
84+
_accum_surv_rate_pred[i] = _accum_surv_rate_pred[i-1] + next_pred;
8885
}
8986
}
90-
_last_pred = new_pred;
87+
_last_pred = _surv_rate_predictors[_num_added_regions-1]->last();
9188

9289
_stats_arrays_length = _num_added_regions;
9390
}

0 commit comments

Comments
 (0)