author | stefank |
Tue, 04 Jul 2017 15:58:10 +0200 | |
changeset 46619 | a3919f5e8d2b |
parent 46618 | d503911aa948 |
child 46625 | edefffab74e2 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
40903
efb9ac3b77ce
8163860: Convert TestOldFreeSpaceCalculation_test to GTest
kzhaldyb
parents:
37466
diff
changeset
|
2 |
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 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:
5343
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5343
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:
5343
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/parallel/parallelScavengeHeap.hpp" |
27 |
#include "gc/parallel/psAdaptiveSizePolicy.hpp" |
|
28 |
#include "gc/parallel/psGCAdaptivePolicyCounters.hpp" |
|
29 |
#include "gc/parallel/psScavenge.hpp" |
|
30 |
#include "gc/shared/collectorPolicy.hpp" |
|
31 |
#include "gc/shared/gcCause.hpp" |
|
32 |
#include "gc/shared/gcPolicyCounters.hpp" |
|
35061 | 33 |
#include "logging/log.hpp" |
7397 | 34 |
#include "runtime/timer.hpp" |
1 | 35 |
|
36 |
#include <math.h> |
|
37 |
||
38 |
PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size, |
|
39 |
size_t init_promo_size, |
|
40 |
size_t init_survivor_size, |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
41 |
size_t space_alignment, |
1 | 42 |
double gc_pause_goal_sec, |
43 |
double gc_minor_pause_goal_sec, |
|
44 |
uint gc_cost_ratio) : |
|
45 |
AdaptiveSizePolicy(init_eden_size, |
|
46 |
init_promo_size, |
|
47 |
init_survivor_size, |
|
48 |
gc_pause_goal_sec, |
|
49 |
gc_cost_ratio), |
|
21560
b3ae3ba25ebb
8026853: Prepare GC code for collector policy regression fix
jwilhelm
parents:
20317
diff
changeset
|
50 |
_collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0), |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
51 |
_space_alignment(space_alignment), |
1 | 52 |
_live_at_last_full_gc(init_promo_size), |
53 |
_gc_minor_pause_goal_sec(gc_minor_pause_goal_sec), |
|
54 |
_latest_major_mutator_interval_seconds(0), |
|
55 |
_young_gen_change_for_major_pause_count(0) |
|
56 |
{ |
|
57 |
// Sizing policy statistics |
|
58 |
_avg_major_pause = |
|
59 |
new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding); |
|
60 |
_avg_minor_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
61 |
_avg_major_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
62 |
||
63 |
_avg_base_footprint = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight); |
|
64 |
_major_pause_old_estimator = |
|
65 |
new LinearLeastSquareFit(AdaptiveSizePolicyWeight); |
|
66 |
_major_pause_young_estimator = |
|
67 |
new LinearLeastSquareFit(AdaptiveSizePolicyWeight); |
|
68 |
_major_collection_estimator = |
|
69 |
new LinearLeastSquareFit(AdaptiveSizePolicyWeight); |
|
70 |
||
71 |
_young_gen_size_increment_supplement = YoungGenerationSizeSupplement; |
|
72 |
_old_gen_size_increment_supplement = TenuredGenerationSizeSupplement; |
|
73 |
||
74 |
// Start the timers |
|
75 |
_major_timer.start(); |
|
76 |
||
77 |
_old_gen_policy_is_ready = false; |
|
78 |
} |
|
79 |
||
22555
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
80 |
size_t PSAdaptiveSizePolicy::calculate_free_based_on_live(size_t live, uintx ratio_as_percentage) { |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
81 |
// We want to calculate how much free memory there can be based on the |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
82 |
// amount of live data currently in the old gen. Using the formula: |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
83 |
// ratio * (free + live) = free |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
84 |
// Some equation solving later we get: |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
85 |
// free = (live * ratio) / (1 - ratio) |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
86 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
87 |
const double ratio = ratio_as_percentage / 100.0; |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
88 |
const double ratio_inverse = 1.0 - ratio; |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
89 |
const double tmp = live * ratio; |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
90 |
size_t free = (size_t)(tmp / ratio_inverse); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
91 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
92 |
return free; |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
93 |
} |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
94 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
95 |
size_t PSAdaptiveSizePolicy::calculated_old_free_size_in_bytes() const { |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
96 |
size_t free_size = (size_t)(_promo_size + avg_promoted()->padded_average()); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
97 |
size_t live = ParallelScavengeHeap::heap()->old_gen()->used_in_bytes(); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
98 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
99 |
if (MinHeapFreeRatio != 0) { |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
100 |
size_t min_free = calculate_free_based_on_live(live, MinHeapFreeRatio); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
101 |
free_size = MAX2(free_size, min_free); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
102 |
} |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
103 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
104 |
if (MaxHeapFreeRatio != 100) { |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
105 |
size_t max_free = calculate_free_based_on_live(live, MaxHeapFreeRatio); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
106 |
free_size = MIN2(max_free, free_size); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
107 |
} |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
108 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
109 |
return free_size; |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
110 |
} |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
111 |
|
1 | 112 |
void PSAdaptiveSizePolicy::major_collection_begin() { |
113 |
// Update the interval time |
|
114 |
_major_timer.stop(); |
|
115 |
// Save most recent collection time |
|
116 |
_latest_major_mutator_interval_seconds = _major_timer.seconds(); |
|
117 |
_major_timer.reset(); |
|
118 |
_major_timer.start(); |
|
119 |
} |
|
120 |
||
121 |
void PSAdaptiveSizePolicy::update_minor_pause_old_estimator( |
|
122 |
double minor_pause_in_ms) { |
|
123 |
double promo_size_in_mbytes = ((double)_promo_size)/((double)M); |
|
124 |
_minor_pause_old_estimator->update(promo_size_in_mbytes, |
|
125 |
minor_pause_in_ms); |
|
126 |
} |
|
127 |
||
128 |
void PSAdaptiveSizePolicy::major_collection_end(size_t amount_live, |
|
129 |
GCCause::Cause gc_cause) { |
|
130 |
// Update the pause time. |
|
131 |
_major_timer.stop(); |
|
132 |
||
31634
0aa645cd8cc3
7012980: PSOldGen is increased if there is no space in Metaspace
jmasa
parents:
31359
diff
changeset
|
133 |
if (should_update_promo_stats(gc_cause)) { |
1 | 134 |
double major_pause_in_seconds = _major_timer.seconds(); |
135 |
double major_pause_in_ms = major_pause_in_seconds * MILLIUNITS; |
|
136 |
||
137 |
// Sample for performance counter |
|
138 |
_avg_major_pause->sample(major_pause_in_seconds); |
|
139 |
||
140 |
// Cost of collection (unit-less) |
|
141 |
double collection_cost = 0.0; |
|
142 |
if ((_latest_major_mutator_interval_seconds > 0.0) && |
|
143 |
(major_pause_in_seconds > 0.0)) { |
|
144 |
double interval_in_seconds = |
|
145 |
_latest_major_mutator_interval_seconds + major_pause_in_seconds; |
|
146 |
collection_cost = |
|
147 |
major_pause_in_seconds / interval_in_seconds; |
|
148 |
avg_major_gc_cost()->sample(collection_cost); |
|
149 |
||
150 |
// Sample for performance counter |
|
151 |
_avg_major_interval->sample(interval_in_seconds); |
|
152 |
} |
|
153 |
||
154 |
// Calculate variables used to estimate pause time vs. gen sizes |
|
155 |
double eden_size_in_mbytes = ((double)_eden_size)/((double)M); |
|
156 |
double promo_size_in_mbytes = ((double)_promo_size)/((double)M); |
|
157 |
_major_pause_old_estimator->update(promo_size_in_mbytes, |
|
158 |
major_pause_in_ms); |
|
159 |
_major_pause_young_estimator->update(eden_size_in_mbytes, |
|
160 |
major_pause_in_ms); |
|
161 |
||
35061 | 162 |
log_trace(gc, ergo)("psAdaptiveSizePolicy::major_collection_end: major gc cost: %f average: %f", |
163 |
collection_cost,avg_major_gc_cost()->average()); |
|
164 |
log_trace(gc, ergo)(" major pause: %f major period %f", |
|
165 |
major_pause_in_ms, _latest_major_mutator_interval_seconds * MILLIUNITS); |
|
1 | 166 |
|
167 |
// Calculate variable used to estimate collection cost vs. gen sizes |
|
168 |
assert(collection_cost >= 0.0, "Expected to be non-negative"); |
|
169 |
_major_collection_estimator->update(promo_size_in_mbytes, |
|
170 |
collection_cost); |
|
171 |
} |
|
172 |
||
173 |
// Update the amount live at the end of a full GC |
|
174 |
_live_at_last_full_gc = amount_live; |
|
175 |
||
176 |
// The policy does not have enough data until at least some major collections |
|
177 |
// have been done. |
|
178 |
if (_avg_major_pause->count() >= AdaptiveSizePolicyReadyThreshold) { |
|
179 |
_old_gen_policy_is_ready = true; |
|
180 |
} |
|
181 |
||
182 |
// Interval times use this timer to measure the interval that |
|
183 |
// the mutator runs. Reset after the GC pause has been measured. |
|
184 |
_major_timer.reset(); |
|
185 |
_major_timer.start(); |
|
186 |
} |
|
187 |
||
188 |
// If the remaining free space in the old generation is less that |
|
189 |
// that expected to be needed by the next collection, do a full |
|
190 |
// collection now. |
|
191 |
bool PSAdaptiveSizePolicy::should_full_GC(size_t old_free_in_bytes) { |
|
192 |
||
193 |
// A similar test is done in the scavenge's should_attempt_scavenge(). If |
|
194 |
// this is changed, decide if that test should also be changed. |
|
195 |
bool result = padded_average_promoted_in_bytes() > (float) old_free_in_bytes; |
|
35061 | 196 |
log_trace(gc, ergo)("%s after scavenge average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT, |
197 |
result ? "Full" : "No full", |
|
198 |
(size_t) average_promoted_in_bytes(), |
|
199 |
(size_t) padded_average_promoted_in_bytes(), |
|
200 |
old_free_in_bytes); |
|
1 | 201 |
return result; |
202 |
} |
|
203 |
||
204 |
void PSAdaptiveSizePolicy::clear_generation_free_space_flags() { |
|
205 |
||
206 |
AdaptiveSizePolicy::clear_generation_free_space_flags(); |
|
207 |
||
208 |
set_change_old_gen_for_min_pauses(0); |
|
209 |
||
210 |
set_change_young_gen_for_maj_pauses(0); |
|
211 |
} |
|
212 |
||
213 |
// If this is not a full GC, only test and modify the young generation. |
|
214 |
||
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
17393
diff
changeset
|
215 |
void PSAdaptiveSizePolicy::compute_generations_free_space( |
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
216 |
size_t young_live, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
217 |
size_t eden_live, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
218 |
size_t old_live, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
219 |
size_t cur_eden, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
220 |
size_t max_old_gen_size, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
221 |
size_t max_eden_size, |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
222 |
bool is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
223 |
compute_eden_space_size(young_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
224 |
eden_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
225 |
cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
226 |
max_eden_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
227 |
is_full_gc); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
228 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
229 |
compute_old_gen_free_space(old_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
230 |
cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
231 |
max_old_gen_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
232 |
is_full_gc); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
233 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
234 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
235 |
void PSAdaptiveSizePolicy::compute_eden_space_size( |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
236 |
size_t young_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
237 |
size_t eden_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
238 |
size_t cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
239 |
size_t max_eden_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
240 |
bool is_full_gc) { |
1 | 241 |
|
242 |
// Update statistics |
|
243 |
// Time statistics are updated as we go, update footprint stats here |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
244 |
_avg_base_footprint->sample(BaseFootPrintEstimate); |
1 | 245 |
avg_young_live()->sample(young_live); |
246 |
avg_eden_live()->sample(eden_live); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
247 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
248 |
// This code used to return if the policy was not ready , i.e., |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
249 |
// policy_is_ready() returning false. The intent was that |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
250 |
// decisions below needed major collection times and so could |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
251 |
// not be made before two major collections. A consequence was |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
252 |
// adjustments to the young generation were not done until after |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
253 |
// two major collections even if the minor collections times |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
254 |
// exceeded the requested goals. Now let the young generation |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
255 |
// adjust for the minor collection times. Major collection times |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
256 |
// will be zero for the first collection and will naturally be |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
257 |
// ignored. Tenured generation adjustments are only made at the |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
258 |
// full collections so until the second major collection has |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
259 |
// been reached, no tenured generation adjustments will be made. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
260 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
261 |
// Until we know better, desired promotion size uses the last calculation |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
262 |
size_t desired_promo_size = _promo_size; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
263 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
264 |
// Start eden at the current value. The desired value that is stored |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
265 |
// in _eden_size is not bounded by constraints of the heap and can |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
266 |
// run away. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
267 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
268 |
// As expected setting desired_eden_size to the current |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
269 |
// value of desired_eden_size as a starting point |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
270 |
// caused desired_eden_size to grow way too large and caused |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
271 |
// an overflow down stream. It may have improved performance in |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
272 |
// some case but is dangerous. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
273 |
size_t desired_eden_size = cur_eden; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
274 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
275 |
// Cache some values. There's a bit of work getting these, so |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
276 |
// we might save a little time. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
277 |
const double major_cost = major_gc_cost(); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
278 |
const double minor_cost = minor_gc_cost(); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
279 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
280 |
// This method sets the desired eden size. That plus the |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
281 |
// desired survivor space sizes sets the desired young generation |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
282 |
// size. This methods does not know what the desired survivor |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
283 |
// size is but expects that other policy will attempt to make |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
284 |
// the survivor sizes compatible with the live data in the |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
285 |
// young generation. This limit is an estimate of the space left |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
286 |
// in the young generation after the survivor spaces have been |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
287 |
// subtracted out. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
288 |
size_t eden_limit = max_eden_size; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
289 |
|
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
31634
diff
changeset
|
290 |
const double gc_cost_limit = GCTimeLimit / 100.0; |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
291 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
292 |
// Which way should we go? |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
293 |
// if pause requirement is not met |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
294 |
// adjust size of any generation with average paus exceeding |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
295 |
// the pause limit. Adjust one pause at a time (the larger) |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
296 |
// and only make adjustments for the major pause at full collections. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
297 |
// else if throughput requirement not met |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
298 |
// adjust the size of the generation with larger gc time. Only |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
299 |
// adjust one generation at a time. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
300 |
// else |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
301 |
// adjust down the total heap size. Adjust down the larger of the |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
302 |
// generations. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
303 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
304 |
// Add some checks for a threshold for a change. For example, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
305 |
// a change less than the necessary alignment is probably not worth |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
306 |
// attempting. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
307 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
308 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
309 |
if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) || |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
310 |
(_avg_major_pause->padded_average() > gc_pause_goal_sec())) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
311 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
312 |
// Check pauses |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
313 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
314 |
// Make changes only to affect one of the pauses (the larger) |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
315 |
// at a time. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
316 |
adjust_eden_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
317 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
318 |
} else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
319 |
// Adjust only for the minor pause time goal |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
320 |
adjust_eden_for_minor_pause_time(is_full_gc, &desired_eden_size); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
321 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
322 |
} else if(adjusted_mutator_cost() < _throughput_goal) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
323 |
// This branch used to require that (mutator_cost() > 0.0 in 1.4.2. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
324 |
// This sometimes resulted in skipping to the minimize footprint |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
325 |
// code. Change this to try and reduce GC time if mutator time is |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
326 |
// negative for whatever reason. Or for future consideration, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
327 |
// bail out of the code if mutator time is negative. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
328 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
329 |
// Throughput |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
330 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
331 |
assert(major_cost >= 0.0, "major cost is < 0.0"); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
332 |
assert(minor_cost >= 0.0, "minor cost is < 0.0"); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
333 |
// Try to reduce the GC times. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
334 |
adjust_eden_for_throughput(is_full_gc, &desired_eden_size); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
335 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
336 |
} else { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
337 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
338 |
// Be conservative about reducing the footprint. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
339 |
// Do a minimum number of major collections first. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
340 |
// Have reasonable averages for major and minor collections costs. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
341 |
if (UseAdaptiveSizePolicyFootprintGoal && |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
342 |
young_gen_policy_is_ready() && |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
343 |
avg_major_gc_cost()->average() >= 0.0 && |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
344 |
avg_minor_gc_cost()->average() >= 0.0) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
345 |
size_t desired_sum = desired_eden_size + desired_promo_size; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
346 |
desired_eden_size = adjust_eden_for_footprint(desired_eden_size, desired_sum); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
347 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
348 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
349 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
350 |
// Note we make the same tests as in the code block below; the code |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
351 |
// seems a little easier to read with the printing in another block. |
35061 | 352 |
if (desired_eden_size > eden_limit) { |
353 |
log_debug(gc, ergo)( |
|
354 |
"PSAdaptiveSizePolicy::compute_eden_space_size limits:" |
|
355 |
" desired_eden_size: " SIZE_FORMAT |
|
356 |
" old_eden_size: " SIZE_FORMAT |
|
357 |
" eden_limit: " SIZE_FORMAT |
|
358 |
" cur_eden: " SIZE_FORMAT |
|
359 |
" max_eden_size: " SIZE_FORMAT |
|
360 |
" avg_young_live: " SIZE_FORMAT, |
|
361 |
desired_eden_size, _eden_size, eden_limit, cur_eden, |
|
362 |
max_eden_size, (size_t)avg_young_live()->average()); |
|
363 |
} |
|
364 |
if (gc_cost() > gc_cost_limit) { |
|
365 |
log_debug(gc, ergo)( |
|
366 |
"PSAdaptiveSizePolicy::compute_eden_space_size: gc time limit" |
|
367 |
" gc_cost: %f " |
|
368 |
" GCTimeLimit: " UINTX_FORMAT, |
|
369 |
gc_cost(), GCTimeLimit); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
370 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
371 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
372 |
// Align everything and make a final limit check |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
373 |
desired_eden_size = align_up(desired_eden_size, _space_alignment); |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
374 |
desired_eden_size = MAX2(desired_eden_size, _space_alignment); |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
375 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
376 |
eden_limit = align_down(eden_limit, _space_alignment); |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
377 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
378 |
// And one last limit check, now that we've aligned things. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
379 |
if (desired_eden_size > eden_limit) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
380 |
// If the policy says to get a larger eden but |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
381 |
// is hitting the limit, don't decrease eden. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
382 |
// This can lead to a general drifting down of the |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
383 |
// eden size. Let the tenuring calculation push more |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
384 |
// into the old gen. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
385 |
desired_eden_size = MAX2(eden_limit, cur_eden); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
386 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
387 |
|
35061 | 388 |
log_debug(gc, ergo)("PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: %f major_cost: %f mutator_cost: %f throughput_goal: %f", |
389 |
minor_gc_cost(), major_gc_cost(), mutator_cost(), _throughput_goal); |
|
390 |
||
391 |
log_trace(gc, ergo)("Minor_pause: %f major_pause: %f minor_interval: %f major_interval: %fpause_goal: %f", |
|
392 |
_avg_minor_pause->padded_average(), |
|
393 |
_avg_major_pause->padded_average(), |
|
394 |
_avg_minor_interval->average(), |
|
395 |
_avg_major_interval->average(), |
|
396 |
gc_pause_goal_sec()); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
397 |
|
35061 | 398 |
log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT, |
399 |
live_space(), free_space()); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
400 |
|
35061 | 401 |
log_trace(gc, ergo)("Base_footprint: " SIZE_FORMAT " avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT, |
402 |
(size_t)_avg_base_footprint->average(), |
|
403 |
(size_t)avg_young_live()->average(), |
|
404 |
(size_t)avg_old_live()->average()); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
405 |
|
35061 | 406 |
log_debug(gc, ergo)("Old eden_size: " SIZE_FORMAT " desired_eden_size: " SIZE_FORMAT, |
407 |
_eden_size, desired_eden_size); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
408 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
409 |
set_eden_size(desired_eden_size); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
410 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
411 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
412 |
void PSAdaptiveSizePolicy::compute_old_gen_free_space( |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
413 |
size_t old_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
414 |
size_t cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
415 |
size_t max_old_gen_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
416 |
bool is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
417 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
418 |
// Update statistics |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
419 |
// Time statistics are updated as we go, update footprint stats here |
1 | 420 |
if (is_full_gc) { |
421 |
// old_live is only accurate after a full gc |
|
422 |
avg_old_live()->sample(old_live); |
|
423 |
} |
|
424 |
||
425 |
// This code used to return if the policy was not ready , i.e., |
|
426 |
// policy_is_ready() returning false. The intent was that |
|
427 |
// decisions below needed major collection times and so could |
|
428 |
// not be made before two major collections. A consequence was |
|
429 |
// adjustments to the young generation were not done until after |
|
430 |
// two major collections even if the minor collections times |
|
431 |
// exceeded the requested goals. Now let the young generation |
|
432 |
// adjust for the minor collection times. Major collection times |
|
433 |
// will be zero for the first collection and will naturally be |
|
434 |
// ignored. Tenured generation adjustments are only made at the |
|
435 |
// full collections so until the second major collection has |
|
436 |
// been reached, no tenured generation adjustments will be made. |
|
437 |
||
438 |
// Until we know better, desired promotion size uses the last calculation |
|
439 |
size_t desired_promo_size = _promo_size; |
|
440 |
||
441 |
// Start eden at the current value. The desired value that is stored |
|
442 |
// in _eden_size is not bounded by constraints of the heap and can |
|
443 |
// run away. |
|
444 |
// |
|
445 |
// As expected setting desired_eden_size to the current |
|
446 |
// value of desired_eden_size as a starting point |
|
447 |
// caused desired_eden_size to grow way too large and caused |
|
448 |
// an overflow down stream. It may have improved performance in |
|
449 |
// some case but is dangerous. |
|
450 |
size_t desired_eden_size = cur_eden; |
|
451 |
||
452 |
// Cache some values. There's a bit of work getting these, so |
|
453 |
// we might save a little time. |
|
454 |
const double major_cost = major_gc_cost(); |
|
455 |
const double minor_cost = minor_gc_cost(); |
|
456 |
||
457 |
// Limits on our growth |
|
458 |
size_t promo_limit = (size_t)(max_old_gen_size - avg_old_live()->average()); |
|
459 |
||
460 |
// But don't force a promo size below the current promo size. Otherwise, |
|
461 |
// the promo size will shrink for no good reason. |
|
462 |
promo_limit = MAX2(promo_limit, _promo_size); |
|
463 |
||
464 |
const double gc_cost_limit = GCTimeLimit/100.0; |
|
465 |
||
466 |
// Which way should we go? |
|
467 |
// if pause requirement is not met |
|
468 |
// adjust size of any generation with average paus exceeding |
|
469 |
// the pause limit. Adjust one pause at a time (the larger) |
|
470 |
// and only make adjustments for the major pause at full collections. |
|
471 |
// else if throughput requirement not met |
|
472 |
// adjust the size of the generation with larger gc time. Only |
|
473 |
// adjust one generation at a time. |
|
474 |
// else |
|
475 |
// adjust down the total heap size. Adjust down the larger of the |
|
476 |
// generations. |
|
477 |
||
22551 | 478 |
// Add some checks for a threshold for a change. For example, |
1 | 479 |
// a change less than the necessary alignment is probably not worth |
480 |
// attempting. |
|
481 |
||
482 |
if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) || |
|
483 |
(_avg_major_pause->padded_average() > gc_pause_goal_sec())) { |
|
484 |
// |
|
485 |
// Check pauses |
|
486 |
// |
|
487 |
// Make changes only to affect one of the pauses (the larger) |
|
488 |
// at a time. |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
489 |
if (is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
490 |
set_decide_at_full_gc(decide_at_full_gc_true); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
491 |
adjust_promo_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
492 |
} |
33227
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
32623
diff
changeset
|
493 |
} else if (adjusted_mutator_cost() < _throughput_goal) { |
1 | 494 |
// This branch used to require that (mutator_cost() > 0.0 in 1.4.2. |
495 |
// This sometimes resulted in skipping to the minimize footprint |
|
496 |
// code. Change this to try and reduce GC time if mutator time is |
|
497 |
// negative for whatever reason. Or for future consideration, |
|
498 |
// bail out of the code if mutator time is negative. |
|
499 |
// |
|
500 |
// Throughput |
|
501 |
// |
|
502 |
assert(major_cost >= 0.0, "major cost is < 0.0"); |
|
503 |
assert(minor_cost >= 0.0, "minor cost is < 0.0"); |
|
504 |
// Try to reduce the GC times. |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
505 |
if (is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
506 |
set_decide_at_full_gc(decide_at_full_gc_true); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
507 |
adjust_promo_for_throughput(is_full_gc, &desired_promo_size); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
508 |
} |
1 | 509 |
} else { |
510 |
||
511 |
// Be conservative about reducing the footprint. |
|
512 |
// Do a minimum number of major collections first. |
|
513 |
// Have reasonable averages for major and minor collections costs. |
|
514 |
if (UseAdaptiveSizePolicyFootprintGoal && |
|
515 |
young_gen_policy_is_ready() && |
|
516 |
avg_major_gc_cost()->average() >= 0.0 && |
|
517 |
avg_minor_gc_cost()->average() >= 0.0) { |
|
518 |
if (is_full_gc) { |
|
519 |
set_decide_at_full_gc(decide_at_full_gc_true); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
520 |
size_t desired_sum = desired_eden_size + desired_promo_size; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
521 |
desired_promo_size = adjust_promo_for_footprint(desired_promo_size, desired_sum); |
1 | 522 |
} |
523 |
} |
|
524 |
} |
|
525 |
||
526 |
// Note we make the same tests as in the code block below; the code |
|
527 |
// seems a little easier to read with the printing in another block. |
|
35061 | 528 |
if (desired_promo_size > promo_limit) { |
529 |
// "free_in_old_gen" was the original value for used for promo_limit |
|
530 |
size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average()); |
|
531 |
log_debug(gc, ergo)( |
|
532 |
"PSAdaptiveSizePolicy::compute_old_gen_free_space limits:" |
|
533 |
" desired_promo_size: " SIZE_FORMAT |
|
534 |
" promo_limit: " SIZE_FORMAT |
|
535 |
" free_in_old_gen: " SIZE_FORMAT |
|
536 |
" max_old_gen_size: " SIZE_FORMAT |
|
537 |
" avg_old_live: " SIZE_FORMAT, |
|
538 |
desired_promo_size, promo_limit, free_in_old_gen, |
|
539 |
max_old_gen_size, (size_t) avg_old_live()->average()); |
|
540 |
} |
|
541 |
if (gc_cost() > gc_cost_limit) { |
|
542 |
log_debug(gc, ergo)( |
|
543 |
"PSAdaptiveSizePolicy::compute_old_gen_free_space: gc time limit" |
|
544 |
" gc_cost: %f " |
|
545 |
" GCTimeLimit: " UINTX_FORMAT, |
|
546 |
gc_cost(), GCTimeLimit); |
|
1 | 547 |
} |
548 |
||
549 |
// Align everything and make a final limit check |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
550 |
desired_promo_size = align_up(desired_promo_size, _space_alignment); |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
551 |
desired_promo_size = MAX2(desired_promo_size, _space_alignment); |
1 | 552 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
553 |
promo_limit = align_down(promo_limit, _space_alignment); |
1 | 554 |
|
555 |
// And one last limit check, now that we've aligned things. |
|
556 |
desired_promo_size = MIN2(desired_promo_size, promo_limit); |
|
557 |
||
35061 | 558 |
// Timing stats |
559 |
log_debug(gc, ergo)("PSAdaptiveSizePolicy::compute_old_gen_free_space: costs minor_time: %f major_cost: %f mutator_cost: %f throughput_goal: %f", |
|
560 |
minor_gc_cost(), major_gc_cost(), mutator_cost(), _throughput_goal); |
|
561 |
||
562 |
log_trace(gc, ergo)("Minor_pause: %f major_pause: %f minor_interval: %f major_interval: %f pause_goal: %f", |
|
563 |
_avg_minor_pause->padded_average(), |
|
564 |
_avg_major_pause->padded_average(), |
|
565 |
_avg_minor_interval->average(), |
|
566 |
_avg_major_interval->average(), |
|
567 |
gc_pause_goal_sec()); |
|
1 | 568 |
|
35061 | 569 |
// Footprint stats |
570 |
log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT, |
|
571 |
live_space(), free_space()); |
|
1 | 572 |
|
35061 | 573 |
log_trace(gc, ergo)("Base_footprint: " SIZE_FORMAT " avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT, |
574 |
(size_t)_avg_base_footprint->average(), |
|
575 |
(size_t)avg_young_live()->average(), |
|
576 |
(size_t)avg_old_live()->average()); |
|
1 | 577 |
|
35061 | 578 |
log_debug(gc, ergo)("Old promo_size: " SIZE_FORMAT " desired_promo_size: " SIZE_FORMAT, |
579 |
_promo_size, desired_promo_size); |
|
1 | 580 |
|
581 |
set_promo_size(desired_promo_size); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
582 |
} |
1 | 583 |
|
584 |
void PSAdaptiveSizePolicy::decay_supplemental_growth(bool is_full_gc) { |
|
585 |
// Decay the supplemental increment? Decay the supplement growth |
|
586 |
// factor even if it is not used. It is only meant to give a boost |
|
587 |
// to the initial growth and if it is not used, then it was not |
|
588 |
// needed. |
|
589 |
if (is_full_gc) { |
|
590 |
// Don't wait for the threshold value for the major collections. If |
|
591 |
// here, the supplemental growth term was used and should decay. |
|
592 |
if ((_avg_major_pause->count() % TenuredGenerationSizeSupplementDecay) |
|
593 |
== 0) { |
|
594 |
_old_gen_size_increment_supplement = |
|
595 |
_old_gen_size_increment_supplement >> 1; |
|
596 |
} |
|
597 |
} else { |
|
598 |
if ((_avg_minor_pause->count() >= AdaptiveSizePolicyReadyThreshold) && |
|
599 |
(_avg_minor_pause->count() % YoungGenerationSizeSupplementDecay) == 0) { |
|
600 |
_young_gen_size_increment_supplement = |
|
601 |
_young_gen_size_increment_supplement >> 1; |
|
602 |
} |
|
603 |
} |
|
604 |
} |
|
605 |
||
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
606 |
void PSAdaptiveSizePolicy::adjust_eden_for_minor_pause_time(bool is_full_gc, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
607 |
size_t* desired_eden_size_ptr) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
608 |
|
1 | 609 |
// Adjust the young generation size to reduce pause time of |
610 |
// of collections. |
|
611 |
// |
|
612 |
// The AdaptiveSizePolicyInitializingSteps test is not used |
|
613 |
// here. It has not seemed to be needed but perhaps should |
|
614 |
// be added for consistency. |
|
615 |
if (minor_pause_young_estimator()->decrement_will_decrease()) { |
|
616 |
// reduce eden size |
|
617 |
set_change_young_gen_for_min_pauses( |
|
618 |
decrease_young_gen_for_min_pauses_true); |
|
619 |
*desired_eden_size_ptr = *desired_eden_size_ptr - |
|
620 |
eden_decrement_aligned_down(*desired_eden_size_ptr); |
|
621 |
} else { |
|
622 |
// EXPERIMENTAL ADJUSTMENT |
|
623 |
// Only record that the estimator indicated such an action. |
|
624 |
// *desired_eden_size_ptr = *desired_eden_size_ptr + eden_heap_delta; |
|
625 |
set_change_young_gen_for_min_pauses( |
|
626 |
increase_young_gen_for_min_pauses_true); |
|
627 |
} |
|
628 |
} |
|
629 |
||
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
630 |
void PSAdaptiveSizePolicy::adjust_promo_for_pause_time(bool is_full_gc, |
1 | 631 |
size_t* desired_promo_size_ptr, |
632 |
size_t* desired_eden_size_ptr) { |
|
633 |
||
634 |
size_t promo_heap_delta = 0; |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
635 |
// Add some checks for a threshold for a change. For example, |
1 | 636 |
// a change less than the required alignment is probably not worth |
637 |
// attempting. |
|
638 |
||
33227
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
32623
diff
changeset
|
639 |
if (_avg_minor_pause->padded_average() <= _avg_major_pause->padded_average() && is_full_gc) { |
1 | 640 |
// Adjust for the major pause time only at full gc's because the |
641 |
// affects of a change can only be seen at full gc's. |
|
642 |
||
643 |
// Reduce old generation size to reduce pause? |
|
644 |
if (major_pause_old_estimator()->decrement_will_decrease()) { |
|
645 |
// reduce old generation size |
|
646 |
set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true); |
|
647 |
promo_heap_delta = promo_decrement_aligned_down(*desired_promo_size_ptr); |
|
648 |
*desired_promo_size_ptr = _promo_size - promo_heap_delta; |
|
649 |
} else { |
|
650 |
// EXPERIMENTAL ADJUSTMENT |
|
651 |
// Only record that the estimator indicated such an action. |
|
652 |
// *desired_promo_size_ptr = _promo_size + |
|
653 |
// promo_increment_aligned_up(*desired_promo_size_ptr); |
|
654 |
set_change_old_gen_for_maj_pauses(increase_old_gen_for_maj_pauses_true); |
|
655 |
} |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
656 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
657 |
|
35061 | 658 |
log_trace(gc, ergo)( |
659 |
"PSAdaptiveSizePolicy::adjust_promo_for_pause_time " |
|
660 |
"adjusting gen sizes for major pause (avg %f goal %f). " |
|
661 |
"desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT, |
|
662 |
_avg_major_pause->average(), gc_pause_goal_sec(), |
|
663 |
*desired_promo_size_ptr, promo_heap_delta); |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
664 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
665 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
666 |
void PSAdaptiveSizePolicy::adjust_eden_for_pause_time(bool is_full_gc, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
667 |
size_t* desired_promo_size_ptr, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
668 |
size_t* desired_eden_size_ptr) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
669 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
670 |
size_t eden_heap_delta = 0; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
671 |
// Add some checks for a threshold for a change. For example, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
672 |
// a change less than the required alignment is probably not worth |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
673 |
// attempting. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
674 |
if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) { |
33227
b00ec45f8c2c
8139277: Remove ScavengeWithObjectsInToSpace, ParallelOldGCSplitALot, ParallelOldGCSplitInterval, PSAdjustTenuredGenForMinorPause and PSAdjustYoungGenForMajorPause
david
parents:
32623
diff
changeset
|
675 |
adjust_eden_for_minor_pause_time(is_full_gc, desired_eden_size_ptr); |
1 | 676 |
} |
35061 | 677 |
log_trace(gc, ergo)( |
678 |
"PSAdaptiveSizePolicy::adjust_eden_for_pause_time " |
|
679 |
"adjusting gen sizes for major pause (avg %f goal %f). " |
|
680 |
"desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, |
|
681 |
_avg_major_pause->average(), gc_pause_goal_sec(), |
|
682 |
*desired_eden_size_ptr, eden_heap_delta); |
|
1 | 683 |
} |
684 |
||
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
685 |
void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
686 |
size_t* desired_promo_size_ptr) { |
1 | 687 |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
688 |
// Add some checks for a threshold for a change. For example, |
1 | 689 |
// a change less than the required alignment is probably not worth |
690 |
// attempting. |
|
691 |
||
692 |
if ((gc_cost() + mutator_cost()) == 0.0) { |
|
693 |
return; |
|
694 |
} |
|
695 |
||
35061 | 696 |
log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_promo_for_throughput(is_full: %d, promo: " SIZE_FORMAT "): mutator_cost %f major_gc_cost %f minor_gc_cost %f", |
697 |
is_full_gc, *desired_promo_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost()); |
|
1 | 698 |
|
699 |
// Tenured generation |
|
700 |
if (is_full_gc) { |
|
701 |
// Calculate the change to use for the tenured gen. |
|
702 |
size_t scaled_promo_heap_delta = 0; |
|
703 |
// Can the increment to the generation be scaled? |
|
704 |
if (gc_cost() >= 0.0 && major_gc_cost() >= 0.0) { |
|
705 |
size_t promo_heap_delta = |
|
706 |
promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); |
|
707 |
double scale_by_ratio = major_gc_cost() / gc_cost(); |
|
708 |
scaled_promo_heap_delta = |
|
709 |
(size_t) (scale_by_ratio * (double) promo_heap_delta); |
|
35061 | 710 |
log_trace(gc, ergo)("Scaled tenured increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT, |
711 |
promo_heap_delta, scale_by_ratio, scaled_promo_heap_delta); |
|
1 | 712 |
} else if (major_gc_cost() >= 0.0) { |
713 |
// Scaling is not going to work. If the major gc time is the |
|
714 |
// larger, give it a full increment. |
|
715 |
if (major_gc_cost() >= minor_gc_cost()) { |
|
716 |
scaled_promo_heap_delta = |
|
717 |
promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); |
|
718 |
} |
|
719 |
} else { |
|
720 |
// Don't expect to get here but it's ok if it does |
|
721 |
// in the product build since the delta will be 0 |
|
722 |
// and nothing will change. |
|
723 |
assert(false, "Unexpected value for gc costs"); |
|
724 |
} |
|
725 |
||
726 |
switch (AdaptiveSizeThroughPutPolicy) { |
|
727 |
case 1: |
|
728 |
// Early in the run the statistics might not be good. Until |
|
729 |
// a specific number of collections have been, use the heuristic |
|
730 |
// that a larger generation size means lower collection costs. |
|
731 |
if (major_collection_estimator()->increment_will_decrease() || |
|
732 |
(_old_gen_change_for_major_throughput |
|
733 |
<= AdaptiveSizePolicyInitializingSteps)) { |
|
734 |
// Increase tenured generation size to reduce major collection cost |
|
735 |
if ((*desired_promo_size_ptr + scaled_promo_heap_delta) > |
|
736 |
*desired_promo_size_ptr) { |
|
737 |
*desired_promo_size_ptr = _promo_size + scaled_promo_heap_delta; |
|
738 |
} |
|
739 |
set_change_old_gen_for_throughput( |
|
740 |
increase_old_gen_for_throughput_true); |
|
741 |
_old_gen_change_for_major_throughput++; |
|
742 |
} else { |
|
743 |
// EXPERIMENTAL ADJUSTMENT |
|
744 |
// Record that decreasing the old gen size would decrease |
|
745 |
// the major collection cost but don't do it. |
|
746 |
// *desired_promo_size_ptr = _promo_size - |
|
747 |
// promo_decrement_aligned_down(*desired_promo_size_ptr); |
|
748 |
set_change_old_gen_for_throughput( |
|
749 |
decrease_old_gen_for_throughput_true); |
|
750 |
} |
|
751 |
||
752 |
break; |
|
753 |
default: |
|
754 |
// Simplest strategy |
|
755 |
if ((*desired_promo_size_ptr + scaled_promo_heap_delta) > |
|
756 |
*desired_promo_size_ptr) { |
|
757 |
*desired_promo_size_ptr = *desired_promo_size_ptr + |
|
758 |
scaled_promo_heap_delta; |
|
759 |
} |
|
760 |
set_change_old_gen_for_throughput( |
|
761 |
increase_old_gen_for_throughput_true); |
|
762 |
_old_gen_change_for_major_throughput++; |
|
763 |
} |
|
764 |
||
35061 | 765 |
log_trace(gc, ergo)("Adjusting tenured gen for throughput (avg %f goal %f). desired_promo_size " SIZE_FORMAT " promo_delta " SIZE_FORMAT , |
766 |
mutator_cost(), |
|
767 |
_throughput_goal, |
|
768 |
*desired_promo_size_ptr, scaled_promo_heap_delta); |
|
1 | 769 |
} |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
770 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
771 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
772 |
void PSAdaptiveSizePolicy::adjust_eden_for_throughput(bool is_full_gc, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
773 |
size_t* desired_eden_size_ptr) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
774 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
775 |
// Add some checks for a threshold for a change. For example, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
776 |
// a change less than the required alignment is probably not worth |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
777 |
// attempting. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
778 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
779 |
if ((gc_cost() + mutator_cost()) == 0.0) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
780 |
return; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
781 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
782 |
|
35061 | 783 |
log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_eden_for_throughput(is_full: %d, cur_eden: " SIZE_FORMAT "): mutator_cost %f major_gc_cost %f minor_gc_cost %f", |
784 |
is_full_gc, *desired_eden_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost()); |
|
1 | 785 |
|
786 |
// Young generation |
|
787 |
size_t scaled_eden_heap_delta = 0; |
|
788 |
// Can the increment to the generation be scaled? |
|
789 |
if (gc_cost() >= 0.0 && minor_gc_cost() >= 0.0) { |
|
790 |
size_t eden_heap_delta = |
|
791 |
eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr); |
|
792 |
double scale_by_ratio = minor_gc_cost() / gc_cost(); |
|
793 |
assert(scale_by_ratio <= 1.0 && scale_by_ratio >= 0.0, "Scaling is wrong"); |
|
794 |
scaled_eden_heap_delta = |
|
795 |
(size_t) (scale_by_ratio * (double) eden_heap_delta); |
|
35061 | 796 |
log_trace(gc, ergo)("Scaled eden increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT, |
797 |
eden_heap_delta, scale_by_ratio, scaled_eden_heap_delta); |
|
1 | 798 |
} else if (minor_gc_cost() >= 0.0) { |
799 |
// Scaling is not going to work. If the minor gc time is the |
|
800 |
// larger, give it a full increment. |
|
801 |
if (minor_gc_cost() > major_gc_cost()) { |
|
802 |
scaled_eden_heap_delta = |
|
803 |
eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr); |
|
804 |
} |
|
805 |
} else { |
|
806 |
// Don't expect to get here but it's ok if it does |
|
807 |
// in the product build since the delta will be 0 |
|
808 |
// and nothing will change. |
|
809 |
assert(false, "Unexpected value for gc costs"); |
|
810 |
} |
|
811 |
||
812 |
// Use a heuristic for some number of collections to give |
|
813 |
// the averages time to settle down. |
|
814 |
switch (AdaptiveSizeThroughPutPolicy) { |
|
815 |
case 1: |
|
816 |
if (minor_collection_estimator()->increment_will_decrease() || |
|
817 |
(_young_gen_change_for_minor_throughput |
|
818 |
<= AdaptiveSizePolicyInitializingSteps)) { |
|
819 |
// Expand young generation size to reduce frequency of |
|
820 |
// of collections. |
|
821 |
if ((*desired_eden_size_ptr + scaled_eden_heap_delta) > |
|
822 |
*desired_eden_size_ptr) { |
|
823 |
*desired_eden_size_ptr = |
|
824 |
*desired_eden_size_ptr + scaled_eden_heap_delta; |
|
825 |
} |
|
826 |
set_change_young_gen_for_throughput( |
|
827 |
increase_young_gen_for_througput_true); |
|
828 |
_young_gen_change_for_minor_throughput++; |
|
829 |
} else { |
|
830 |
// EXPERIMENTAL ADJUSTMENT |
|
831 |
// Record that decreasing the young gen size would decrease |
|
832 |
// the minor collection cost but don't do it. |
|
833 |
// *desired_eden_size_ptr = _eden_size - |
|
834 |
// eden_decrement_aligned_down(*desired_eden_size_ptr); |
|
835 |
set_change_young_gen_for_throughput( |
|
836 |
decrease_young_gen_for_througput_true); |
|
837 |
} |
|
838 |
break; |
|
839 |
default: |
|
840 |
if ((*desired_eden_size_ptr + scaled_eden_heap_delta) > |
|
841 |
*desired_eden_size_ptr) { |
|
842 |
*desired_eden_size_ptr = |
|
843 |
*desired_eden_size_ptr + scaled_eden_heap_delta; |
|
844 |
} |
|
845 |
set_change_young_gen_for_throughput( |
|
846 |
increase_young_gen_for_througput_true); |
|
847 |
_young_gen_change_for_minor_throughput++; |
|
848 |
} |
|
849 |
||
35061 | 850 |
log_trace(gc, ergo)("Adjusting eden for throughput (avg %f goal %f). desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, |
851 |
mutator_cost(), _throughput_goal, *desired_eden_size_ptr, scaled_eden_heap_delta); |
|
1 | 852 |
} |
853 |
||
854 |
size_t PSAdaptiveSizePolicy::adjust_promo_for_footprint( |
|
855 |
size_t desired_promo_size, size_t desired_sum) { |
|
856 |
assert(desired_promo_size <= desired_sum, "Inconsistent parameters"); |
|
857 |
set_decrease_for_footprint(decrease_old_gen_for_footprint_true); |
|
858 |
||
859 |
size_t change = promo_decrement(desired_promo_size); |
|
860 |
change = scale_down(change, desired_promo_size, desired_sum); |
|
861 |
||
862 |
size_t reduced_size = desired_promo_size - change; |
|
863 |
||
35061 | 864 |
log_trace(gc, ergo)( |
865 |
"AdaptiveSizePolicy::adjust_promo_for_footprint " |
|
866 |
"adjusting tenured gen for footprint. " |
|
867 |
"starting promo size " SIZE_FORMAT |
|
868 |
" reduced promo size " SIZE_FORMAT |
|
869 |
" promo delta " SIZE_FORMAT, |
|
870 |
desired_promo_size, reduced_size, change ); |
|
1 | 871 |
|
872 |
assert(reduced_size <= desired_promo_size, "Inconsistent result"); |
|
873 |
return reduced_size; |
|
874 |
} |
|
875 |
||
876 |
size_t PSAdaptiveSizePolicy::adjust_eden_for_footprint( |
|
877 |
size_t desired_eden_size, size_t desired_sum) { |
|
878 |
assert(desired_eden_size <= desired_sum, "Inconsistent parameters"); |
|
879 |
set_decrease_for_footprint(decrease_young_gen_for_footprint_true); |
|
880 |
||
881 |
size_t change = eden_decrement(desired_eden_size); |
|
882 |
change = scale_down(change, desired_eden_size, desired_sum); |
|
883 |
||
884 |
size_t reduced_size = desired_eden_size - change; |
|
885 |
||
35061 | 886 |
log_trace(gc, ergo)( |
887 |
"AdaptiveSizePolicy::adjust_eden_for_footprint " |
|
888 |
"adjusting eden for footprint. " |
|
889 |
" starting eden size " SIZE_FORMAT |
|
890 |
" reduced eden size " SIZE_FORMAT |
|
891 |
" eden delta " SIZE_FORMAT, |
|
892 |
desired_eden_size, reduced_size, change); |
|
1 | 893 |
|
894 |
assert(reduced_size <= desired_eden_size, "Inconsistent result"); |
|
895 |
return reduced_size; |
|
896 |
} |
|
897 |
||
898 |
// Scale down "change" by the factor |
|
899 |
// part / total |
|
900 |
// Don't align the results. |
|
901 |
||
902 |
size_t PSAdaptiveSizePolicy::scale_down(size_t change, |
|
903 |
double part, |
|
904 |
double total) { |
|
905 |
assert(part <= total, "Inconsistent input"); |
|
906 |
size_t reduced_change = change; |
|
907 |
if (total > 0) { |
|
908 |
double fraction = part / total; |
|
909 |
reduced_change = (size_t) (fraction * (double) change); |
|
910 |
} |
|
911 |
assert(reduced_change <= change, "Inconsistent result"); |
|
912 |
return reduced_change; |
|
913 |
} |
|
914 |
||
915 |
size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden, |
|
916 |
uint percent_change) { |
|
917 |
size_t eden_heap_delta; |
|
918 |
eden_heap_delta = cur_eden / 100 * percent_change; |
|
919 |
return eden_heap_delta; |
|
920 |
} |
|
921 |
||
922 |
size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden) { |
|
923 |
return eden_increment(cur_eden, YoungGenerationSizeIncrement); |
|
924 |
} |
|
925 |
||
926 |
size_t PSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) { |
|
927 |
size_t result = eden_increment(cur_eden, YoungGenerationSizeIncrement); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
928 |
return align_up(result, _space_alignment); |
1 | 929 |
} |
930 |
||
931 |
size_t PSAdaptiveSizePolicy::eden_increment_aligned_down(size_t cur_eden) { |
|
932 |
size_t result = eden_increment(cur_eden); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
933 |
return align_down(result, _space_alignment); |
1 | 934 |
} |
935 |
||
936 |
size_t PSAdaptiveSizePolicy::eden_increment_with_supplement_aligned_up( |
|
937 |
size_t cur_eden) { |
|
938 |
size_t result = eden_increment(cur_eden, |
|
939 |
YoungGenerationSizeIncrement + _young_gen_size_increment_supplement); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
940 |
return align_up(result, _space_alignment); |
1 | 941 |
} |
942 |
||
943 |
size_t PSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) { |
|
944 |
size_t eden_heap_delta = eden_decrement(cur_eden); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
945 |
return align_down(eden_heap_delta, _space_alignment); |
1 | 946 |
} |
947 |
||
948 |
size_t PSAdaptiveSizePolicy::eden_decrement(size_t cur_eden) { |
|
949 |
size_t eden_heap_delta = eden_increment(cur_eden) / |
|
950 |
AdaptiveSizeDecrementScaleFactor; |
|
951 |
return eden_heap_delta; |
|
952 |
} |
|
953 |
||
954 |
size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo, |
|
955 |
uint percent_change) { |
|
956 |
size_t promo_heap_delta; |
|
957 |
promo_heap_delta = cur_promo / 100 * percent_change; |
|
958 |
return promo_heap_delta; |
|
959 |
} |
|
960 |
||
961 |
size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo) { |
|
962 |
return promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
|
963 |
} |
|
964 |
||
965 |
size_t PSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { |
|
966 |
size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
967 |
return align_up(result, _space_alignment); |
1 | 968 |
} |
969 |
||
970 |
size_t PSAdaptiveSizePolicy::promo_increment_aligned_down(size_t cur_promo) { |
|
971 |
size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
972 |
return align_down(result, _space_alignment); |
1 | 973 |
} |
974 |
||
975 |
size_t PSAdaptiveSizePolicy::promo_increment_with_supplement_aligned_up( |
|
976 |
size_t cur_promo) { |
|
977 |
size_t result = promo_increment(cur_promo, |
|
978 |
TenuredGenerationSizeIncrement + _old_gen_size_increment_supplement); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
979 |
return align_up(result, _space_alignment); |
1 | 980 |
} |
981 |
||
982 |
size_t PSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) { |
|
983 |
size_t promo_heap_delta = promo_decrement(cur_promo); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
984 |
return align_down(promo_heap_delta, _space_alignment); |
1 | 985 |
} |
986 |
||
987 |
size_t PSAdaptiveSizePolicy::promo_decrement(size_t cur_promo) { |
|
988 |
size_t promo_heap_delta = promo_increment(cur_promo); |
|
989 |
promo_heap_delta = promo_heap_delta / AdaptiveSizeDecrementScaleFactor; |
|
990 |
return promo_heap_delta; |
|
991 |
} |
|
992 |
||
13925 | 993 |
uint PSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( |
1 | 994 |
bool is_survivor_overflow, |
13925 | 995 |
uint tenuring_threshold, |
1 | 996 |
size_t survivor_limit) { |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
997 |
assert(survivor_limit >= _space_alignment, |
1 | 998 |
"survivor_limit too small"); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
999 |
assert(is_aligned(survivor_limit, _space_alignment), |
46618
d503911aa948
8178489: Make align functions more type safe and consistent
stefank
parents:
40903
diff
changeset
|
1000 |
"survivor_limit not aligned"); |
1 | 1001 |
|
1002 |
// This method is called even if the tenuring threshold and survivor |
|
1003 |
// spaces are not adjusted so that the averages are sampled above. |
|
1004 |
if (!UsePSAdaptiveSurvivorSizePolicy || |
|
1005 |
!young_gen_policy_is_ready()) { |
|
1006 |
return tenuring_threshold; |
|
1007 |
} |
|
1008 |
||
1009 |
// We'll decide whether to increase or decrease the tenuring |
|
1010 |
// threshold based partly on the newly computed survivor size |
|
1011 |
// (if we hit the maximum limit allowed, we'll always choose to |
|
1012 |
// decrement the threshold). |
|
1013 |
bool incr_tenuring_threshold = false; |
|
1014 |
bool decr_tenuring_threshold = false; |
|
1015 |
||
1016 |
set_decrement_tenuring_threshold_for_gc_cost(false); |
|
1017 |
set_increment_tenuring_threshold_for_gc_cost(false); |
|
1018 |
set_decrement_tenuring_threshold_for_survivor_limit(false); |
|
1019 |
||
1020 |
if (!is_survivor_overflow) { |
|
1021 |
// Keep running averages on how much survived |
|
1022 |
||
1023 |
// We use the tenuring threshold to equalize the cost of major |
|
1024 |
// and minor collections. |
|
1025 |
// ThresholdTolerance is used to indicate how sensitive the |
|
22551 | 1026 |
// tenuring threshold is to differences in cost between the |
1 | 1027 |
// collection types. |
1028 |
||
1029 |
// Get the times of interest. This involves a little work, so |
|
1030 |
// we cache the values here. |
|
1031 |
const double major_cost = major_gc_cost(); |
|
1032 |
const double minor_cost = minor_gc_cost(); |
|
1033 |
||
1034 |
if (minor_cost > major_cost * _threshold_tolerance_percent) { |
|
1035 |
// Minor times are getting too long; lower the threshold so |
|
1036 |
// less survives and more is promoted. |
|
1037 |
decr_tenuring_threshold = true; |
|
1038 |
set_decrement_tenuring_threshold_for_gc_cost(true); |
|
1039 |
} else if (major_cost > minor_cost * _threshold_tolerance_percent) { |
|
1040 |
// Major times are too long, so we want less promotion. |
|
1041 |
incr_tenuring_threshold = true; |
|
1042 |
set_increment_tenuring_threshold_for_gc_cost(true); |
|
1043 |
} |
|
1044 |
||
1045 |
} else { |
|
1046 |
// Survivor space overflow occurred, so promoted and survived are |
|
1047 |
// not accurate. We'll make our best guess by combining survived |
|
1048 |
// and promoted and count them as survivors. |
|
1049 |
// |
|
1050 |
// We'll lower the tenuring threshold to see if we can correct |
|
1051 |
// things. Also, set the survivor size conservatively. We're |
|
1052 |
// trying to avoid many overflows from occurring if defnew size |
|
1053 |
// is just too small. |
|
1054 |
||
1055 |
decr_tenuring_threshold = true; |
|
1056 |
} |
|
1057 |
||
1058 |
// The padded average also maintains a deviation from the average; |
|
1059 |
// we use this to see how good of an estimate we have of what survived. |
|
1060 |
// We're trying to pad the survivor size as little as possible without |
|
1061 |
// overflowing the survivor spaces. |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1062 |
size_t target_size = align_up((size_t)_avg_survived->padded_average(), |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1063 |
_space_alignment); |
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1064 |
target_size = MAX2(target_size, _space_alignment); |
1 | 1065 |
|
1066 |
if (target_size > survivor_limit) { |
|
1067 |
// Target size is bigger than we can handle. Let's also reduce |
|
1068 |
// the tenuring threshold. |
|
1069 |
target_size = survivor_limit; |
|
1070 |
decr_tenuring_threshold = true; |
|
1071 |
set_decrement_tenuring_threshold_for_survivor_limit(true); |
|
1072 |
} |
|
1073 |
||
1074 |
// Finally, increment or decrement the tenuring threshold, as decided above. |
|
1075 |
// We test for decrementing first, as we might have hit the target size |
|
1076 |
// limit. |
|
1077 |
if (decr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { |
|
1078 |
if (tenuring_threshold > 1) { |
|
1079 |
tenuring_threshold--; |
|
1080 |
} |
|
1081 |
} else if (incr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { |
|
1082 |
if (tenuring_threshold < MaxTenuringThreshold) { |
|
1083 |
tenuring_threshold++; |
|
1084 |
} |
|
1085 |
} |
|
1086 |
||
1087 |
// We keep a running average of the amount promoted which is used |
|
1088 |
// to decide when we should collect the old generation (when |
|
1089 |
// the amount of old gen free space is less than what we expect to |
|
1090 |
// promote). |
|
1091 |
||
35061 | 1092 |
log_trace(gc, ergo)("avg_survived: %f avg_deviation: %f", _avg_survived->average(), _avg_survived->deviation()); |
1093 |
log_debug(gc, ergo)("avg_survived_padded_avg: %f", _avg_survived->padded_average()); |
|
1 | 1094 |
|
35061 | 1095 |
log_trace(gc, ergo)("avg_promoted_avg: %f avg_promoted_dev: %f", avg_promoted()->average(), avg_promoted()->deviation()); |
1096 |
log_debug(gc, ergo)("avg_promoted_padded_avg: %f avg_pretenured_padded_avg: %f tenuring_thresh: %d target_size: " SIZE_FORMAT, |
|
1097 |
avg_promoted()->padded_average(), |
|
1098 |
_avg_pretenured->padded_average(), |
|
1099 |
tenuring_threshold, target_size); |
|
1 | 1100 |
|
1101 |
set_survivor_size(target_size); |
|
1102 |
||
1103 |
return tenuring_threshold; |
|
1104 |
} |
|
1105 |
||
1106 |
void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow, |
|
1107 |
size_t survived, |
|
1108 |
size_t promoted) { |
|
1109 |
// Update averages |
|
1110 |
if (!is_survivor_overflow) { |
|
1111 |
// Keep running averages on how much survived |
|
1112 |
_avg_survived->sample(survived); |
|
1113 |
} else { |
|
1114 |
size_t survived_guess = survived + promoted; |
|
1115 |
_avg_survived->sample(survived_guess); |
|
1116 |
} |
|
31359 | 1117 |
avg_promoted()->sample(promoted); |
1 | 1118 |
|
35061 | 1119 |
log_trace(gc, ergo)("AdaptiveSizePolicy::update_averages: survived: " SIZE_FORMAT " promoted: " SIZE_FORMAT " overflow: %s", |
1120 |
survived, promoted, is_survivor_overflow ? "true" : "false"); |
|
1 | 1121 |
} |
1122 |
||
35061 | 1123 |
bool PSAdaptiveSizePolicy::print() const { |
1124 |
||
1125 |
if (!UseAdaptiveSizePolicy) { |
|
1126 |
return false; |
|
1127 |
} |
|
1 | 1128 |
|
35061 | 1129 |
if (AdaptiveSizePolicy::print()) { |
1130 |
AdaptiveSizePolicy::print_tenuring_threshold(PSScavenge::tenuring_threshold()); |
|
1131 |
return true; |
|
1132 |
} |
|
1 | 1133 |
|
35061 | 1134 |
return false; |
1 | 1135 |
} |