@@ -68,13 +68,26 @@ 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+
7179 for (size_t i = _stats_arrays_length; i < _num_added_regions; ++i) {
7280 // Initialize predictors and accumulated survivor rate predictions.
7381 _surv_rate_predictors[i] = new TruncatedSeq (10 );
74- _surv_rate_predictors[i]->add (InitialSurvivorRate);
75- _accum_surv_rate_pred[i] = ((i == 0 ) ? 0.0 : _accum_surv_rate_pred[i-1 ]) + InitialSurvivorRate;
82+ if (i == 0 ) {
83+ _surv_rate_predictors[i]->add (InitialSurvivorRate);
84+ _accum_surv_rate_pred[i] = 0.0 ;
85+ } 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;
88+ }
7689 }
77- _last_pred = InitialSurvivorRate ;
90+ _last_pred = new_pred ;
7891
7992 _stats_arrays_length = _num_added_regions;
8093 }
0 commit comments