From 5ab28451a9dd238cbb121d9d61289dd5e13b3bcc Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Wed, 26 Feb 2025 12:05:26 +0100 Subject: [PATCH 1/2] 8350758 Hi all, please review this fix to recent JDK-8349906 to use the current survivor rate in the accumulated survivor rate for initializing newly allocated entries as well. Testing: gha Thanks, Thomas --- src/hotspot/share/gc/g1/g1SurvRateGroup.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp b/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp index d5fd50c4523cd..5c17c305ac69d 100644 --- a/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp +++ b/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp @@ -68,14 +68,6 @@ 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 (uint i = _stats_arrays_length; i < _num_added_regions; ++i) { // Initialize predictors and accumulated survivor rate predictions. _surv_rate_predictors[i] = new TruncatedSeq(10); @@ -83,11 +75,16 @@ void G1SurvRateGroup::stop_adding_regions() { _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; + // 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 next_pred = _surv_rate_predictors[i-1]->last(); + _surv_rate_predictors[i]->add(next_pred); + _accum_surv_rate_pred[i] = _accum_surv_rate_pred[i-1] + next_pred; } } - _last_pred = new_pred; + _last_pred = _surv_rate_predictors[_num_added_regions-1]->last(); _stats_arrays_length = _num_added_regions; } From 8bfe673a4995c413749f323e6b9fb81f24c0a7d5 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Thu, 27 Feb 2025 13:17:09 +0100 Subject: [PATCH 2/2] * ayang review --- src/hotspot/share/gc/g1/g1SurvRateGroup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp b/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp index 5c17c305ac69d..f858b93b13d49 100644 --- a/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp +++ b/src/hotspot/share/gc/g1/g1SurvRateGroup.cpp @@ -73,7 +73,7 @@ void G1SurvRateGroup::stop_adding_regions() { _surv_rate_predictors[i] = new TruncatedSeq(10); if (i == 0) { _surv_rate_predictors[i]->add(InitialSurvivorRate); - _accum_surv_rate_pred[i] = 0.0; + _accum_surv_rate_pred[i] = InitialSurvivorRate; } else { // 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