author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 47216 | 71c04702a3d5 |
child 51332 | c25572739e7c |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
1374 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
33214
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
30764
diff
changeset
|
27 |
#include "gc/g1/g1Predictions.hpp" |
30764 | 28 |
#include "gc/g1/heapRegion.hpp" |
29 |
#include "gc/g1/survRateGroup.hpp" |
|
35061 | 30 |
#include "logging/log.hpp" |
7397 | 31 |
#include "memory/allocation.hpp" |
1374 | 32 |
|
38185
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
33 |
SurvRateGroup::SurvRateGroup() : |
2009 | 34 |
_accum_surv_rate_pred(NULL), |
12117 | 35 |
_surv_rate_pred(NULL), |
36 |
_stats_arrays_length(0) { |
|
2009 | 37 |
reset(); |
1374 | 38 |
start_adding_regions(); |
39 |
} |
|
40 |
||
12117 | 41 |
void SurvRateGroup::reset() { |
2009 | 42 |
_all_regions_allocated = 0; |
43 |
_setup_seq_num = 0; |
|
44 |
_last_pred = 0.0; |
|
45 |
// the following will set up the arrays with length 1 |
|
46 |
_region_num = 1; |
|
12117 | 47 |
|
48 |
// The call to stop_adding_regions() will use "new" to refill |
|
49 |
// the _surv_rate_pred array, so we need to make sure to call |
|
50 |
// "delete". |
|
51 |
for (size_t i = 0; i < _stats_arrays_length; ++i) { |
|
52 |
delete _surv_rate_pred[i]; |
|
53 |
} |
|
54 |
_stats_arrays_length = 0; |
|
55 |
||
2009 | 56 |
stop_adding_regions(); |
38185
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
57 |
|
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
58 |
// Seed initial _surv_rate_pred and _accum_surv_rate_pred values |
2009 | 59 |
guarantee( _stats_arrays_length == 1, "invariant" ); |
60 |
guarantee( _surv_rate_pred[0] != NULL, "invariant" ); |
|
38185
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
61 |
const double initial_surv_rate = 0.4; |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
62 |
_surv_rate_pred[0]->add(initial_surv_rate); |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
63 |
_last_pred = _accum_surv_rate_pred[0] = initial_surv_rate; |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
64 |
|
2009 | 65 |
_region_num = 0; |
66 |
} |
|
67 |
||
33215 | 68 |
void SurvRateGroup::start_adding_regions() { |
2009 | 69 |
_setup_seq_num = _stats_arrays_length; |
5350
cccf0925702e
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
2105
diff
changeset
|
70 |
_region_num = 0; |
1374 | 71 |
} |
72 |
||
33215 | 73 |
void SurvRateGroup::stop_adding_regions() { |
2009 | 74 |
if (_region_num > _stats_arrays_length) { |
38185
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
75 |
_accum_surv_rate_pred = REALLOC_C_HEAP_ARRAY(double, _accum_surv_rate_pred, _region_num, mtGC); |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
76 |
_surv_rate_pred = REALLOC_C_HEAP_ARRAY(TruncatedSeq*, _surv_rate_pred, _region_num, mtGC); |
1374 | 77 |
|
2009 | 78 |
for (size_t i = _stats_arrays_length; i < _region_num; ++i) { |
1374 | 79 |
_surv_rate_pred[i] = new TruncatedSeq(10); |
80 |
} |
|
81 |
||
2009 | 82 |
_stats_arrays_length = _region_num; |
1374 | 83 |
} |
84 |
} |
|
85 |
||
33215 | 86 |
void SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) { |
2009 | 87 |
guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num, |
1374 | 88 |
"pre-condition" ); |
89 |
||
90 |
double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords; |
|
91 |
_surv_rate_pred[age_in_group]->add(surv_rate); |
|
38185
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
92 |
} |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
93 |
|
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
94 |
void SurvRateGroup::all_surviving_words_recorded(const G1Predictions& predictor, bool update_predictors) { |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
95 |
if (update_predictors) { |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
96 |
fill_in_last_surv_rates(); |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
97 |
} |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
98 |
finalize_predictions(predictor); |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
99 |
} |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
100 |
|
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
101 |
void SurvRateGroup::fill_in_last_surv_rates() { |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
102 |
if (_region_num > 0) { // conservative |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
103 |
double surv_rate = _surv_rate_pred[_region_num-1]->last(); |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
104 |
for (size_t i = _region_num; i < _stats_arrays_length; ++i) { |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
105 |
_surv_rate_pred[i]->add(surv_rate); |
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
106 |
} |
1374 | 107 |
} |
108 |
} |
|
109 |
||
38185
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
110 |
void SurvRateGroup::finalize_predictions(const G1Predictions& predictor) { |
1374 | 111 |
double accum = 0.0; |
112 |
double pred = 0.0; |
|
2009 | 113 |
for (size_t i = 0; i < _stats_arrays_length; ++i) { |
38185
c432f8466c73
8155634: Clean out old logging and dead code from SurvRateGroup
mgerdin
parents:
35061
diff
changeset
|
114 |
pred = predictor.get_new_prediction(_surv_rate_pred[i]); |
1374 | 115 |
if (pred > 1.0) pred = 1.0; |
116 |
accum += pred; |
|
117 |
_accum_surv_rate_pred[i] = accum; |
|
118 |
} |
|
119 |
_last_pred = pred; |
|
120 |
} |