Skip to content

Commit

Permalink
8349906: G1: Improve initial survivor rate for newly used young regions
Browse files Browse the repository at this point in the history
Reviewed-by: kbarrett, iwalulya
  • Loading branch information
Thomas Schatzl committed Feb 26, 2025
1 parent a431046 commit aac9cb4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/hotspot/share/gc/g1/g1SurvRateGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,26 @@ void G1SurvRateGroup::stop_adding_regions() {
_accum_surv_rate_pred = REALLOC_C_HEAP_ARRAY(double, _accum_surv_rate_pred, _num_added_regions, mtGC);
_surv_rate_predictors = REALLOC_C_HEAP_ARRAY(TruncatedSeq*, _surv_rate_predictors, _num_added_regions, mtGC);

// Assume that the prediction for the newly added regions is the same as the
// ones at the (current) end of the array. Particularly predictions at the end
// of this array fairly seldom get updated, so having a better initial value
// that is at least somewhat related to the actual application is preferable.
double new_pred = _stats_arrays_length > 1
? _accum_surv_rate_pred[_stats_arrays_length - 1] - _accum_surv_rate_pred[_stats_arrays_length - 2]
: InitialSurvivorRate;

for (size_t i = _stats_arrays_length; i < _num_added_regions; ++i) {
// Initialize predictors and accumulated survivor rate predictions.
_surv_rate_predictors[i] = new TruncatedSeq(10);
_surv_rate_predictors[i]->add(InitialSurvivorRate);
_accum_surv_rate_pred[i] = ((i == 0) ? 0.0 : _accum_surv_rate_pred[i-1]) + InitialSurvivorRate;
if (i == 0) {
_surv_rate_predictors[i]->add(InitialSurvivorRate);
_accum_surv_rate_pred[i] = 0.0;
} else {
_surv_rate_predictors[i]->add(_surv_rate_predictors[i-1]->last());
_accum_surv_rate_pred[i] = _accum_surv_rate_pred[i-1] + new_pred;
}
}
_last_pred = InitialSurvivorRate;
_last_pred = new_pred;

_stats_arrays_length = _num_added_regions;
}
Expand Down

0 comments on commit aac9cb4

Please sign in to comment.