author | stefank |
Wed, 09 Apr 2014 13:54:32 +0200 | |
changeset 24092 | e274d864545a |
parent 22555 | ea32f6c51d08 |
child 24424 | 2658d7834c6e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
2 |
* Copyright (c) 2002, 2013, 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" |
22555
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
26 |
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" |
7397 | 27 |
#include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp" |
28 |
#include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp" |
|
29 |
#include "gc_implementation/parallelScavenge/psScavenge.hpp" |
|
30 |
#include "gc_implementation/shared/gcPolicyCounters.hpp" |
|
31 |
#include "gc_interface/gcCause.hpp" |
|
32 |
#include "memory/collectorPolicy.hpp" |
|
33 |
#include "runtime/timer.hpp" |
|
34 |
#include "utilities/top.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 |
||
133 |
if (gc_cause != GCCause::_java_lang_system_gc || |
|
134 |
UseAdaptiveSizePolicyWithSystemGC) { |
|
135 |
double major_pause_in_seconds = _major_timer.seconds(); |
|
136 |
double major_pause_in_ms = major_pause_in_seconds * MILLIUNITS; |
|
137 |
||
138 |
// Sample for performance counter |
|
139 |
_avg_major_pause->sample(major_pause_in_seconds); |
|
140 |
||
141 |
// Cost of collection (unit-less) |
|
142 |
double collection_cost = 0.0; |
|
143 |
if ((_latest_major_mutator_interval_seconds > 0.0) && |
|
144 |
(major_pause_in_seconds > 0.0)) { |
|
145 |
double interval_in_seconds = |
|
146 |
_latest_major_mutator_interval_seconds + major_pause_in_seconds; |
|
147 |
collection_cost = |
|
148 |
major_pause_in_seconds / interval_in_seconds; |
|
149 |
avg_major_gc_cost()->sample(collection_cost); |
|
150 |
||
151 |
// Sample for performance counter |
|
152 |
_avg_major_interval->sample(interval_in_seconds); |
|
153 |
} |
|
154 |
||
155 |
// Calculate variables used to estimate pause time vs. gen sizes |
|
156 |
double eden_size_in_mbytes = ((double)_eden_size)/((double)M); |
|
157 |
double promo_size_in_mbytes = ((double)_promo_size)/((double)M); |
|
158 |
_major_pause_old_estimator->update(promo_size_in_mbytes, |
|
159 |
major_pause_in_ms); |
|
160 |
_major_pause_young_estimator->update(eden_size_in_mbytes, |
|
161 |
major_pause_in_ms); |
|
162 |
||
163 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
164 |
gclog_or_tty->print("psAdaptiveSizePolicy::major_collection_end: " |
|
165 |
"major gc cost: %f average: %f", collection_cost, |
|
166 |
avg_major_gc_cost()->average()); |
|
167 |
gclog_or_tty->print_cr(" major pause: %f major period %f", |
|
168 |
major_pause_in_ms, |
|
169 |
_latest_major_mutator_interval_seconds * MILLIUNITS); |
|
170 |
} |
|
171 |
||
172 |
// Calculate variable used to estimate collection cost vs. gen sizes |
|
173 |
assert(collection_cost >= 0.0, "Expected to be non-negative"); |
|
174 |
_major_collection_estimator->update(promo_size_in_mbytes, |
|
175 |
collection_cost); |
|
176 |
} |
|
177 |
||
178 |
// Update the amount live at the end of a full GC |
|
179 |
_live_at_last_full_gc = amount_live; |
|
180 |
||
181 |
// The policy does not have enough data until at least some major collections |
|
182 |
// have been done. |
|
183 |
if (_avg_major_pause->count() >= AdaptiveSizePolicyReadyThreshold) { |
|
184 |
_old_gen_policy_is_ready = true; |
|
185 |
} |
|
186 |
||
187 |
// Interval times use this timer to measure the interval that |
|
188 |
// the mutator runs. Reset after the GC pause has been measured. |
|
189 |
_major_timer.reset(); |
|
190 |
_major_timer.start(); |
|
191 |
} |
|
192 |
||
193 |
// If the remaining free space in the old generation is less that |
|
194 |
// that expected to be needed by the next collection, do a full |
|
195 |
// collection now. |
|
196 |
bool PSAdaptiveSizePolicy::should_full_GC(size_t old_free_in_bytes) { |
|
197 |
||
198 |
// A similar test is done in the scavenge's should_attempt_scavenge(). If |
|
199 |
// this is changed, decide if that test should also be changed. |
|
200 |
bool result = padded_average_promoted_in_bytes() > (float) old_free_in_bytes; |
|
201 |
if (PrintGCDetails && Verbose) { |
|
202 |
if (result) { |
|
203 |
gclog_or_tty->print(" full after scavenge: "); |
|
204 |
} else { |
|
205 |
gclog_or_tty->print(" no full after scavenge: "); |
|
206 |
} |
|
207 |
gclog_or_tty->print_cr(" average_promoted " SIZE_FORMAT |
|
208 |
" padded_average_promoted " SIZE_FORMAT |
|
209 |
" free in old gen " SIZE_FORMAT, |
|
210 |
(size_t) average_promoted_in_bytes(), |
|
211 |
(size_t) padded_average_promoted_in_bytes(), |
|
212 |
old_free_in_bytes); |
|
213 |
} |
|
214 |
return result; |
|
215 |
} |
|
216 |
||
217 |
void PSAdaptiveSizePolicy::clear_generation_free_space_flags() { |
|
218 |
||
219 |
AdaptiveSizePolicy::clear_generation_free_space_flags(); |
|
220 |
||
221 |
set_change_old_gen_for_min_pauses(0); |
|
222 |
||
223 |
set_change_young_gen_for_maj_pauses(0); |
|
224 |
} |
|
225 |
||
226 |
// If this is not a full GC, only test and modify the young generation. |
|
227 |
||
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
17393
diff
changeset
|
228 |
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
|
229 |
size_t young_live, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
230 |
size_t eden_live, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
231 |
size_t old_live, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
232 |
size_t cur_eden, |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1
diff
changeset
|
233 |
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
|
234 |
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
|
235 |
bool is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
236 |
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
|
237 |
eden_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
238 |
cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
239 |
max_eden_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
240 |
is_full_gc); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
241 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
242 |
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
|
243 |
cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
244 |
max_old_gen_size, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
245 |
is_full_gc); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
246 |
} |
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 |
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
|
249 |
size_t young_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
250 |
size_t eden_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
251 |
size_t cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
252 |
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
|
253 |
bool is_full_gc) { |
1 | 254 |
|
255 |
// Update statistics |
|
256 |
// 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
|
257 |
_avg_base_footprint->sample(BaseFootPrintEstimate); |
1 | 258 |
avg_young_live()->sample(young_live); |
259 |
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
|
260 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
261 |
// 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
|
262 |
// 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
|
263 |
// 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
|
264 |
// 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
|
265 |
// 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
|
266 |
// 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
|
267 |
// 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
|
268 |
// 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
|
269 |
// 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
|
270 |
// 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
|
271 |
// 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
|
272 |
// 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
|
273 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
274 |
// 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
|
275 |
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
|
276 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
277 |
// 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
|
278 |
// 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
|
279 |
// run away. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
280 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
281 |
// 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
|
282 |
// 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
|
283 |
// 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
|
284 |
// 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
|
285 |
// 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
|
286 |
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
|
287 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
288 |
// 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
|
289 |
// 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
|
290 |
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
|
291 |
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
|
292 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
293 |
// 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
|
294 |
// 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
|
295 |
// 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
|
296 |
// 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
|
297 |
// 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
|
298 |
// 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
|
299 |
// 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
|
300 |
// subtracted out. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
301 |
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
|
302 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
303 |
const double gc_cost_limit = GCTimeLimit/100.0; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
304 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
305 |
// 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
|
306 |
// 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
|
307 |
// 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
|
308 |
// 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
|
309 |
// 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
|
310 |
// 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
|
311 |
// 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
|
312 |
// 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
|
313 |
// else |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
314 |
// 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
|
315 |
// generations. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
316 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
317 |
// 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
|
318 |
// 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
|
319 |
// attempting. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
320 |
|
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 |
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
|
323 |
(_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
|
324 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
325 |
// Check pauses |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
326 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
327 |
// 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
|
328 |
// at a time. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
329 |
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
|
330 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
331 |
} 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
|
332 |
// 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
|
333 |
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
|
334 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
335 |
} 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
|
336 |
// 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
|
337 |
// 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
|
338 |
// 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
|
339 |
// 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
|
340 |
// 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
|
341 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
342 |
// Throughput |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
343 |
// |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
344 |
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
|
345 |
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
|
346 |
// 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
|
347 |
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
|
348 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
349 |
} else { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
350 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
351 |
// 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
|
352 |
// 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
|
353 |
// 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
|
354 |
if (UseAdaptiveSizePolicyFootprintGoal && |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
355 |
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
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
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
|
360 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
361 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
362 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
363 |
// 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
|
364 |
// seems a little easier to read with the printing in another block. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
365 |
if (PrintAdaptiveSizePolicy) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
366 |
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
|
367 |
gclog_or_tty->print_cr( |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
368 |
"PSAdaptiveSizePolicy::compute_eden_space_size limits:" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
369 |
" desired_eden_size: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
370 |
" old_eden_size: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
371 |
" eden_limit: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
372 |
" cur_eden: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
373 |
" max_eden_size: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
374 |
" avg_young_live: " SIZE_FORMAT, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
375 |
desired_eden_size, _eden_size, eden_limit, cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
376 |
max_eden_size, (size_t)avg_young_live()->average()); |
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 |
if (gc_cost() > gc_cost_limit) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
379 |
gclog_or_tty->print_cr( |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
380 |
"PSAdaptiveSizePolicy::compute_eden_space_size: gc time limit" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
381 |
" gc_cost: %f " |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22555
diff
changeset
|
382 |
" GCTimeLimit: " UINTX_FORMAT, |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
383 |
gc_cost(), GCTimeLimit); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
384 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
385 |
} |
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 |
// Align everything and make a final limit check |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
388 |
desired_eden_size = align_size_up(desired_eden_size, _space_alignment); |
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
389 |
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
|
390 |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
391 |
eden_limit = align_size_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
|
392 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
393 |
// 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
|
394 |
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
|
395 |
// 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
|
396 |
// 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
|
397 |
// 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
|
398 |
// 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
|
399 |
// into the old gen. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
400 |
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
|
401 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
402 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
403 |
if (PrintAdaptiveSizePolicy) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
404 |
// Timing stats |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
405 |
gclog_or_tty->print( |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
406 |
"PSAdaptiveSizePolicy::compute_eden_space_size: costs" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
407 |
" minor_time: %f" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
408 |
" major_cost: %f" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
409 |
" mutator_cost: %f" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
410 |
" throughput_goal: %f", |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
411 |
minor_gc_cost(), major_gc_cost(), mutator_cost(), |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
412 |
_throughput_goal); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
413 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
414 |
// We give more details if Verbose is set |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
415 |
if (Verbose) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
416 |
gclog_or_tty->print( " minor_pause: %f" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
417 |
" major_pause: %f" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
418 |
" minor_interval: %f" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
419 |
" major_interval: %f" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
420 |
" pause_goal: %f", |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
421 |
_avg_minor_pause->padded_average(), |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
422 |
_avg_major_pause->padded_average(), |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
423 |
_avg_minor_interval->average(), |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
424 |
_avg_major_interval->average(), |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
425 |
gc_pause_goal_sec()); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
426 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
427 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
428 |
// Footprint stats |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
429 |
gclog_or_tty->print( " live_space: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
430 |
" free_space: " SIZE_FORMAT, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
431 |
live_space(), free_space()); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
432 |
// More detail |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
433 |
if (Verbose) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
434 |
gclog_or_tty->print( " base_footprint: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
435 |
" avg_young_live: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
436 |
" avg_old_live: " SIZE_FORMAT, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
437 |
(size_t)_avg_base_footprint->average(), |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
438 |
(size_t)avg_young_live()->average(), |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
439 |
(size_t)avg_old_live()->average()); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
440 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
441 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
442 |
// And finally, our old and new sizes. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
443 |
gclog_or_tty->print(" old_eden_size: " SIZE_FORMAT |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
444 |
" desired_eden_size: " SIZE_FORMAT, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
445 |
_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
|
446 |
gclog_or_tty->cr(); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
447 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
448 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
449 |
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
|
450 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
451 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
452 |
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
|
453 |
size_t old_live, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
454 |
size_t cur_eden, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
455 |
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
|
456 |
bool is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
457 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
458 |
// Update statistics |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
459 |
// Time statistics are updated as we go, update footprint stats here |
1 | 460 |
if (is_full_gc) { |
461 |
// old_live is only accurate after a full gc |
|
462 |
avg_old_live()->sample(old_live); |
|
463 |
} |
|
464 |
||
465 |
// This code used to return if the policy was not ready , i.e., |
|
466 |
// policy_is_ready() returning false. The intent was that |
|
467 |
// decisions below needed major collection times and so could |
|
468 |
// not be made before two major collections. A consequence was |
|
469 |
// adjustments to the young generation were not done until after |
|
470 |
// two major collections even if the minor collections times |
|
471 |
// exceeded the requested goals. Now let the young generation |
|
472 |
// adjust for the minor collection times. Major collection times |
|
473 |
// will be zero for the first collection and will naturally be |
|
474 |
// ignored. Tenured generation adjustments are only made at the |
|
475 |
// full collections so until the second major collection has |
|
476 |
// been reached, no tenured generation adjustments will be made. |
|
477 |
||
478 |
// Until we know better, desired promotion size uses the last calculation |
|
479 |
size_t desired_promo_size = _promo_size; |
|
480 |
||
481 |
// Start eden at the current value. The desired value that is stored |
|
482 |
// in _eden_size is not bounded by constraints of the heap and can |
|
483 |
// run away. |
|
484 |
// |
|
485 |
// As expected setting desired_eden_size to the current |
|
486 |
// value of desired_eden_size as a starting point |
|
487 |
// caused desired_eden_size to grow way too large and caused |
|
488 |
// an overflow down stream. It may have improved performance in |
|
489 |
// some case but is dangerous. |
|
490 |
size_t desired_eden_size = cur_eden; |
|
491 |
||
492 |
// Cache some values. There's a bit of work getting these, so |
|
493 |
// we might save a little time. |
|
494 |
const double major_cost = major_gc_cost(); |
|
495 |
const double minor_cost = minor_gc_cost(); |
|
496 |
||
497 |
// Limits on our growth |
|
498 |
size_t promo_limit = (size_t)(max_old_gen_size - avg_old_live()->average()); |
|
499 |
||
500 |
// But don't force a promo size below the current promo size. Otherwise, |
|
501 |
// the promo size will shrink for no good reason. |
|
502 |
promo_limit = MAX2(promo_limit, _promo_size); |
|
503 |
||
504 |
const double gc_cost_limit = GCTimeLimit/100.0; |
|
505 |
||
506 |
// Which way should we go? |
|
507 |
// if pause requirement is not met |
|
508 |
// adjust size of any generation with average paus exceeding |
|
509 |
// the pause limit. Adjust one pause at a time (the larger) |
|
510 |
// and only make adjustments for the major pause at full collections. |
|
511 |
// else if throughput requirement not met |
|
512 |
// adjust the size of the generation with larger gc time. Only |
|
513 |
// adjust one generation at a time. |
|
514 |
// else |
|
515 |
// adjust down the total heap size. Adjust down the larger of the |
|
516 |
// generations. |
|
517 |
||
22551 | 518 |
// Add some checks for a threshold for a change. For example, |
1 | 519 |
// a change less than the necessary alignment is probably not worth |
520 |
// attempting. |
|
521 |
||
522 |
if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) || |
|
523 |
(_avg_major_pause->padded_average() > gc_pause_goal_sec())) { |
|
524 |
// |
|
525 |
// Check pauses |
|
526 |
// |
|
527 |
// Make changes only to affect one of the pauses (the larger) |
|
528 |
// at a time. |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
529 |
if (is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
530 |
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
|
531 |
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
|
532 |
} |
1 | 533 |
} else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) { |
534 |
// Adjust only for the minor pause time goal |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
535 |
adjust_promo_for_minor_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); |
1 | 536 |
} else if(adjusted_mutator_cost() < _throughput_goal) { |
537 |
// This branch used to require that (mutator_cost() > 0.0 in 1.4.2. |
|
538 |
// This sometimes resulted in skipping to the minimize footprint |
|
539 |
// code. Change this to try and reduce GC time if mutator time is |
|
540 |
// negative for whatever reason. Or for future consideration, |
|
541 |
// bail out of the code if mutator time is negative. |
|
542 |
// |
|
543 |
// Throughput |
|
544 |
// |
|
545 |
assert(major_cost >= 0.0, "major cost is < 0.0"); |
|
546 |
assert(minor_cost >= 0.0, "minor cost is < 0.0"); |
|
547 |
// 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
|
548 |
if (is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
549 |
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
|
550 |
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
|
551 |
} |
1 | 552 |
} else { |
553 |
||
554 |
// Be conservative about reducing the footprint. |
|
555 |
// Do a minimum number of major collections first. |
|
556 |
// Have reasonable averages for major and minor collections costs. |
|
557 |
if (UseAdaptiveSizePolicyFootprintGoal && |
|
558 |
young_gen_policy_is_ready() && |
|
559 |
avg_major_gc_cost()->average() >= 0.0 && |
|
560 |
avg_minor_gc_cost()->average() >= 0.0) { |
|
561 |
if (is_full_gc) { |
|
562 |
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
|
563 |
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
|
564 |
desired_promo_size = adjust_promo_for_footprint(desired_promo_size, desired_sum); |
1 | 565 |
} |
566 |
} |
|
567 |
} |
|
568 |
||
569 |
// Note we make the same tests as in the code block below; the code |
|
570 |
// seems a little easier to read with the printing in another block. |
|
571 |
if (PrintAdaptiveSizePolicy) { |
|
572 |
if (desired_promo_size > promo_limit) { |
|
573 |
// "free_in_old_gen" was the original value for used for promo_limit |
|
574 |
size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average()); |
|
575 |
gclog_or_tty->print_cr( |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
576 |
"PSAdaptiveSizePolicy::compute_old_gen_free_space limits:" |
1 | 577 |
" desired_promo_size: " SIZE_FORMAT |
578 |
" promo_limit: " SIZE_FORMAT |
|
579 |
" free_in_old_gen: " SIZE_FORMAT |
|
580 |
" max_old_gen_size: " SIZE_FORMAT |
|
581 |
" avg_old_live: " SIZE_FORMAT, |
|
582 |
desired_promo_size, promo_limit, free_in_old_gen, |
|
583 |
max_old_gen_size, (size_t) avg_old_live()->average()); |
|
584 |
} |
|
585 |
if (gc_cost() > gc_cost_limit) { |
|
586 |
gclog_or_tty->print_cr( |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
587 |
"PSAdaptiveSizePolicy::compute_old_gen_free_space: gc time limit" |
1 | 588 |
" gc_cost: %f " |
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22555
diff
changeset
|
589 |
" GCTimeLimit: " UINTX_FORMAT, |
1 | 590 |
gc_cost(), GCTimeLimit); |
591 |
} |
|
592 |
} |
|
593 |
||
594 |
// Align everything and make a final limit check |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
595 |
desired_promo_size = align_size_up(desired_promo_size, _space_alignment); |
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
596 |
desired_promo_size = MAX2(desired_promo_size, _space_alignment); |
1 | 597 |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
598 |
promo_limit = align_size_down(promo_limit, _space_alignment); |
1 | 599 |
|
600 |
// And one last limit check, now that we've aligned things. |
|
601 |
desired_promo_size = MIN2(desired_promo_size, promo_limit); |
|
602 |
||
603 |
if (PrintAdaptiveSizePolicy) { |
|
604 |
// Timing stats |
|
605 |
gclog_or_tty->print( |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
606 |
"PSAdaptiveSizePolicy::compute_old_gen_free_space: costs" |
1 | 607 |
" minor_time: %f" |
608 |
" major_cost: %f" |
|
609 |
" mutator_cost: %f" |
|
610 |
" throughput_goal: %f", |
|
611 |
minor_gc_cost(), major_gc_cost(), mutator_cost(), |
|
612 |
_throughput_goal); |
|
613 |
||
614 |
// We give more details if Verbose is set |
|
615 |
if (Verbose) { |
|
616 |
gclog_or_tty->print( " minor_pause: %f" |
|
617 |
" major_pause: %f" |
|
618 |
" minor_interval: %f" |
|
619 |
" major_interval: %f" |
|
620 |
" pause_goal: %f", |
|
621 |
_avg_minor_pause->padded_average(), |
|
622 |
_avg_major_pause->padded_average(), |
|
623 |
_avg_minor_interval->average(), |
|
624 |
_avg_major_interval->average(), |
|
625 |
gc_pause_goal_sec()); |
|
626 |
} |
|
627 |
||
628 |
// Footprint stats |
|
629 |
gclog_or_tty->print( " live_space: " SIZE_FORMAT |
|
630 |
" free_space: " SIZE_FORMAT, |
|
631 |
live_space(), free_space()); |
|
632 |
// More detail |
|
633 |
if (Verbose) { |
|
634 |
gclog_or_tty->print( " base_footprint: " SIZE_FORMAT |
|
635 |
" avg_young_live: " SIZE_FORMAT |
|
636 |
" avg_old_live: " SIZE_FORMAT, |
|
637 |
(size_t)_avg_base_footprint->average(), |
|
638 |
(size_t)avg_young_live()->average(), |
|
639 |
(size_t)avg_old_live()->average()); |
|
640 |
} |
|
641 |
||
642 |
// And finally, our old and new sizes. |
|
643 |
gclog_or_tty->print(" old_promo_size: " SIZE_FORMAT |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
644 |
" desired_promo_size: " SIZE_FORMAT, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
645 |
_promo_size, desired_promo_size); |
1 | 646 |
gclog_or_tty->cr(); |
647 |
} |
|
648 |
||
649 |
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
|
650 |
} |
1 | 651 |
|
652 |
void PSAdaptiveSizePolicy::decay_supplemental_growth(bool is_full_gc) { |
|
653 |
// Decay the supplemental increment? Decay the supplement growth |
|
654 |
// factor even if it is not used. It is only meant to give a boost |
|
655 |
// to the initial growth and if it is not used, then it was not |
|
656 |
// needed. |
|
657 |
if (is_full_gc) { |
|
658 |
// Don't wait for the threshold value for the major collections. If |
|
659 |
// here, the supplemental growth term was used and should decay. |
|
660 |
if ((_avg_major_pause->count() % TenuredGenerationSizeSupplementDecay) |
|
661 |
== 0) { |
|
662 |
_old_gen_size_increment_supplement = |
|
663 |
_old_gen_size_increment_supplement >> 1; |
|
664 |
} |
|
665 |
} else { |
|
666 |
if ((_avg_minor_pause->count() >= AdaptiveSizePolicyReadyThreshold) && |
|
667 |
(_avg_minor_pause->count() % YoungGenerationSizeSupplementDecay) == 0) { |
|
668 |
_young_gen_size_increment_supplement = |
|
669 |
_young_gen_size_increment_supplement >> 1; |
|
670 |
} |
|
671 |
} |
|
672 |
} |
|
673 |
||
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
674 |
void PSAdaptiveSizePolicy::adjust_promo_for_minor_pause_time(bool is_full_gc, |
1 | 675 |
size_t* desired_promo_size_ptr, size_t* desired_eden_size_ptr) { |
676 |
||
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
677 |
if (PSAdjustTenuredGenForMinorPause) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
678 |
if (is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
679 |
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
|
680 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
681 |
// If the desired eden size is as small as it will get, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
682 |
// try to adjust the old gen size. |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
683 |
if (*desired_eden_size_ptr <= _space_alignment) { |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
684 |
// Vary the old gen size to reduce the young gen pause. This |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
685 |
// may not be a good idea. This is just a test. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
686 |
if (minor_pause_old_estimator()->decrement_will_decrease()) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
687 |
set_change_old_gen_for_min_pauses(decrease_old_gen_for_min_pauses_true); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
688 |
*desired_promo_size_ptr = |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
689 |
_promo_size - promo_decrement_aligned_down(*desired_promo_size_ptr); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
690 |
} else { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
691 |
set_change_old_gen_for_min_pauses(increase_old_gen_for_min_pauses_true); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
692 |
size_t promo_heap_delta = |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
693 |
promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
694 |
if ((*desired_promo_size_ptr + promo_heap_delta) > |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
695 |
*desired_promo_size_ptr) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
696 |
*desired_promo_size_ptr = |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
697 |
_promo_size + promo_heap_delta; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
698 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
699 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
700 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
701 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
702 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
703 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
704 |
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
|
705 |
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
|
706 |
|
1 | 707 |
// Adjust the young generation size to reduce pause time of |
708 |
// of collections. |
|
709 |
// |
|
710 |
// The AdaptiveSizePolicyInitializingSteps test is not used |
|
711 |
// here. It has not seemed to be needed but perhaps should |
|
712 |
// be added for consistency. |
|
713 |
if (minor_pause_young_estimator()->decrement_will_decrease()) { |
|
714 |
// reduce eden size |
|
715 |
set_change_young_gen_for_min_pauses( |
|
716 |
decrease_young_gen_for_min_pauses_true); |
|
717 |
*desired_eden_size_ptr = *desired_eden_size_ptr - |
|
718 |
eden_decrement_aligned_down(*desired_eden_size_ptr); |
|
719 |
} else { |
|
720 |
// EXPERIMENTAL ADJUSTMENT |
|
721 |
// Only record that the estimator indicated such an action. |
|
722 |
// *desired_eden_size_ptr = *desired_eden_size_ptr + eden_heap_delta; |
|
723 |
set_change_young_gen_for_min_pauses( |
|
724 |
increase_young_gen_for_min_pauses_true); |
|
725 |
} |
|
726 |
} |
|
727 |
||
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
728 |
void PSAdaptiveSizePolicy::adjust_promo_for_pause_time(bool is_full_gc, |
1 | 729 |
size_t* desired_promo_size_ptr, |
730 |
size_t* desired_eden_size_ptr) { |
|
731 |
||
732 |
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
|
733 |
// Add some checks for a threshold for a change. For example, |
1 | 734 |
// a change less than the required alignment is probably not worth |
735 |
// attempting. |
|
736 |
||
737 |
if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) { |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
738 |
adjust_promo_for_minor_pause_time(is_full_gc, desired_promo_size_ptr, desired_eden_size_ptr); |
1 | 739 |
// major pause adjustments |
740 |
} else if (is_full_gc) { |
|
741 |
// Adjust for the major pause time only at full gc's because the |
|
742 |
// affects of a change can only be seen at full gc's. |
|
743 |
||
744 |
// Reduce old generation size to reduce pause? |
|
745 |
if (major_pause_old_estimator()->decrement_will_decrease()) { |
|
746 |
// reduce old generation size |
|
747 |
set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true); |
|
748 |
promo_heap_delta = promo_decrement_aligned_down(*desired_promo_size_ptr); |
|
749 |
*desired_promo_size_ptr = _promo_size - promo_heap_delta; |
|
750 |
} else { |
|
751 |
// EXPERIMENTAL ADJUSTMENT |
|
752 |
// Only record that the estimator indicated such an action. |
|
753 |
// *desired_promo_size_ptr = _promo_size + |
|
754 |
// promo_increment_aligned_up(*desired_promo_size_ptr); |
|
755 |
set_change_old_gen_for_maj_pauses(increase_old_gen_for_maj_pauses_true); |
|
756 |
} |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
757 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
758 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
759 |
if (PrintAdaptiveSizePolicy && Verbose) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
760 |
gclog_or_tty->print_cr( |
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
17393
diff
changeset
|
761 |
"PSAdaptiveSizePolicy::adjust_promo_for_pause_time " |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
762 |
"adjusting gen sizes for major pause (avg %f goal %f). " |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
763 |
"desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
764 |
_avg_major_pause->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
|
765 |
*desired_promo_size_ptr, promo_heap_delta); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
766 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
767 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
768 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
769 |
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
|
770 |
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
|
771 |
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
|
772 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
773 |
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
|
774 |
// 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
|
775 |
// 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
|
776 |
// attempting. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
777 |
if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
778 |
adjust_eden_for_minor_pause_time(is_full_gc, |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
779 |
desired_eden_size_ptr); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
780 |
// major pause adjustments |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
781 |
} else if (is_full_gc) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
782 |
// Adjust for the major pause time only at full gc's because the |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
783 |
// affects of a change can only be seen at full gc's. |
1 | 784 |
if (PSAdjustYoungGenForMajorPause) { |
785 |
// If the promo size is at the minimum (i.e., the old gen |
|
786 |
// size will not actually decrease), consider changing the |
|
787 |
// young gen size. |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
788 |
if (*desired_promo_size_ptr < _space_alignment) { |
1 | 789 |
// If increasing the young generation will decrease the old gen |
790 |
// pause, do it. |
|
791 |
// During startup there is noise in the statistics for deciding |
|
792 |
// on whether to increase or decrease the young gen size. For |
|
793 |
// some number of iterations, just try to increase the young |
|
794 |
// gen size if the major pause is too long to try and establish |
|
795 |
// good statistics for later decisions. |
|
796 |
if (major_pause_young_estimator()->increment_will_decrease() || |
|
797 |
(_young_gen_change_for_major_pause_count |
|
798 |
<= AdaptiveSizePolicyInitializingSteps)) { |
|
799 |
set_change_young_gen_for_maj_pauses( |
|
800 |
increase_young_gen_for_maj_pauses_true); |
|
801 |
eden_heap_delta = eden_increment_aligned_up(*desired_eden_size_ptr); |
|
802 |
*desired_eden_size_ptr = _eden_size + eden_heap_delta; |
|
803 |
_young_gen_change_for_major_pause_count++; |
|
804 |
} else { |
|
805 |
// Record that decreasing the young gen size would decrease |
|
806 |
// the major pause |
|
807 |
set_change_young_gen_for_maj_pauses( |
|
808 |
decrease_young_gen_for_maj_pauses_true); |
|
809 |
eden_heap_delta = eden_decrement_aligned_down(*desired_eden_size_ptr); |
|
810 |
*desired_eden_size_ptr = _eden_size - eden_heap_delta; |
|
811 |
} |
|
812 |
} |
|
813 |
} |
|
814 |
} |
|
815 |
||
816 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
817 |
gclog_or_tty->print_cr( |
|
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
17393
diff
changeset
|
818 |
"PSAdaptiveSizePolicy::adjust_eden_for_pause_time " |
1 | 819 |
"adjusting gen sizes for major pause (avg %f goal %f). " |
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
820 |
"desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, |
1 | 821 |
_avg_major_pause->average(), 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
|
822 |
*desired_eden_size_ptr, eden_heap_delta); |
1 | 823 |
} |
824 |
} |
|
825 |
||
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
826 |
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
|
827 |
size_t* desired_promo_size_ptr) { |
1 | 828 |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
829 |
// Add some checks for a threshold for a change. For example, |
1 | 830 |
// a change less than the required alignment is probably not worth |
831 |
// attempting. |
|
832 |
||
833 |
if ((gc_cost() + mutator_cost()) == 0.0) { |
|
834 |
return; |
|
835 |
} |
|
836 |
||
837 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
838 |
gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_promo_for_throughput(" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
839 |
"is_full: %d, promo: " SIZE_FORMAT "): ", |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
840 |
is_full_gc, *desired_promo_size_ptr); |
1 | 841 |
gclog_or_tty->print_cr("mutator_cost %f major_gc_cost %f " |
842 |
"minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost()); |
|
843 |
} |
|
844 |
||
845 |
// Tenured generation |
|
846 |
if (is_full_gc) { |
|
847 |
// Calculate the change to use for the tenured gen. |
|
848 |
size_t scaled_promo_heap_delta = 0; |
|
849 |
// Can the increment to the generation be scaled? |
|
850 |
if (gc_cost() >= 0.0 && major_gc_cost() >= 0.0) { |
|
851 |
size_t promo_heap_delta = |
|
852 |
promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); |
|
853 |
double scale_by_ratio = major_gc_cost() / gc_cost(); |
|
854 |
scaled_promo_heap_delta = |
|
855 |
(size_t) (scale_by_ratio * (double) promo_heap_delta); |
|
856 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
857 |
gclog_or_tty->print_cr( |
|
858 |
"Scaled tenured increment: " SIZE_FORMAT " by %f down to " |
|
859 |
SIZE_FORMAT, |
|
860 |
promo_heap_delta, scale_by_ratio, scaled_promo_heap_delta); |
|
861 |
} |
|
862 |
} else if (major_gc_cost() >= 0.0) { |
|
863 |
// Scaling is not going to work. If the major gc time is the |
|
864 |
// larger, give it a full increment. |
|
865 |
if (major_gc_cost() >= minor_gc_cost()) { |
|
866 |
scaled_promo_heap_delta = |
|
867 |
promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); |
|
868 |
} |
|
869 |
} else { |
|
870 |
// Don't expect to get here but it's ok if it does |
|
871 |
// in the product build since the delta will be 0 |
|
872 |
// and nothing will change. |
|
873 |
assert(false, "Unexpected value for gc costs"); |
|
874 |
} |
|
875 |
||
876 |
switch (AdaptiveSizeThroughPutPolicy) { |
|
877 |
case 1: |
|
878 |
// Early in the run the statistics might not be good. Until |
|
879 |
// a specific number of collections have been, use the heuristic |
|
880 |
// that a larger generation size means lower collection costs. |
|
881 |
if (major_collection_estimator()->increment_will_decrease() || |
|
882 |
(_old_gen_change_for_major_throughput |
|
883 |
<= AdaptiveSizePolicyInitializingSteps)) { |
|
884 |
// Increase tenured generation size to reduce major collection cost |
|
885 |
if ((*desired_promo_size_ptr + scaled_promo_heap_delta) > |
|
886 |
*desired_promo_size_ptr) { |
|
887 |
*desired_promo_size_ptr = _promo_size + scaled_promo_heap_delta; |
|
888 |
} |
|
889 |
set_change_old_gen_for_throughput( |
|
890 |
increase_old_gen_for_throughput_true); |
|
891 |
_old_gen_change_for_major_throughput++; |
|
892 |
} else { |
|
893 |
// EXPERIMENTAL ADJUSTMENT |
|
894 |
// Record that decreasing the old gen size would decrease |
|
895 |
// the major collection cost but don't do it. |
|
896 |
// *desired_promo_size_ptr = _promo_size - |
|
897 |
// promo_decrement_aligned_down(*desired_promo_size_ptr); |
|
898 |
set_change_old_gen_for_throughput( |
|
899 |
decrease_old_gen_for_throughput_true); |
|
900 |
} |
|
901 |
||
902 |
break; |
|
903 |
default: |
|
904 |
// Simplest strategy |
|
905 |
if ((*desired_promo_size_ptr + scaled_promo_heap_delta) > |
|
906 |
*desired_promo_size_ptr) { |
|
907 |
*desired_promo_size_ptr = *desired_promo_size_ptr + |
|
908 |
scaled_promo_heap_delta; |
|
909 |
} |
|
910 |
set_change_old_gen_for_throughput( |
|
911 |
increase_old_gen_for_throughput_true); |
|
912 |
_old_gen_change_for_major_throughput++; |
|
913 |
} |
|
914 |
||
915 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
916 |
gclog_or_tty->print_cr( |
|
917 |
"adjusting tenured gen for throughput (avg %f goal %f). " |
|
918 |
"desired_promo_size " SIZE_FORMAT " promo_delta " SIZE_FORMAT , |
|
919 |
mutator_cost(), _throughput_goal, |
|
920 |
*desired_promo_size_ptr, scaled_promo_heap_delta); |
|
921 |
} |
|
922 |
} |
|
17393
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
923 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
924 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
925 |
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
|
926 |
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
|
927 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
928 |
// 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
|
929 |
// 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
|
930 |
// attempting. |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
931 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
932 |
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
|
933 |
return; |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
934 |
} |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
935 |
|
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
936 |
if (PrintAdaptiveSizePolicy && Verbose) { |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
937 |
gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_eden_for_throughput(" |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
938 |
"is_full: %d, cur_eden: " SIZE_FORMAT "): ", |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
939 |
is_full_gc, *desired_eden_size_ptr); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
940 |
gclog_or_tty->print_cr("mutator_cost %f major_gc_cost %f " |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
941 |
"minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost()); |
7e99f263902c
8007763: Refactoring: split up compute_generation_free_space() into two functions for class PSAdaptiveSizePolicy
tamao
parents:
13925
diff
changeset
|
942 |
} |
1 | 943 |
|
944 |
// Young generation |
|
945 |
size_t scaled_eden_heap_delta = 0; |
|
946 |
// Can the increment to the generation be scaled? |
|
947 |
if (gc_cost() >= 0.0 && minor_gc_cost() >= 0.0) { |
|
948 |
size_t eden_heap_delta = |
|
949 |
eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr); |
|
950 |
double scale_by_ratio = minor_gc_cost() / gc_cost(); |
|
951 |
assert(scale_by_ratio <= 1.0 && scale_by_ratio >= 0.0, "Scaling is wrong"); |
|
952 |
scaled_eden_heap_delta = |
|
953 |
(size_t) (scale_by_ratio * (double) eden_heap_delta); |
|
954 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
955 |
gclog_or_tty->print_cr( |
|
956 |
"Scaled eden increment: " SIZE_FORMAT " by %f down to " |
|
957 |
SIZE_FORMAT, |
|
958 |
eden_heap_delta, scale_by_ratio, scaled_eden_heap_delta); |
|
959 |
} |
|
960 |
} else if (minor_gc_cost() >= 0.0) { |
|
961 |
// Scaling is not going to work. If the minor gc time is the |
|
962 |
// larger, give it a full increment. |
|
963 |
if (minor_gc_cost() > major_gc_cost()) { |
|
964 |
scaled_eden_heap_delta = |
|
965 |
eden_increment_with_supplement_aligned_up(*desired_eden_size_ptr); |
|
966 |
} |
|
967 |
} else { |
|
968 |
// Don't expect to get here but it's ok if it does |
|
969 |
// in the product build since the delta will be 0 |
|
970 |
// and nothing will change. |
|
971 |
assert(false, "Unexpected value for gc costs"); |
|
972 |
} |
|
973 |
||
974 |
// Use a heuristic for some number of collections to give |
|
975 |
// the averages time to settle down. |
|
976 |
switch (AdaptiveSizeThroughPutPolicy) { |
|
977 |
case 1: |
|
978 |
if (minor_collection_estimator()->increment_will_decrease() || |
|
979 |
(_young_gen_change_for_minor_throughput |
|
980 |
<= AdaptiveSizePolicyInitializingSteps)) { |
|
981 |
// Expand young generation size to reduce frequency of |
|
982 |
// of collections. |
|
983 |
if ((*desired_eden_size_ptr + scaled_eden_heap_delta) > |
|
984 |
*desired_eden_size_ptr) { |
|
985 |
*desired_eden_size_ptr = |
|
986 |
*desired_eden_size_ptr + scaled_eden_heap_delta; |
|
987 |
} |
|
988 |
set_change_young_gen_for_throughput( |
|
989 |
increase_young_gen_for_througput_true); |
|
990 |
_young_gen_change_for_minor_throughput++; |
|
991 |
} else { |
|
992 |
// EXPERIMENTAL ADJUSTMENT |
|
993 |
// Record that decreasing the young gen size would decrease |
|
994 |
// the minor collection cost but don't do it. |
|
995 |
// *desired_eden_size_ptr = _eden_size - |
|
996 |
// eden_decrement_aligned_down(*desired_eden_size_ptr); |
|
997 |
set_change_young_gen_for_throughput( |
|
998 |
decrease_young_gen_for_througput_true); |
|
999 |
} |
|
1000 |
break; |
|
1001 |
default: |
|
1002 |
if ((*desired_eden_size_ptr + scaled_eden_heap_delta) > |
|
1003 |
*desired_eden_size_ptr) { |
|
1004 |
*desired_eden_size_ptr = |
|
1005 |
*desired_eden_size_ptr + scaled_eden_heap_delta; |
|
1006 |
} |
|
1007 |
set_change_young_gen_for_throughput( |
|
1008 |
increase_young_gen_for_througput_true); |
|
1009 |
_young_gen_change_for_minor_throughput++; |
|
1010 |
} |
|
1011 |
||
1012 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
1013 |
gclog_or_tty->print_cr( |
|
1014 |
"adjusting eden for throughput (avg %f goal %f). desired_eden_size " |
|
1015 |
SIZE_FORMAT " eden delta " SIZE_FORMAT "\n", |
|
1016 |
mutator_cost(), _throughput_goal, |
|
1017 |
*desired_eden_size_ptr, scaled_eden_heap_delta); |
|
1018 |
} |
|
1019 |
} |
|
1020 |
||
1021 |
size_t PSAdaptiveSizePolicy::adjust_promo_for_footprint( |
|
1022 |
size_t desired_promo_size, size_t desired_sum) { |
|
1023 |
assert(desired_promo_size <= desired_sum, "Inconsistent parameters"); |
|
1024 |
set_decrease_for_footprint(decrease_old_gen_for_footprint_true); |
|
1025 |
||
1026 |
size_t change = promo_decrement(desired_promo_size); |
|
1027 |
change = scale_down(change, desired_promo_size, desired_sum); |
|
1028 |
||
1029 |
size_t reduced_size = desired_promo_size - change; |
|
1030 |
||
1031 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
1032 |
gclog_or_tty->print_cr( |
|
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
17393
diff
changeset
|
1033 |
"AdaptiveSizePolicy::adjust_promo_for_footprint " |
1 | 1034 |
"adjusting tenured gen for footprint. " |
1035 |
"starting promo size " SIZE_FORMAT |
|
1036 |
" reduced promo size " SIZE_FORMAT, |
|
1037 |
" promo delta " SIZE_FORMAT, |
|
1038 |
desired_promo_size, reduced_size, change ); |
|
1039 |
} |
|
1040 |
||
1041 |
assert(reduced_size <= desired_promo_size, "Inconsistent result"); |
|
1042 |
return reduced_size; |
|
1043 |
} |
|
1044 |
||
1045 |
size_t PSAdaptiveSizePolicy::adjust_eden_for_footprint( |
|
1046 |
size_t desired_eden_size, size_t desired_sum) { |
|
1047 |
assert(desired_eden_size <= desired_sum, "Inconsistent parameters"); |
|
1048 |
set_decrease_for_footprint(decrease_young_gen_for_footprint_true); |
|
1049 |
||
1050 |
size_t change = eden_decrement(desired_eden_size); |
|
1051 |
change = scale_down(change, desired_eden_size, desired_sum); |
|
1052 |
||
1053 |
size_t reduced_size = desired_eden_size - change; |
|
1054 |
||
1055 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
1056 |
gclog_or_tty->print_cr( |
|
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
17393
diff
changeset
|
1057 |
"AdaptiveSizePolicy::adjust_eden_for_footprint " |
1 | 1058 |
"adjusting eden for footprint. " |
1059 |
" starting eden size " SIZE_FORMAT |
|
1060 |
" reduced eden size " SIZE_FORMAT |
|
1061 |
" eden delta " SIZE_FORMAT, |
|
1062 |
desired_eden_size, reduced_size, change); |
|
1063 |
} |
|
1064 |
||
1065 |
assert(reduced_size <= desired_eden_size, "Inconsistent result"); |
|
1066 |
return reduced_size; |
|
1067 |
} |
|
1068 |
||
1069 |
// Scale down "change" by the factor |
|
1070 |
// part / total |
|
1071 |
// Don't align the results. |
|
1072 |
||
1073 |
size_t PSAdaptiveSizePolicy::scale_down(size_t change, |
|
1074 |
double part, |
|
1075 |
double total) { |
|
1076 |
assert(part <= total, "Inconsistent input"); |
|
1077 |
size_t reduced_change = change; |
|
1078 |
if (total > 0) { |
|
1079 |
double fraction = part / total; |
|
1080 |
reduced_change = (size_t) (fraction * (double) change); |
|
1081 |
} |
|
1082 |
assert(reduced_change <= change, "Inconsistent result"); |
|
1083 |
return reduced_change; |
|
1084 |
} |
|
1085 |
||
1086 |
size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden, |
|
1087 |
uint percent_change) { |
|
1088 |
size_t eden_heap_delta; |
|
1089 |
eden_heap_delta = cur_eden / 100 * percent_change; |
|
1090 |
return eden_heap_delta; |
|
1091 |
} |
|
1092 |
||
1093 |
size_t PSAdaptiveSizePolicy::eden_increment(size_t cur_eden) { |
|
1094 |
return eden_increment(cur_eden, YoungGenerationSizeIncrement); |
|
1095 |
} |
|
1096 |
||
1097 |
size_t PSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) { |
|
1098 |
size_t result = eden_increment(cur_eden, YoungGenerationSizeIncrement); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1099 |
return align_size_up(result, _space_alignment); |
1 | 1100 |
} |
1101 |
||
1102 |
size_t PSAdaptiveSizePolicy::eden_increment_aligned_down(size_t cur_eden) { |
|
1103 |
size_t result = eden_increment(cur_eden); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1104 |
return align_size_down(result, _space_alignment); |
1 | 1105 |
} |
1106 |
||
1107 |
size_t PSAdaptiveSizePolicy::eden_increment_with_supplement_aligned_up( |
|
1108 |
size_t cur_eden) { |
|
1109 |
size_t result = eden_increment(cur_eden, |
|
1110 |
YoungGenerationSizeIncrement + _young_gen_size_increment_supplement); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1111 |
return align_size_up(result, _space_alignment); |
1 | 1112 |
} |
1113 |
||
1114 |
size_t PSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) { |
|
1115 |
size_t eden_heap_delta = eden_decrement(cur_eden); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1116 |
return align_size_down(eden_heap_delta, _space_alignment); |
1 | 1117 |
} |
1118 |
||
1119 |
size_t PSAdaptiveSizePolicy::eden_decrement(size_t cur_eden) { |
|
1120 |
size_t eden_heap_delta = eden_increment(cur_eden) / |
|
1121 |
AdaptiveSizeDecrementScaleFactor; |
|
1122 |
return eden_heap_delta; |
|
1123 |
} |
|
1124 |
||
1125 |
size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo, |
|
1126 |
uint percent_change) { |
|
1127 |
size_t promo_heap_delta; |
|
1128 |
promo_heap_delta = cur_promo / 100 * percent_change; |
|
1129 |
return promo_heap_delta; |
|
1130 |
} |
|
1131 |
||
1132 |
size_t PSAdaptiveSizePolicy::promo_increment(size_t cur_promo) { |
|
1133 |
return promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
|
1134 |
} |
|
1135 |
||
1136 |
size_t PSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { |
|
1137 |
size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1138 |
return align_size_up(result, _space_alignment); |
1 | 1139 |
} |
1140 |
||
1141 |
size_t PSAdaptiveSizePolicy::promo_increment_aligned_down(size_t cur_promo) { |
|
1142 |
size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1143 |
return align_size_down(result, _space_alignment); |
1 | 1144 |
} |
1145 |
||
1146 |
size_t PSAdaptiveSizePolicy::promo_increment_with_supplement_aligned_up( |
|
1147 |
size_t cur_promo) { |
|
1148 |
size_t result = promo_increment(cur_promo, |
|
1149 |
TenuredGenerationSizeIncrement + _old_gen_size_increment_supplement); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1150 |
return align_size_up(result, _space_alignment); |
1 | 1151 |
} |
1152 |
||
1153 |
size_t PSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) { |
|
1154 |
size_t promo_heap_delta = promo_decrement(cur_promo); |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1155 |
return align_size_down(promo_heap_delta, _space_alignment); |
1 | 1156 |
} |
1157 |
||
1158 |
size_t PSAdaptiveSizePolicy::promo_decrement(size_t cur_promo) { |
|
1159 |
size_t promo_heap_delta = promo_increment(cur_promo); |
|
1160 |
promo_heap_delta = promo_heap_delta / AdaptiveSizeDecrementScaleFactor; |
|
1161 |
return promo_heap_delta; |
|
1162 |
} |
|
1163 |
||
13925 | 1164 |
uint PSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( |
1 | 1165 |
bool is_survivor_overflow, |
13925 | 1166 |
uint tenuring_threshold, |
1 | 1167 |
size_t survivor_limit) { |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1168 |
assert(survivor_limit >= _space_alignment, |
1 | 1169 |
"survivor_limit too small"); |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1170 |
assert((size_t)align_size_down(survivor_limit, _space_alignment) |
1 | 1171 |
== survivor_limit, "survivor_limit not aligned"); |
1172 |
||
1173 |
// This method is called even if the tenuring threshold and survivor |
|
1174 |
// spaces are not adjusted so that the averages are sampled above. |
|
1175 |
if (!UsePSAdaptiveSurvivorSizePolicy || |
|
1176 |
!young_gen_policy_is_ready()) { |
|
1177 |
return tenuring_threshold; |
|
1178 |
} |
|
1179 |
||
1180 |
// We'll decide whether to increase or decrease the tenuring |
|
1181 |
// threshold based partly on the newly computed survivor size |
|
1182 |
// (if we hit the maximum limit allowed, we'll always choose to |
|
1183 |
// decrement the threshold). |
|
1184 |
bool incr_tenuring_threshold = false; |
|
1185 |
bool decr_tenuring_threshold = false; |
|
1186 |
||
1187 |
set_decrement_tenuring_threshold_for_gc_cost(false); |
|
1188 |
set_increment_tenuring_threshold_for_gc_cost(false); |
|
1189 |
set_decrement_tenuring_threshold_for_survivor_limit(false); |
|
1190 |
||
1191 |
if (!is_survivor_overflow) { |
|
1192 |
// Keep running averages on how much survived |
|
1193 |
||
1194 |
// We use the tenuring threshold to equalize the cost of major |
|
1195 |
// and minor collections. |
|
1196 |
// ThresholdTolerance is used to indicate how sensitive the |
|
22551 | 1197 |
// tenuring threshold is to differences in cost between the |
1 | 1198 |
// collection types. |
1199 |
||
1200 |
// Get the times of interest. This involves a little work, so |
|
1201 |
// we cache the values here. |
|
1202 |
const double major_cost = major_gc_cost(); |
|
1203 |
const double minor_cost = minor_gc_cost(); |
|
1204 |
||
1205 |
if (minor_cost > major_cost * _threshold_tolerance_percent) { |
|
1206 |
// Minor times are getting too long; lower the threshold so |
|
1207 |
// less survives and more is promoted. |
|
1208 |
decr_tenuring_threshold = true; |
|
1209 |
set_decrement_tenuring_threshold_for_gc_cost(true); |
|
1210 |
} else if (major_cost > minor_cost * _threshold_tolerance_percent) { |
|
1211 |
// Major times are too long, so we want less promotion. |
|
1212 |
incr_tenuring_threshold = true; |
|
1213 |
set_increment_tenuring_threshold_for_gc_cost(true); |
|
1214 |
} |
|
1215 |
||
1216 |
} else { |
|
1217 |
// Survivor space overflow occurred, so promoted and survived are |
|
1218 |
// not accurate. We'll make our best guess by combining survived |
|
1219 |
// and promoted and count them as survivors. |
|
1220 |
// |
|
1221 |
// We'll lower the tenuring threshold to see if we can correct |
|
1222 |
// things. Also, set the survivor size conservatively. We're |
|
1223 |
// trying to avoid many overflows from occurring if defnew size |
|
1224 |
// is just too small. |
|
1225 |
||
1226 |
decr_tenuring_threshold = true; |
|
1227 |
} |
|
1228 |
||
1229 |
// The padded average also maintains a deviation from the average; |
|
1230 |
// we use this to see how good of an estimate we have of what survived. |
|
1231 |
// We're trying to pad the survivor size as little as possible without |
|
1232 |
// overflowing the survivor spaces. |
|
1233 |
size_t target_size = align_size_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
|
1234 |
_space_alignment); |
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
1235 |
target_size = MAX2(target_size, _space_alignment); |
1 | 1236 |
|
1237 |
if (target_size > survivor_limit) { |
|
1238 |
// Target size is bigger than we can handle. Let's also reduce |
|
1239 |
// the tenuring threshold. |
|
1240 |
target_size = survivor_limit; |
|
1241 |
decr_tenuring_threshold = true; |
|
1242 |
set_decrement_tenuring_threshold_for_survivor_limit(true); |
|
1243 |
} |
|
1244 |
||
1245 |
// Finally, increment or decrement the tenuring threshold, as decided above. |
|
1246 |
// We test for decrementing first, as we might have hit the target size |
|
1247 |
// limit. |
|
1248 |
if (decr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { |
|
1249 |
if (tenuring_threshold > 1) { |
|
1250 |
tenuring_threshold--; |
|
1251 |
} |
|
1252 |
} else if (incr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { |
|
1253 |
if (tenuring_threshold < MaxTenuringThreshold) { |
|
1254 |
tenuring_threshold++; |
|
1255 |
} |
|
1256 |
} |
|
1257 |
||
1258 |
// We keep a running average of the amount promoted which is used |
|
1259 |
// to decide when we should collect the old generation (when |
|
1260 |
// the amount of old gen free space is less than what we expect to |
|
1261 |
// promote). |
|
1262 |
||
1263 |
if (PrintAdaptiveSizePolicy) { |
|
1264 |
// A little more detail if Verbose is on |
|
1265 |
if (Verbose) { |
|
1266 |
gclog_or_tty->print( " avg_survived: %f" |
|
1267 |
" avg_deviation: %f", |
|
1268 |
_avg_survived->average(), |
|
1269 |
_avg_survived->deviation()); |
|
1270 |
} |
|
1271 |
||
1272 |
gclog_or_tty->print( " avg_survived_padded_avg: %f", |
|
1273 |
_avg_survived->padded_average()); |
|
1274 |
||
1275 |
if (Verbose) { |
|
1276 |
gclog_or_tty->print( " avg_promoted_avg: %f" |
|
1277 |
" avg_promoted_dev: %f", |
|
1278 |
avg_promoted()->average(), |
|
1279 |
avg_promoted()->deviation()); |
|
1280 |
} |
|
1281 |
||
18093
39cccba02d17
8015903: Format issue with -XX:+PrintAdaptiveSizePolicy on JDK8
poonam
parents:
17842
diff
changeset
|
1282 |
gclog_or_tty->print_cr( " avg_promoted_padded_avg: %f" |
1 | 1283 |
" avg_pretenured_padded_avg: %f" |
1284 |
" tenuring_thresh: %d" |
|
1285 |
" target_size: " SIZE_FORMAT, |
|
1286 |
avg_promoted()->padded_average(), |
|
1287 |
_avg_pretenured->padded_average(), |
|
1288 |
tenuring_threshold, target_size); |
|
1289 |
} |
|
1290 |
||
1291 |
set_survivor_size(target_size); |
|
1292 |
||
1293 |
return tenuring_threshold; |
|
1294 |
} |
|
1295 |
||
1296 |
void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow, |
|
1297 |
size_t survived, |
|
1298 |
size_t promoted) { |
|
1299 |
// Update averages |
|
1300 |
if (!is_survivor_overflow) { |
|
1301 |
// Keep running averages on how much survived |
|
1302 |
_avg_survived->sample(survived); |
|
1303 |
} else { |
|
1304 |
size_t survived_guess = survived + promoted; |
|
1305 |
_avg_survived->sample(survived_guess); |
|
1306 |
} |
|
1307 |
avg_promoted()->sample(promoted + _avg_pretenured->padded_average()); |
|
1308 |
||
1309 |
if (PrintAdaptiveSizePolicy) { |
|
18093
39cccba02d17
8015903: Format issue with -XX:+PrintAdaptiveSizePolicy on JDK8
poonam
parents:
17842
diff
changeset
|
1310 |
gclog_or_tty->print_cr( |
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
17393
diff
changeset
|
1311 |
"AdaptiveSizePolicy::update_averages:" |
1 | 1312 |
" survived: " SIZE_FORMAT |
1313 |
" promoted: " SIZE_FORMAT |
|
1314 |
" overflow: %s", |
|
1315 |
survived, promoted, is_survivor_overflow ? "true" : "false"); |
|
1316 |
} |
|
1317 |
} |
|
1318 |
||
1319 |
bool PSAdaptiveSizePolicy::print_adaptive_size_policy_on(outputStream* st) |
|
1320 |
const { |
|
1321 |
||
1322 |
if (!UseAdaptiveSizePolicy) return false; |
|
1323 |
||
1324 |
return AdaptiveSizePolicy::print_adaptive_size_policy_on( |
|
1325 |
st, |
|
1326 |
PSScavenge::tenuring_threshold()); |
|
1327 |
} |
|
22555
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1328 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1329 |
#ifndef PRODUCT |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1330 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1331 |
void TestOldFreeSpaceCalculation_test() { |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1332 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 20) == 25, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1333 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 50) == 100, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1334 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 60) == 150, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1335 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 75) == 300, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1336 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 20) == 100, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1337 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 50) == 400, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1338 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 60) == 600, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1339 |
assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 75) == 1200, "Calculation of free memory failed"); |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1340 |
} |
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1341 |
|
ea32f6c51d08
8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents:
22551
diff
changeset
|
1342 |
#endif /* !PRODUCT */ |