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