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