author | goetz |
Thu, 26 Jun 2014 16:05:15 +0200 | |
changeset 25468 | 5331df506290 |
parent 24941 | 4ebbe176a7b1 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
25468
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
24941
diff
changeset
|
2 |
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5035
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5035
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5035
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" |
|
27 |
#include "gc_implementation/shared/gcStats.hpp" |
|
28 |
#include "memory/defNewGeneration.hpp" |
|
29 |
#include "memory/genCollectedHeap.hpp" |
|
30 |
#include "runtime/thread.hpp" |
|
25468
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
24941
diff
changeset
|
31 |
|
1 | 32 |
elapsedTimer CMSAdaptiveSizePolicy::_concurrent_timer; |
33 |
elapsedTimer CMSAdaptiveSizePolicy::_STW_timer; |
|
34 |
||
35 |
// Defined if the granularity of the time measurements is potentially too large. |
|
36 |
#define CLOCK_GRANULARITY_TOO_LARGE |
|
37 |
||
38 |
CMSAdaptiveSizePolicy::CMSAdaptiveSizePolicy(size_t init_eden_size, |
|
39 |
size_t init_promo_size, |
|
40 |
size_t init_survivor_size, |
|
41 |
double max_gc_minor_pause_sec, |
|
42 |
double max_gc_pause_sec, |
|
43 |
uint gc_cost_ratio) : |
|
44 |
AdaptiveSizePolicy(init_eden_size, |
|
45 |
init_promo_size, |
|
46 |
init_survivor_size, |
|
47 |
max_gc_pause_sec, |
|
48 |
gc_cost_ratio) { |
|
49 |
||
50 |
clear_internal_time_intervals(); |
|
51 |
||
52 |
_processor_count = os::active_processor_count(); |
|
53 |
||
5035 | 54 |
if (CMSConcurrentMTEnabled && (ConcGCThreads > 1)) { |
1 | 55 |
assert(_processor_count > 0, "Processor count is suspect"); |
5035 | 56 |
_concurrent_processor_count = MIN2((uint) ConcGCThreads, |
1 | 57 |
(uint) _processor_count); |
58 |
} else { |
|
59 |
_concurrent_processor_count = 1; |
|
60 |
} |
|
61 |
||
62 |
_avg_concurrent_time = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
63 |
_avg_concurrent_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
64 |
_avg_concurrent_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
65 |
||
66 |
_avg_initial_pause = new AdaptivePaddedAverage(AdaptiveTimeWeight, |
|
67 |
PausePadding); |
|
68 |
_avg_remark_pause = new AdaptivePaddedAverage(AdaptiveTimeWeight, |
|
69 |
PausePadding); |
|
70 |
||
71 |
_avg_cms_STW_time = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
72 |
_avg_cms_STW_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
73 |
||
74 |
_avg_cms_free = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
75 |
_avg_cms_free_at_sweep = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
76 |
_avg_cms_promo = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
77 |
||
78 |
// Mark-sweep-compact |
|
79 |
_avg_msc_pause = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
80 |
_avg_msc_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
81 |
_avg_msc_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
82 |
||
83 |
// Mark-sweep |
|
84 |
_avg_ms_pause = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
85 |
_avg_ms_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
86 |
_avg_ms_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); |
|
87 |
||
88 |
// Variables that estimate pause times as a function of generation |
|
89 |
// size. |
|
90 |
_remark_pause_old_estimator = |
|
91 |
new LinearLeastSquareFit(AdaptiveSizePolicyWeight); |
|
92 |
_initial_pause_old_estimator = |
|
93 |
new LinearLeastSquareFit(AdaptiveSizePolicyWeight); |
|
94 |
_remark_pause_young_estimator = |
|
95 |
new LinearLeastSquareFit(AdaptiveSizePolicyWeight); |
|
96 |
_initial_pause_young_estimator = |
|
97 |
new LinearLeastSquareFit(AdaptiveSizePolicyWeight); |
|
98 |
||
99 |
// Alignment comes from that used in ReservedSpace. |
|
100 |
_generation_alignment = os::vm_allocation_granularity(); |
|
101 |
||
102 |
// Start the concurrent timer here so that the first |
|
103 |
// concurrent_phases_begin() measures a finite mutator |
|
104 |
// time. A finite mutator time is used to determine |
|
105 |
// if a concurrent collection has been started. If this |
|
106 |
// proves to be a problem, use some explicit flag to |
|
107 |
// signal that a concurrent collection has been started. |
|
108 |
_concurrent_timer.start(); |
|
109 |
_STW_timer.start(); |
|
110 |
} |
|
111 |
||
112 |
double CMSAdaptiveSizePolicy::concurrent_processor_fraction() { |
|
113 |
// For now assume no other daemon threads are taking alway |
|
114 |
// cpu's from the application. |
|
115 |
return ((double) _concurrent_processor_count / (double) _processor_count); |
|
116 |
} |
|
117 |
||
118 |
double CMSAdaptiveSizePolicy::concurrent_collection_cost( |
|
119 |
double interval_in_seconds) { |
|
120 |
// When the precleaning and sweeping phases use multiple |
|
121 |
// threads, change one_processor_fraction to |
|
122 |
// concurrent_processor_fraction(). |
|
123 |
double one_processor_fraction = 1.0 / ((double) processor_count()); |
|
124 |
double concurrent_cost = |
|
125 |
collection_cost(_latest_cms_concurrent_marking_time_secs, |
|
126 |
interval_in_seconds) * concurrent_processor_fraction() + |
|
127 |
collection_cost(_latest_cms_concurrent_precleaning_time_secs, |
|
128 |
interval_in_seconds) * one_processor_fraction + |
|
129 |
collection_cost(_latest_cms_concurrent_sweeping_time_secs, |
|
130 |
interval_in_seconds) * one_processor_fraction; |
|
131 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
132 |
gclog_or_tty->print_cr( |
|
133 |
"\nCMSAdaptiveSizePolicy::scaled_concurrent_collection_cost(%f) " |
|
134 |
"_latest_cms_concurrent_marking_cost %f " |
|
135 |
"_latest_cms_concurrent_precleaning_cost %f " |
|
136 |
"_latest_cms_concurrent_sweeping_cost %f " |
|
137 |
"concurrent_processor_fraction %f " |
|
138 |
"concurrent_cost %f ", |
|
139 |
interval_in_seconds, |
|
140 |
collection_cost(_latest_cms_concurrent_marking_time_secs, |
|
141 |
interval_in_seconds), |
|
142 |
collection_cost(_latest_cms_concurrent_precleaning_time_secs, |
|
143 |
interval_in_seconds), |
|
144 |
collection_cost(_latest_cms_concurrent_sweeping_time_secs, |
|
145 |
interval_in_seconds), |
|
146 |
concurrent_processor_fraction(), |
|
147 |
concurrent_cost); |
|
148 |
} |
|
149 |
return concurrent_cost; |
|
150 |
} |
|
151 |
||
152 |
double CMSAdaptiveSizePolicy::concurrent_collection_time() { |
|
153 |
double latest_cms_sum_concurrent_phases_time_secs = |
|
154 |
_latest_cms_concurrent_marking_time_secs + |
|
155 |
_latest_cms_concurrent_precleaning_time_secs + |
|
156 |
_latest_cms_concurrent_sweeping_time_secs; |
|
157 |
return latest_cms_sum_concurrent_phases_time_secs; |
|
158 |
} |
|
159 |
||
160 |
double CMSAdaptiveSizePolicy::scaled_concurrent_collection_time() { |
|
161 |
// When the precleaning and sweeping phases use multiple |
|
162 |
// threads, change one_processor_fraction to |
|
163 |
// concurrent_processor_fraction(). |
|
164 |
double one_processor_fraction = 1.0 / ((double) processor_count()); |
|
165 |
double latest_cms_sum_concurrent_phases_time_secs = |
|
166 |
_latest_cms_concurrent_marking_time_secs * concurrent_processor_fraction() + |
|
167 |
_latest_cms_concurrent_precleaning_time_secs * one_processor_fraction + |
|
168 |
_latest_cms_concurrent_sweeping_time_secs * one_processor_fraction ; |
|
169 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
170 |
gclog_or_tty->print_cr( |
|
171 |
"\nCMSAdaptiveSizePolicy::scaled_concurrent_collection_time " |
|
172 |
"_latest_cms_concurrent_marking_time_secs %f " |
|
173 |
"_latest_cms_concurrent_precleaning_time_secs %f " |
|
174 |
"_latest_cms_concurrent_sweeping_time_secs %f " |
|
175 |
"concurrent_processor_fraction %f " |
|
176 |
"latest_cms_sum_concurrent_phases_time_secs %f ", |
|
177 |
_latest_cms_concurrent_marking_time_secs, |
|
178 |
_latest_cms_concurrent_precleaning_time_secs, |
|
179 |
_latest_cms_concurrent_sweeping_time_secs, |
|
180 |
concurrent_processor_fraction(), |
|
181 |
latest_cms_sum_concurrent_phases_time_secs); |
|
182 |
} |
|
183 |
return latest_cms_sum_concurrent_phases_time_secs; |
|
184 |
} |
|
185 |
||
186 |
void CMSAdaptiveSizePolicy::update_minor_pause_old_estimator( |
|
187 |
double minor_pause_in_ms) { |
|
188 |
// Get the equivalent of the free space |
|
189 |
// that is available for promotions in the CMS generation |
|
190 |
// and use that to update _minor_pause_old_estimator |
|
191 |
||
192 |
// Don't implement this until it is needed. A warning is |
|
193 |
// printed if _minor_pause_old_estimator is used. |
|
194 |
} |
|
195 |
||
196 |
void CMSAdaptiveSizePolicy::concurrent_marking_begin() { |
|
197 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
198 |
gclog_or_tty->print(" "); |
|
199 |
gclog_or_tty->stamp(); |
|
200 |
gclog_or_tty->print(": concurrent_marking_begin "); |
|
201 |
} |
|
202 |
// Update the interval time |
|
203 |
_concurrent_timer.stop(); |
|
204 |
_latest_cms_collection_end_to_collection_start_secs = _concurrent_timer.seconds(); |
|
205 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
206 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_marking_begin: " |
|
207 |
"mutator time %f", _latest_cms_collection_end_to_collection_start_secs); |
|
208 |
} |
|
209 |
_concurrent_timer.reset(); |
|
210 |
_concurrent_timer.start(); |
|
211 |
} |
|
212 |
||
213 |
void CMSAdaptiveSizePolicy::concurrent_marking_end() { |
|
214 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
215 |
gclog_or_tty->stamp(); |
|
216 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_marking_end()"); |
|
217 |
} |
|
218 |
||
219 |
_concurrent_timer.stop(); |
|
220 |
_latest_cms_concurrent_marking_time_secs = _concurrent_timer.seconds(); |
|
221 |
||
222 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
223 |
gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_marking_end" |
|
224 |
":concurrent marking time (s) %f", |
|
225 |
_latest_cms_concurrent_marking_time_secs); |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
void CMSAdaptiveSizePolicy::concurrent_precleaning_begin() { |
|
230 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
231 |
gclog_or_tty->stamp(); |
|
232 |
gclog_or_tty->print_cr( |
|
233 |
"CMSAdaptiveSizePolicy::concurrent_precleaning_begin()"); |
|
234 |
} |
|
235 |
_concurrent_timer.reset(); |
|
236 |
_concurrent_timer.start(); |
|
237 |
} |
|
238 |
||
239 |
||
240 |
void CMSAdaptiveSizePolicy::concurrent_precleaning_end() { |
|
241 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
242 |
gclog_or_tty->stamp(); |
|
243 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_precleaning_end()"); |
|
244 |
} |
|
245 |
||
246 |
_concurrent_timer.stop(); |
|
247 |
// May be set again by a second call during the same collection. |
|
248 |
_latest_cms_concurrent_precleaning_time_secs = _concurrent_timer.seconds(); |
|
249 |
||
250 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
251 |
gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_precleaning_end" |
|
252 |
":concurrent precleaning time (s) %f", |
|
253 |
_latest_cms_concurrent_precleaning_time_secs); |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
void CMSAdaptiveSizePolicy::concurrent_sweeping_begin() { |
|
258 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
259 |
gclog_or_tty->stamp(); |
|
260 |
gclog_or_tty->print_cr( |
|
261 |
"CMSAdaptiveSizePolicy::concurrent_sweeping_begin()"); |
|
262 |
} |
|
263 |
_concurrent_timer.reset(); |
|
264 |
_concurrent_timer.start(); |
|
265 |
} |
|
266 |
||
267 |
||
268 |
void CMSAdaptiveSizePolicy::concurrent_sweeping_end() { |
|
269 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
270 |
gclog_or_tty->stamp(); |
|
271 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_sweeping_end()"); |
|
272 |
} |
|
273 |
||
274 |
_concurrent_timer.stop(); |
|
275 |
_latest_cms_concurrent_sweeping_time_secs = _concurrent_timer.seconds(); |
|
276 |
||
277 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
278 |
gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_sweeping_end" |
|
279 |
":concurrent sweeping time (s) %f", |
|
280 |
_latest_cms_concurrent_sweeping_time_secs); |
|
281 |
} |
|
282 |
} |
|
283 |
||
284 |
void CMSAdaptiveSizePolicy::concurrent_phases_end(GCCause::Cause gc_cause, |
|
285 |
size_t cur_eden, |
|
286 |
size_t cur_promo) { |
|
287 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
288 |
gclog_or_tty->print(" "); |
|
289 |
gclog_or_tty->stamp(); |
|
290 |
gclog_or_tty->print(": concurrent_phases_end "); |
|
291 |
} |
|
292 |
||
293 |
// Update the concurrent timer |
|
294 |
_concurrent_timer.stop(); |
|
295 |
||
296 |
if (gc_cause != GCCause::_java_lang_system_gc || |
|
297 |
UseAdaptiveSizePolicyWithSystemGC) { |
|
298 |
||
299 |
avg_cms_free()->sample(cur_promo); |
|
300 |
double latest_cms_sum_concurrent_phases_time_secs = |
|
301 |
concurrent_collection_time(); |
|
302 |
||
303 |
_avg_concurrent_time->sample(latest_cms_sum_concurrent_phases_time_secs); |
|
304 |
||
305 |
// Cost of collection (unit-less) |
|
306 |
||
307 |
// Total interval for collection. May not be valid. Tests |
|
308 |
// below determine whether to use this. |
|
309 |
// |
|
310 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
311 |
gclog_or_tty->print_cr("\nCMSAdaptiveSizePolicy::concurrent_phases_end \n" |
|
312 |
"_latest_cms_reset_end_to_initial_mark_start_secs %f \n" |
|
313 |
"_latest_cms_initial_mark_start_to_end_time_secs %f \n" |
|
314 |
"_latest_cms_remark_start_to_end_time_secs %f \n" |
|
315 |
"_latest_cms_concurrent_marking_time_secs %f \n" |
|
316 |
"_latest_cms_concurrent_precleaning_time_secs %f \n" |
|
317 |
"_latest_cms_concurrent_sweeping_time_secs %f \n" |
|
318 |
"latest_cms_sum_concurrent_phases_time_secs %f \n" |
|
319 |
"_latest_cms_collection_end_to_collection_start_secs %f \n" |
|
320 |
"concurrent_processor_fraction %f", |
|
321 |
_latest_cms_reset_end_to_initial_mark_start_secs, |
|
322 |
_latest_cms_initial_mark_start_to_end_time_secs, |
|
323 |
_latest_cms_remark_start_to_end_time_secs, |
|
324 |
_latest_cms_concurrent_marking_time_secs, |
|
325 |
_latest_cms_concurrent_precleaning_time_secs, |
|
326 |
_latest_cms_concurrent_sweeping_time_secs, |
|
327 |
latest_cms_sum_concurrent_phases_time_secs, |
|
328 |
_latest_cms_collection_end_to_collection_start_secs, |
|
329 |
concurrent_processor_fraction()); |
|
330 |
} |
|
331 |
double interval_in_seconds = |
|
332 |
_latest_cms_initial_mark_start_to_end_time_secs + |
|
333 |
_latest_cms_remark_start_to_end_time_secs + |
|
334 |
latest_cms_sum_concurrent_phases_time_secs + |
|
335 |
_latest_cms_collection_end_to_collection_start_secs; |
|
336 |
assert(interval_in_seconds >= 0.0, |
|
337 |
"Bad interval between cms collections"); |
|
338 |
||
339 |
// Sample for performance counter |
|
340 |
avg_concurrent_interval()->sample(interval_in_seconds); |
|
341 |
||
342 |
// STW costs (initial and remark pauses) |
|
343 |
// Cost of collection (unit-less) |
|
344 |
assert(_latest_cms_initial_mark_start_to_end_time_secs >= 0.0, |
|
345 |
"Bad initial mark pause"); |
|
346 |
assert(_latest_cms_remark_start_to_end_time_secs >= 0.0, |
|
347 |
"Bad remark pause"); |
|
348 |
double STW_time_in_seconds = |
|
349 |
_latest_cms_initial_mark_start_to_end_time_secs + |
|
350 |
_latest_cms_remark_start_to_end_time_secs; |
|
351 |
double STW_collection_cost = 0.0; |
|
352 |
if (interval_in_seconds > 0.0) { |
|
353 |
// cost for the STW phases of the concurrent collection. |
|
354 |
STW_collection_cost = STW_time_in_seconds / interval_in_seconds; |
|
355 |
avg_cms_STW_gc_cost()->sample(STW_collection_cost); |
|
356 |
} |
|
357 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
358 |
gclog_or_tty->print("cmsAdaptiveSizePolicy::STW_collection_end: " |
|
359 |
"STW gc cost: %f average: %f", STW_collection_cost, |
|
360 |
avg_cms_STW_gc_cost()->average()); |
|
361 |
gclog_or_tty->print_cr(" STW pause: %f (ms) STW period %f (ms)", |
|
362 |
(double) STW_time_in_seconds * MILLIUNITS, |
|
363 |
(double) interval_in_seconds * MILLIUNITS); |
|
364 |
} |
|
365 |
||
366 |
double concurrent_cost = 0.0; |
|
367 |
if (latest_cms_sum_concurrent_phases_time_secs > 0.0) { |
|
368 |
concurrent_cost = concurrent_collection_cost(interval_in_seconds); |
|
369 |
||
370 |
avg_concurrent_gc_cost()->sample(concurrent_cost); |
|
371 |
// Average this ms cost into all the other types gc costs |
|
372 |
||
373 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
374 |
gclog_or_tty->print("cmsAdaptiveSizePolicy::concurrent_phases_end: " |
|
375 |
"concurrent gc cost: %f average: %f", |
|
376 |
concurrent_cost, |
|
377 |
_avg_concurrent_gc_cost->average()); |
|
378 |
gclog_or_tty->print_cr(" concurrent time: %f (ms) cms period %f (ms)" |
|
379 |
" processor fraction: %f", |
|
380 |
latest_cms_sum_concurrent_phases_time_secs * MILLIUNITS, |
|
381 |
interval_in_seconds * MILLIUNITS, |
|
382 |
concurrent_processor_fraction()); |
|
383 |
} |
|
384 |
} |
|
385 |
double total_collection_cost = STW_collection_cost + concurrent_cost; |
|
386 |
avg_major_gc_cost()->sample(total_collection_cost); |
|
387 |
||
388 |
// Gather information for estimating future behavior |
|
389 |
double initial_pause_in_ms = _latest_cms_initial_mark_start_to_end_time_secs * MILLIUNITS; |
|
390 |
double remark_pause_in_ms = _latest_cms_remark_start_to_end_time_secs * MILLIUNITS; |
|
391 |
||
392 |
double cur_promo_size_in_mbytes = ((double)cur_promo)/((double)M); |
|
393 |
initial_pause_old_estimator()->update(cur_promo_size_in_mbytes, |
|
394 |
initial_pause_in_ms); |
|
395 |
remark_pause_old_estimator()->update(cur_promo_size_in_mbytes, |
|
396 |
remark_pause_in_ms); |
|
397 |
major_collection_estimator()->update(cur_promo_size_in_mbytes, |
|
398 |
total_collection_cost); |
|
399 |
||
400 |
// This estimate uses the average eden size. It could also |
|
401 |
// have used the latest eden size. Which is better? |
|
402 |
double cur_eden_size_in_mbytes = ((double)cur_eden)/((double) M); |
|
403 |
initial_pause_young_estimator()->update(cur_eden_size_in_mbytes, |
|
404 |
initial_pause_in_ms); |
|
405 |
remark_pause_young_estimator()->update(cur_eden_size_in_mbytes, |
|
406 |
remark_pause_in_ms); |
|
407 |
} |
|
408 |
||
409 |
clear_internal_time_intervals(); |
|
410 |
||
411 |
set_first_after_collection(); |
|
412 |
||
413 |
// The concurrent phases keeps track of it's own mutator interval |
|
414 |
// with this timer. This allows the stop-the-world phase to |
|
415 |
// be included in the mutator time so that the stop-the-world time |
|
416 |
// is not double counted. Reset and start it. |
|
417 |
_concurrent_timer.reset(); |
|
418 |
_concurrent_timer.start(); |
|
419 |
||
420 |
// The mutator time between STW phases does not include the |
|
421 |
// concurrent collection time. |
|
422 |
_STW_timer.reset(); |
|
423 |
_STW_timer.start(); |
|
424 |
} |
|
425 |
||
426 |
void CMSAdaptiveSizePolicy::checkpoint_roots_initial_begin() { |
|
427 |
// Update the interval time |
|
428 |
_STW_timer.stop(); |
|
429 |
_latest_cms_reset_end_to_initial_mark_start_secs = _STW_timer.seconds(); |
|
430 |
// Reset for the initial mark |
|
431 |
_STW_timer.reset(); |
|
432 |
_STW_timer.start(); |
|
433 |
} |
|
434 |
||
435 |
void CMSAdaptiveSizePolicy::checkpoint_roots_initial_end( |
|
436 |
GCCause::Cause gc_cause) { |
|
437 |
_STW_timer.stop(); |
|
438 |
||
439 |
if (gc_cause != GCCause::_java_lang_system_gc || |
|
440 |
UseAdaptiveSizePolicyWithSystemGC) { |
|
441 |
_latest_cms_initial_mark_start_to_end_time_secs = _STW_timer.seconds(); |
|
442 |
avg_initial_pause()->sample(_latest_cms_initial_mark_start_to_end_time_secs); |
|
443 |
||
444 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
445 |
gclog_or_tty->print( |
|
446 |
"cmsAdaptiveSizePolicy::checkpoint_roots_initial_end: " |
|
447 |
"initial pause: %f ", _latest_cms_initial_mark_start_to_end_time_secs); |
|
448 |
} |
|
449 |
} |
|
450 |
||
451 |
_STW_timer.reset(); |
|
452 |
_STW_timer.start(); |
|
453 |
} |
|
454 |
||
455 |
void CMSAdaptiveSizePolicy::checkpoint_roots_final_begin() { |
|
456 |
_STW_timer.stop(); |
|
457 |
_latest_cms_initial_mark_end_to_remark_start_secs = _STW_timer.seconds(); |
|
22551 | 458 |
// Start accumulating time for the remark in the STW timer. |
1 | 459 |
_STW_timer.reset(); |
460 |
_STW_timer.start(); |
|
461 |
} |
|
462 |
||
463 |
void CMSAdaptiveSizePolicy::checkpoint_roots_final_end( |
|
464 |
GCCause::Cause gc_cause) { |
|
465 |
_STW_timer.stop(); |
|
466 |
if (gc_cause != GCCause::_java_lang_system_gc || |
|
467 |
UseAdaptiveSizePolicyWithSystemGC) { |
|
468 |
// Total initial mark pause + remark pause. |
|
469 |
_latest_cms_remark_start_to_end_time_secs = _STW_timer.seconds(); |
|
470 |
double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs + |
|
471 |
_latest_cms_remark_start_to_end_time_secs; |
|
472 |
double STW_time_in_ms = STW_time_in_seconds * MILLIUNITS; |
|
473 |
||
474 |
avg_remark_pause()->sample(_latest_cms_remark_start_to_end_time_secs); |
|
475 |
||
476 |
// Sample total for initial mark + remark |
|
477 |
avg_cms_STW_time()->sample(STW_time_in_seconds); |
|
478 |
||
479 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
480 |
gclog_or_tty->print("cmsAdaptiveSizePolicy::checkpoint_roots_final_end: " |
|
481 |
"remark pause: %f", _latest_cms_remark_start_to_end_time_secs); |
|
482 |
} |
|
483 |
||
484 |
} |
|
485 |
// Don't start the STW times here because the concurrent |
|
486 |
// sweep and reset has not happened. |
|
487 |
// Keep the old comment above in case I don't understand |
|
488 |
// what is going on but now |
|
489 |
// Start the STW timer because it is used by ms_collection_begin() |
|
490 |
// and ms_collection_end() to get the sweep time if a MS is being |
|
491 |
// done in the foreground. |
|
492 |
_STW_timer.reset(); |
|
493 |
_STW_timer.start(); |
|
494 |
} |
|
495 |
||
496 |
void CMSAdaptiveSizePolicy::msc_collection_begin() { |
|
497 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
498 |
gclog_or_tty->print(" "); |
|
499 |
gclog_or_tty->stamp(); |
|
500 |
gclog_or_tty->print(": msc_collection_begin "); |
|
501 |
} |
|
502 |
_STW_timer.stop(); |
|
503 |
_latest_cms_msc_end_to_msc_start_time_secs = _STW_timer.seconds(); |
|
504 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
505 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::msc_collection_begin: " |
|
506 |
"mutator time %f", |
|
507 |
_latest_cms_msc_end_to_msc_start_time_secs); |
|
508 |
} |
|
509 |
avg_msc_interval()->sample(_latest_cms_msc_end_to_msc_start_time_secs); |
|
510 |
_STW_timer.reset(); |
|
511 |
_STW_timer.start(); |
|
512 |
} |
|
513 |
||
514 |
void CMSAdaptiveSizePolicy::msc_collection_end(GCCause::Cause gc_cause) { |
|
515 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
516 |
gclog_or_tty->print(" "); |
|
517 |
gclog_or_tty->stamp(); |
|
518 |
gclog_or_tty->print(": msc_collection_end "); |
|
519 |
} |
|
520 |
_STW_timer.stop(); |
|
521 |
if (gc_cause != GCCause::_java_lang_system_gc || |
|
522 |
UseAdaptiveSizePolicyWithSystemGC) { |
|
523 |
double msc_pause_in_seconds = _STW_timer.seconds(); |
|
524 |
if ((_latest_cms_msc_end_to_msc_start_time_secs > 0.0) && |
|
525 |
(msc_pause_in_seconds > 0.0)) { |
|
526 |
avg_msc_pause()->sample(msc_pause_in_seconds); |
|
527 |
double mutator_time_in_seconds = 0.0; |
|
528 |
if (_latest_cms_collection_end_to_collection_start_secs == 0.0) { |
|
22551 | 529 |
// This assertion may fail because of time stamp granularity. |
530 |
// Comment it out and investigate it at a later time. The large |
|
1 | 531 |
// time stamp granularity occurs on some older linux systems. |
532 |
#ifndef CLOCK_GRANULARITY_TOO_LARGE |
|
533 |
assert((_latest_cms_concurrent_marking_time_secs == 0.0) && |
|
534 |
(_latest_cms_concurrent_precleaning_time_secs == 0.0) && |
|
535 |
(_latest_cms_concurrent_sweeping_time_secs == 0.0), |
|
536 |
"There should not be any concurrent time"); |
|
537 |
#endif |
|
538 |
// A concurrent collection did not start. Mutator time |
|
539 |
// between collections comes from the STW MSC timer. |
|
540 |
mutator_time_in_seconds = _latest_cms_msc_end_to_msc_start_time_secs; |
|
541 |
} else { |
|
542 |
// The concurrent collection did start so count the mutator |
|
543 |
// time to the start of the concurrent collection. In this |
|
544 |
// case the _latest_cms_msc_end_to_msc_start_time_secs measures |
|
545 |
// the time between the initial mark or remark and the |
|
546 |
// start of the MSC. That has no real meaning. |
|
547 |
mutator_time_in_seconds = _latest_cms_collection_end_to_collection_start_secs; |
|
548 |
} |
|
549 |
||
550 |
double latest_cms_sum_concurrent_phases_time_secs = |
|
551 |
concurrent_collection_time(); |
|
552 |
double interval_in_seconds = |
|
553 |
mutator_time_in_seconds + |
|
554 |
_latest_cms_initial_mark_start_to_end_time_secs + |
|
555 |
_latest_cms_remark_start_to_end_time_secs + |
|
556 |
latest_cms_sum_concurrent_phases_time_secs + |
|
557 |
msc_pause_in_seconds; |
|
558 |
||
559 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
560 |
gclog_or_tty->print_cr(" interval_in_seconds %f \n" |
|
561 |
" mutator_time_in_seconds %f \n" |
|
562 |
" _latest_cms_initial_mark_start_to_end_time_secs %f\n" |
|
563 |
" _latest_cms_remark_start_to_end_time_secs %f\n" |
|
564 |
" latest_cms_sum_concurrent_phases_time_secs %f\n" |
|
565 |
" msc_pause_in_seconds %f\n", |
|
566 |
interval_in_seconds, |
|
567 |
mutator_time_in_seconds, |
|
568 |
_latest_cms_initial_mark_start_to_end_time_secs, |
|
569 |
_latest_cms_remark_start_to_end_time_secs, |
|
570 |
latest_cms_sum_concurrent_phases_time_secs, |
|
571 |
msc_pause_in_seconds); |
|
572 |
} |
|
573 |
||
574 |
// The concurrent cost is wasted cost but it should be |
|
575 |
// included. |
|
576 |
double concurrent_cost = concurrent_collection_cost(interval_in_seconds); |
|
577 |
||
578 |
// Initial mark and remark, also wasted. |
|
579 |
double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs + |
|
580 |
_latest_cms_remark_start_to_end_time_secs; |
|
581 |
double STW_collection_cost = |
|
582 |
collection_cost(STW_time_in_seconds, interval_in_seconds) + |
|
583 |
concurrent_cost; |
|
584 |
||
585 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
586 |
gclog_or_tty->print_cr(" msc_collection_end:\n" |
|
587 |
"_latest_cms_collection_end_to_collection_start_secs %f\n" |
|
588 |
"_latest_cms_msc_end_to_msc_start_time_secs %f\n" |
|
589 |
"_latest_cms_initial_mark_start_to_end_time_secs %f\n" |
|
590 |
"_latest_cms_remark_start_to_end_time_secs %f\n" |
|
591 |
"latest_cms_sum_concurrent_phases_time_secs %f\n", |
|
592 |
_latest_cms_collection_end_to_collection_start_secs, |
|
593 |
_latest_cms_msc_end_to_msc_start_time_secs, |
|
594 |
_latest_cms_initial_mark_start_to_end_time_secs, |
|
595 |
_latest_cms_remark_start_to_end_time_secs, |
|
596 |
latest_cms_sum_concurrent_phases_time_secs); |
|
597 |
||
598 |
gclog_or_tty->print_cr(" msc_collection_end: \n" |
|
599 |
"latest_cms_sum_concurrent_phases_time_secs %f\n" |
|
600 |
"STW_time_in_seconds %f\n" |
|
601 |
"msc_pause_in_seconds %f\n", |
|
602 |
latest_cms_sum_concurrent_phases_time_secs, |
|
603 |
STW_time_in_seconds, |
|
604 |
msc_pause_in_seconds); |
|
605 |
} |
|
606 |
||
607 |
double cost = concurrent_cost + STW_collection_cost + |
|
608 |
collection_cost(msc_pause_in_seconds, interval_in_seconds); |
|
609 |
||
610 |
_avg_msc_gc_cost->sample(cost); |
|
611 |
||
612 |
// Average this ms cost into all the other types gc costs |
|
613 |
avg_major_gc_cost()->sample(cost); |
|
614 |
||
615 |
// Sample for performance counter |
|
616 |
_avg_msc_interval->sample(interval_in_seconds); |
|
617 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
618 |
gclog_or_tty->print("cmsAdaptiveSizePolicy::msc_collection_end: " |
|
619 |
"MSC gc cost: %f average: %f", cost, |
|
620 |
_avg_msc_gc_cost->average()); |
|
621 |
||
622 |
double msc_pause_in_ms = msc_pause_in_seconds * MILLIUNITS; |
|
623 |
gclog_or_tty->print_cr(" MSC pause: %f (ms) MSC period %f (ms)", |
|
624 |
msc_pause_in_ms, (double) interval_in_seconds * MILLIUNITS); |
|
625 |
} |
|
626 |
} |
|
627 |
} |
|
628 |
||
629 |
clear_internal_time_intervals(); |
|
630 |
||
631 |
// Can this call be put into the epilogue? |
|
632 |
set_first_after_collection(); |
|
633 |
||
634 |
// The concurrent phases keeps track of it's own mutator interval |
|
635 |
// with this timer. This allows the stop-the-world phase to |
|
636 |
// be included in the mutator time so that the stop-the-world time |
|
637 |
// is not double counted. Reset and start it. |
|
638 |
_concurrent_timer.stop(); |
|
639 |
_concurrent_timer.reset(); |
|
640 |
_concurrent_timer.start(); |
|
641 |
||
642 |
_STW_timer.reset(); |
|
643 |
_STW_timer.start(); |
|
644 |
} |
|
645 |
||
646 |
void CMSAdaptiveSizePolicy::ms_collection_begin() { |
|
647 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
648 |
gclog_or_tty->print(" "); |
|
649 |
gclog_or_tty->stamp(); |
|
650 |
gclog_or_tty->print(": ms_collection_begin "); |
|
651 |
} |
|
652 |
_STW_timer.stop(); |
|
653 |
_latest_cms_ms_end_to_ms_start = _STW_timer.seconds(); |
|
654 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
655 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::ms_collection_begin: " |
|
656 |
"mutator time %f", |
|
657 |
_latest_cms_ms_end_to_ms_start); |
|
658 |
} |
|
659 |
avg_ms_interval()->sample(_STW_timer.seconds()); |
|
660 |
_STW_timer.reset(); |
|
661 |
_STW_timer.start(); |
|
662 |
} |
|
663 |
||
664 |
void CMSAdaptiveSizePolicy::ms_collection_end(GCCause::Cause gc_cause) { |
|
665 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
666 |
gclog_or_tty->print(" "); |
|
667 |
gclog_or_tty->stamp(); |
|
668 |
gclog_or_tty->print(": ms_collection_end "); |
|
669 |
} |
|
670 |
_STW_timer.stop(); |
|
671 |
if (gc_cause != GCCause::_java_lang_system_gc || |
|
672 |
UseAdaptiveSizePolicyWithSystemGC) { |
|
673 |
// The MS collection is a foreground collection that does all |
|
674 |
// the parts of a mostly concurrent collection. |
|
675 |
// |
|
676 |
// For this collection include the cost of the |
|
677 |
// initial mark |
|
678 |
// remark |
|
679 |
// all concurrent time (scaled down by the |
|
680 |
// concurrent_processor_fraction). Some |
|
681 |
// may be zero if the baton was passed before |
|
682 |
// it was reached. |
|
683 |
// concurrent marking |
|
684 |
// sweeping |
|
685 |
// resetting |
|
686 |
// STW after baton was passed (STW_in_foreground_in_seconds) |
|
687 |
double STW_in_foreground_in_seconds = _STW_timer.seconds(); |
|
688 |
||
689 |
double latest_cms_sum_concurrent_phases_time_secs = |
|
690 |
concurrent_collection_time(); |
|
691 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
22775 | 692 |
gclog_or_tty->print_cr("\nCMSAdaptiveSizePolicy::ms_collection_end " |
1 | 693 |
"STW_in_foreground_in_seconds %f " |
694 |
"_latest_cms_initial_mark_start_to_end_time_secs %f " |
|
695 |
"_latest_cms_remark_start_to_end_time_secs %f " |
|
696 |
"latest_cms_sum_concurrent_phases_time_secs %f " |
|
697 |
"_latest_cms_ms_marking_start_to_end_time_secs %f " |
|
698 |
"_latest_cms_ms_end_to_ms_start %f", |
|
699 |
STW_in_foreground_in_seconds, |
|
700 |
_latest_cms_initial_mark_start_to_end_time_secs, |
|
701 |
_latest_cms_remark_start_to_end_time_secs, |
|
702 |
latest_cms_sum_concurrent_phases_time_secs, |
|
703 |
_latest_cms_ms_marking_start_to_end_time_secs, |
|
704 |
_latest_cms_ms_end_to_ms_start); |
|
705 |
} |
|
706 |
||
707 |
double STW_marking_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs + |
|
708 |
_latest_cms_remark_start_to_end_time_secs; |
|
709 |
#ifndef CLOCK_GRANULARITY_TOO_LARGE |
|
710 |
assert(_latest_cms_ms_marking_start_to_end_time_secs == 0.0 || |
|
711 |
latest_cms_sum_concurrent_phases_time_secs == 0.0, |
|
712 |
"marking done twice?"); |
|
713 |
#endif |
|
714 |
double ms_time_in_seconds = STW_marking_in_seconds + |
|
715 |
STW_in_foreground_in_seconds + |
|
716 |
_latest_cms_ms_marking_start_to_end_time_secs + |
|
717 |
scaled_concurrent_collection_time(); |
|
718 |
avg_ms_pause()->sample(ms_time_in_seconds); |
|
719 |
// Use the STW costs from the initial mark and remark plus |
|
720 |
// the cost of the concurrent phase to calculate a |
|
721 |
// collection cost. |
|
722 |
double cost = 0.0; |
|
723 |
if ((_latest_cms_ms_end_to_ms_start > 0.0) && |
|
724 |
(ms_time_in_seconds > 0.0)) { |
|
725 |
double interval_in_seconds = |
|
726 |
_latest_cms_ms_end_to_ms_start + ms_time_in_seconds; |
|
727 |
||
728 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
729 |
gclog_or_tty->print_cr("\n ms_time_in_seconds %f " |
|
730 |
"latest_cms_sum_concurrent_phases_time_secs %f " |
|
731 |
"interval_in_seconds %f", |
|
732 |
ms_time_in_seconds, |
|
733 |
latest_cms_sum_concurrent_phases_time_secs, |
|
734 |
interval_in_seconds); |
|
735 |
} |
|
736 |
||
737 |
cost = collection_cost(ms_time_in_seconds, interval_in_seconds); |
|
738 |
||
739 |
_avg_ms_gc_cost->sample(cost); |
|
740 |
// Average this ms cost into all the other types gc costs |
|
741 |
avg_major_gc_cost()->sample(cost); |
|
742 |
||
743 |
// Sample for performance counter |
|
744 |
_avg_ms_interval->sample(interval_in_seconds); |
|
745 |
} |
|
746 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
747 |
gclog_or_tty->print("cmsAdaptiveSizePolicy::ms_collection_end: " |
|
748 |
"MS gc cost: %f average: %f", cost, _avg_ms_gc_cost->average()); |
|
749 |
||
750 |
double ms_time_in_ms = ms_time_in_seconds * MILLIUNITS; |
|
751 |
gclog_or_tty->print_cr(" MS pause: %f (ms) MS period %f (ms)", |
|
752 |
ms_time_in_ms, |
|
753 |
_latest_cms_ms_end_to_ms_start * MILLIUNITS); |
|
754 |
} |
|
755 |
} |
|
756 |
||
757 |
// Consider putting this code (here to end) into a |
|
758 |
// method for convenience. |
|
759 |
clear_internal_time_intervals(); |
|
760 |
||
761 |
set_first_after_collection(); |
|
762 |
||
763 |
// The concurrent phases keeps track of it's own mutator interval |
|
764 |
// with this timer. This allows the stop-the-world phase to |
|
765 |
// be included in the mutator time so that the stop-the-world time |
|
766 |
// is not double counted. Reset and start it. |
|
767 |
_concurrent_timer.stop(); |
|
768 |
_concurrent_timer.reset(); |
|
769 |
_concurrent_timer.start(); |
|
770 |
||
771 |
_STW_timer.reset(); |
|
772 |
_STW_timer.start(); |
|
773 |
} |
|
774 |
||
775 |
void CMSAdaptiveSizePolicy::clear_internal_time_intervals() { |
|
776 |
_latest_cms_reset_end_to_initial_mark_start_secs = 0.0; |
|
777 |
_latest_cms_initial_mark_end_to_remark_start_secs = 0.0; |
|
778 |
_latest_cms_collection_end_to_collection_start_secs = 0.0; |
|
779 |
_latest_cms_concurrent_marking_time_secs = 0.0; |
|
780 |
_latest_cms_concurrent_precleaning_time_secs = 0.0; |
|
781 |
_latest_cms_concurrent_sweeping_time_secs = 0.0; |
|
782 |
_latest_cms_msc_end_to_msc_start_time_secs = 0.0; |
|
783 |
_latest_cms_ms_end_to_ms_start = 0.0; |
|
784 |
_latest_cms_remark_start_to_end_time_secs = 0.0; |
|
785 |
_latest_cms_initial_mark_start_to_end_time_secs = 0.0; |
|
786 |
_latest_cms_ms_marking_start_to_end_time_secs = 0.0; |
|
787 |
} |
|
788 |
||
789 |
void CMSAdaptiveSizePolicy::clear_generation_free_space_flags() { |
|
790 |
AdaptiveSizePolicy::clear_generation_free_space_flags(); |
|
791 |
||
792 |
set_change_young_gen_for_maj_pauses(0); |
|
793 |
} |
|
794 |
||
795 |
void CMSAdaptiveSizePolicy::concurrent_phases_resume() { |
|
796 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
797 |
gclog_or_tty->stamp(); |
|
798 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_phases_resume()"); |
|
799 |
} |
|
800 |
_concurrent_timer.start(); |
|
801 |
} |
|
802 |
||
803 |
double CMSAdaptiveSizePolicy::time_since_major_gc() const { |
|
804 |
_concurrent_timer.stop(); |
|
805 |
double time_since_cms_gc = _concurrent_timer.seconds(); |
|
806 |
_concurrent_timer.start(); |
|
807 |
_STW_timer.stop(); |
|
808 |
double time_since_STW_gc = _STW_timer.seconds(); |
|
809 |
_STW_timer.start(); |
|
810 |
||
811 |
return MIN2(time_since_cms_gc, time_since_STW_gc); |
|
812 |
} |
|
813 |
||
814 |
double CMSAdaptiveSizePolicy::major_gc_interval_average_for_decay() const { |
|
815 |
double cms_interval = _avg_concurrent_interval->average(); |
|
816 |
double msc_interval = _avg_msc_interval->average(); |
|
817 |
double ms_interval = _avg_ms_interval->average(); |
|
818 |
||
819 |
return MAX3(cms_interval, msc_interval, ms_interval); |
|
820 |
} |
|
821 |
||
822 |
double CMSAdaptiveSizePolicy::cms_gc_cost() const { |
|
823 |
return avg_major_gc_cost()->average(); |
|
824 |
} |
|
825 |
||
826 |
void CMSAdaptiveSizePolicy::ms_collection_marking_begin() { |
|
827 |
_STW_timer.stop(); |
|
22551 | 828 |
// Start accumulating time for the marking in the STW timer. |
1 | 829 |
_STW_timer.reset(); |
830 |
_STW_timer.start(); |
|
831 |
} |
|
832 |
||
833 |
void CMSAdaptiveSizePolicy::ms_collection_marking_end( |
|
834 |
GCCause::Cause gc_cause) { |
|
835 |
_STW_timer.stop(); |
|
836 |
if (gc_cause != GCCause::_java_lang_system_gc || |
|
837 |
UseAdaptiveSizePolicyWithSystemGC) { |
|
838 |
_latest_cms_ms_marking_start_to_end_time_secs = _STW_timer.seconds(); |
|
839 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
840 |
gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::" |
|
841 |
"msc_collection_marking_end: mutator time %f", |
|
842 |
_latest_cms_ms_marking_start_to_end_time_secs); |
|
843 |
} |
|
844 |
} |
|
845 |
_STW_timer.reset(); |
|
846 |
_STW_timer.start(); |
|
847 |
} |
|
848 |
||
849 |
double CMSAdaptiveSizePolicy::gc_cost() const { |
|
850 |
double cms_gen_cost = cms_gc_cost(); |
|
851 |
double result = MIN2(1.0, minor_gc_cost() + cms_gen_cost); |
|
852 |
assert(result >= 0.0, "Both minor and major costs are non-negative"); |
|
853 |
return result; |
|
854 |
} |
|
855 |
||
856 |
// Cost of collection (unit-less) |
|
857 |
double CMSAdaptiveSizePolicy::collection_cost(double pause_in_seconds, |
|
858 |
double interval_in_seconds) { |
|
859 |
// Cost of collection (unit-less) |
|
860 |
double cost = 0.0; |
|
861 |
if ((interval_in_seconds > 0.0) && |
|
862 |
(pause_in_seconds > 0.0)) { |
|
863 |
cost = |
|
864 |
pause_in_seconds / interval_in_seconds; |
|
865 |
} |
|
866 |
return cost; |
|
867 |
} |
|
868 |
||
869 |
size_t CMSAdaptiveSizePolicy::adjust_eden_for_pause_time(size_t cur_eden) { |
|
870 |
size_t change = 0; |
|
871 |
size_t desired_eden = cur_eden; |
|
872 |
||
873 |
// reduce eden size |
|
874 |
change = eden_decrement_aligned_down(cur_eden); |
|
875 |
desired_eden = cur_eden - change; |
|
876 |
||
877 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
878 |
gclog_or_tty->print_cr( |
|
879 |
"CMSAdaptiveSizePolicy::adjust_eden_for_pause_time " |
|
880 |
"adjusting eden for pause time. " |
|
881 |
" starting eden size " SIZE_FORMAT |
|
882 |
" reduced eden size " SIZE_FORMAT |
|
883 |
" eden delta " SIZE_FORMAT, |
|
884 |
cur_eden, desired_eden, change); |
|
885 |
} |
|
886 |
||
887 |
return desired_eden; |
|
888 |
} |
|
889 |
||
890 |
size_t CMSAdaptiveSizePolicy::adjust_eden_for_throughput(size_t cur_eden) { |
|
891 |
||
892 |
size_t desired_eden = cur_eden; |
|
893 |
||
894 |
set_change_young_gen_for_throughput(increase_young_gen_for_througput_true); |
|
895 |
||
896 |
size_t change = eden_increment_aligned_up(cur_eden); |
|
897 |
size_t scaled_change = scale_by_gen_gc_cost(change, minor_gc_cost()); |
|
898 |
||
899 |
if (cur_eden + scaled_change > cur_eden) { |
|
900 |
desired_eden = cur_eden + scaled_change; |
|
901 |
} |
|
902 |
||
903 |
_young_gen_change_for_minor_throughput++; |
|
904 |
||
905 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
906 |
gclog_or_tty->print_cr( |
|
907 |
"CMSAdaptiveSizePolicy::adjust_eden_for_throughput " |
|
908 |
"adjusting eden for throughput. " |
|
909 |
" starting eden size " SIZE_FORMAT |
|
910 |
" increased eden size " SIZE_FORMAT |
|
911 |
" eden delta " SIZE_FORMAT, |
|
912 |
cur_eden, desired_eden, scaled_change); |
|
913 |
} |
|
914 |
||
915 |
return desired_eden; |
|
916 |
} |
|
917 |
||
918 |
size_t CMSAdaptiveSizePolicy::adjust_eden_for_footprint(size_t cur_eden) { |
|
919 |
||
920 |
set_decrease_for_footprint(decrease_young_gen_for_footprint_true); |
|
921 |
||
922 |
size_t change = eden_decrement(cur_eden); |
|
923 |
size_t desired_eden_size = cur_eden - change; |
|
924 |
||
925 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
926 |
gclog_or_tty->print_cr( |
|
927 |
"CMSAdaptiveSizePolicy::adjust_eden_for_footprint " |
|
928 |
"adjusting eden for footprint. " |
|
929 |
" starting eden size " SIZE_FORMAT |
|
930 |
" reduced eden size " SIZE_FORMAT |
|
931 |
" eden delta " SIZE_FORMAT, |
|
932 |
cur_eden, desired_eden_size, change); |
|
933 |
} |
|
934 |
return desired_eden_size; |
|
935 |
} |
|
936 |
||
937 |
// The eden and promo versions should be combined if possible. |
|
938 |
// They are the same except that the sizes of the decrement |
|
939 |
// and increment are different for eden and promo. |
|
940 |
size_t CMSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) { |
|
941 |
size_t delta = eden_decrement(cur_eden); |
|
942 |
return align_size_down(delta, generation_alignment()); |
|
943 |
} |
|
944 |
||
945 |
size_t CMSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) { |
|
946 |
size_t delta = eden_increment(cur_eden); |
|
947 |
return align_size_up(delta, generation_alignment()); |
|
948 |
} |
|
949 |
||
950 |
size_t CMSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) { |
|
951 |
size_t delta = promo_decrement(cur_promo); |
|
952 |
return align_size_down(delta, generation_alignment()); |
|
953 |
} |
|
954 |
||
955 |
size_t CMSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { |
|
956 |
size_t delta = promo_increment(cur_promo); |
|
957 |
return align_size_up(delta, generation_alignment()); |
|
958 |
} |
|
959 |
||
960 |
||
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
13925
diff
changeset
|
961 |
void CMSAdaptiveSizePolicy::compute_eden_space_size(size_t cur_eden, |
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
13925
diff
changeset
|
962 |
size_t max_eden_size) |
1 | 963 |
{ |
964 |
size_t desired_eden_size = cur_eden; |
|
965 |
size_t eden_limit = max_eden_size; |
|
966 |
||
967 |
// Printout input |
|
968 |
if (PrintGC && PrintAdaptiveSizePolicy) { |
|
969 |
gclog_or_tty->print_cr( |
|
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
13925
diff
changeset
|
970 |
"CMSAdaptiveSizePolicy::compute_eden_space_size: " |
1 | 971 |
"cur_eden " SIZE_FORMAT, |
972 |
cur_eden); |
|
973 |
} |
|
974 |
||
975 |
// Used for diagnostics |
|
976 |
clear_generation_free_space_flags(); |
|
977 |
||
978 |
if (_avg_minor_pause->padded_average() > gc_pause_goal_sec()) { |
|
979 |
if (minor_pause_young_estimator()->decrement_will_decrease()) { |
|
980 |
// If the minor pause is too long, shrink the young gen. |
|
981 |
set_change_young_gen_for_min_pauses( |
|
982 |
decrease_young_gen_for_min_pauses_true); |
|
983 |
desired_eden_size = adjust_eden_for_pause_time(desired_eden_size); |
|
984 |
} |
|
985 |
} else if ((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) || |
|
986 |
(avg_initial_pause()->padded_average() > gc_pause_goal_sec())) { |
|
987 |
// The remark or initial pauses are not meeting the goal. Should |
|
988 |
// the generation be shrunk? |
|
989 |
if (get_and_clear_first_after_collection() && |
|
990 |
((avg_remark_pause()->padded_average() > gc_pause_goal_sec() && |
|
991 |
remark_pause_young_estimator()->decrement_will_decrease()) || |
|
992 |
(avg_initial_pause()->padded_average() > gc_pause_goal_sec() && |
|
993 |
initial_pause_young_estimator()->decrement_will_decrease()))) { |
|
994 |
||
995 |
set_change_young_gen_for_maj_pauses( |
|
996 |
decrease_young_gen_for_maj_pauses_true); |
|
997 |
||
998 |
// If the remark or initial pause is too long and this is the |
|
999 |
// first young gen collection after a cms collection, shrink |
|
1000 |
// the young gen. |
|
1001 |
desired_eden_size = adjust_eden_for_pause_time(desired_eden_size); |
|
1002 |
} |
|
1003 |
// If not the first young gen collection after a cms collection, |
|
1004 |
// don't do anything. In this case an adjustment has already |
|
1005 |
// been made and the results of the adjustment has not yet been |
|
1006 |
// measured. |
|
1007 |
} else if ((minor_gc_cost() >= 0.0) && |
|
1008 |
(adjusted_mutator_cost() < _throughput_goal)) { |
|
1009 |
desired_eden_size = adjust_eden_for_throughput(desired_eden_size); |
|
1010 |
} else { |
|
1011 |
desired_eden_size = adjust_eden_for_footprint(desired_eden_size); |
|
1012 |
} |
|
1013 |
||
1014 |
if (PrintGC && PrintAdaptiveSizePolicy) { |
|
1015 |
gclog_or_tty->print_cr( |
|
17842
0d11fa49f81f
8007762: Rename a bunch of methods in size policy across collectors
tamao
parents:
13925
diff
changeset
|
1016 |
"CMSAdaptiveSizePolicy::compute_eden_space_size limits:" |
1 | 1017 |
" desired_eden_size: " SIZE_FORMAT |
1018 |
" old_eden_size: " SIZE_FORMAT, |
|
1019 |
desired_eden_size, cur_eden); |
|
1020 |
} |
|
1021 |
||
1022 |
set_eden_size(desired_eden_size); |
|
1023 |
} |
|
1024 |
||
1025 |
size_t CMSAdaptiveSizePolicy::adjust_promo_for_pause_time(size_t cur_promo) { |
|
1026 |
size_t change = 0; |
|
1027 |
size_t desired_promo = cur_promo; |
|
1028 |
// Move this test up to caller like the adjust_eden_for_pause_time() |
|
1029 |
// call. |
|
1030 |
if ((AdaptiveSizePausePolicy == 0) && |
|
1031 |
((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) || |
|
1032 |
(avg_initial_pause()->padded_average() > gc_pause_goal_sec()))) { |
|
1033 |
set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true); |
|
1034 |
change = promo_decrement_aligned_down(cur_promo); |
|
1035 |
desired_promo = cur_promo - change; |
|
1036 |
} else if ((AdaptiveSizePausePolicy > 0) && |
|
1037 |
(((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) && |
|
1038 |
remark_pause_old_estimator()->decrement_will_decrease()) || |
|
1039 |
((avg_initial_pause()->padded_average() > gc_pause_goal_sec()) && |
|
1040 |
initial_pause_old_estimator()->decrement_will_decrease()))) { |
|
1041 |
set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true); |
|
1042 |
change = promo_decrement_aligned_down(cur_promo); |
|
1043 |
desired_promo = cur_promo - change; |
|
1044 |
} |
|
1045 |
||
1046 |
if ((change != 0) &&PrintAdaptiveSizePolicy && Verbose) { |
|
1047 |
gclog_or_tty->print_cr( |
|
1048 |
"CMSAdaptiveSizePolicy::adjust_promo_for_pause_time " |
|
1049 |
"adjusting promo for pause time. " |
|
1050 |
" starting promo size " SIZE_FORMAT |
|
1051 |
" reduced promo size " SIZE_FORMAT |
|
1052 |
" promo delta " SIZE_FORMAT, |
|
1053 |
cur_promo, desired_promo, change); |
|
1054 |
} |
|
1055 |
||
1056 |
return desired_promo; |
|
1057 |
} |
|
1058 |
||
1059 |
// Try to share this with PS. |
|
1060 |
size_t CMSAdaptiveSizePolicy::scale_by_gen_gc_cost(size_t base_change, |
|
1061 |
double gen_gc_cost) { |
|
1062 |
||
1063 |
// Calculate the change to use for the tenured gen. |
|
1064 |
size_t scaled_change = 0; |
|
1065 |
// Can the increment to the generation be scaled? |
|
1066 |
if (gc_cost() >= 0.0 && gen_gc_cost >= 0.0) { |
|
1067 |
double scale_by_ratio = gen_gc_cost / gc_cost(); |
|
1068 |
scaled_change = |
|
1069 |
(size_t) (scale_by_ratio * (double) base_change); |
|
1070 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
1071 |
gclog_or_tty->print_cr( |
|
1072 |
"Scaled tenured increment: " SIZE_FORMAT " by %f down to " |
|
1073 |
SIZE_FORMAT, |
|
1074 |
base_change, scale_by_ratio, scaled_change); |
|
1075 |
} |
|
1076 |
} else if (gen_gc_cost >= 0.0) { |
|
1077 |
// Scaling is not going to work. If the major gc time is the |
|
1078 |
// larger than the other GC costs, give it a full increment. |
|
1079 |
if (gen_gc_cost >= (gc_cost() - gen_gc_cost)) { |
|
1080 |
scaled_change = base_change; |
|
1081 |
} |
|
1082 |
} else { |
|
1083 |
// Don't expect to get here but it's ok if it does |
|
1084 |
// in the product build since the delta will be 0 |
|
1085 |
// and nothing will change. |
|
1086 |
assert(false, "Unexpected value for gc costs"); |
|
1087 |
} |
|
1088 |
||
1089 |
return scaled_change; |
|
1090 |
} |
|
1091 |
||
1092 |
size_t CMSAdaptiveSizePolicy::adjust_promo_for_throughput(size_t cur_promo) { |
|
1093 |
||
1094 |
size_t desired_promo = cur_promo; |
|
1095 |
||
1096 |
set_change_old_gen_for_throughput(increase_old_gen_for_throughput_true); |
|
1097 |
||
1098 |
size_t change = promo_increment_aligned_up(cur_promo); |
|
1099 |
size_t scaled_change = scale_by_gen_gc_cost(change, major_gc_cost()); |
|
1100 |
||
1101 |
if (cur_promo + scaled_change > cur_promo) { |
|
1102 |
desired_promo = cur_promo + scaled_change; |
|
1103 |
} |
|
1104 |
||
1105 |
_old_gen_change_for_major_throughput++; |
|
1106 |
||
1107 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
1108 |
gclog_or_tty->print_cr( |
|
1109 |
"CMSAdaptiveSizePolicy::adjust_promo_for_throughput " |
|
1110 |
"adjusting promo for throughput. " |
|
1111 |
" starting promo size " SIZE_FORMAT |
|
1112 |
" increased promo size " SIZE_FORMAT |
|
1113 |
" promo delta " SIZE_FORMAT, |
|
1114 |
cur_promo, desired_promo, scaled_change); |
|
1115 |
} |
|
1116 |
||
1117 |
return desired_promo; |
|
1118 |
} |
|
1119 |
||
1120 |
size_t CMSAdaptiveSizePolicy::adjust_promo_for_footprint(size_t cur_promo, |
|
1121 |
size_t cur_eden) { |
|
1122 |
||
1123 |
set_decrease_for_footprint(decrease_young_gen_for_footprint_true); |
|
1124 |
||
1125 |
size_t change = promo_decrement(cur_promo); |
|
1126 |
size_t desired_promo_size = cur_promo - change; |
|
1127 |
||
1128 |
if (PrintAdaptiveSizePolicy && Verbose) { |
|
1129 |
gclog_or_tty->print_cr( |
|
1130 |
"CMSAdaptiveSizePolicy::adjust_promo_for_footprint " |
|
1131 |
"adjusting promo for footprint. " |
|
1132 |
" starting promo size " SIZE_FORMAT |
|
1133 |
" reduced promo size " SIZE_FORMAT |
|
1134 |
" promo delta " SIZE_FORMAT, |
|
1135 |
cur_promo, desired_promo_size, change); |
|
1136 |
} |
|
1137 |
return desired_promo_size; |
|
1138 |
} |
|
1139 |
||
1140 |
void CMSAdaptiveSizePolicy::compute_tenured_generation_free_space( |
|
1141 |
size_t cur_tenured_free, |
|
1142 |
size_t max_tenured_available, |
|
1143 |
size_t cur_eden) { |
|
1144 |
// This can be bad if the desired value grows/shrinks without |
|
1145 |
// any connection to the read free space |
|
1146 |
size_t desired_promo_size = promo_size(); |
|
1147 |
size_t tenured_limit = max_tenured_available; |
|
1148 |
||
1149 |
// Printout input |
|
1150 |
if (PrintGC && PrintAdaptiveSizePolicy) { |
|
1151 |
gclog_or_tty->print_cr( |
|
1152 |
"CMSAdaptiveSizePolicy::compute_tenured_generation_free_space: " |
|
1153 |
"cur_tenured_free " SIZE_FORMAT |
|
1154 |
" max_tenured_available " SIZE_FORMAT, |
|
1155 |
cur_tenured_free, max_tenured_available); |
|
1156 |
} |
|
1157 |
||
1158 |
// Used for diagnostics |
|
1159 |
clear_generation_free_space_flags(); |
|
1160 |
||
1161 |
set_decide_at_full_gc(decide_at_full_gc_true); |
|
1162 |
if (avg_remark_pause()->padded_average() > gc_pause_goal_sec() || |
|
1163 |
avg_initial_pause()->padded_average() > gc_pause_goal_sec()) { |
|
1164 |
desired_promo_size = adjust_promo_for_pause_time(cur_tenured_free); |
|
1165 |
} else if (avg_minor_pause()->padded_average() > gc_pause_goal_sec()) { |
|
1166 |
// Nothing to do since the minor collections are too large and |
|
1167 |
// this method only deals with the cms generation. |
|
1168 |
} else if ((cms_gc_cost() >= 0.0) && |
|
1169 |
(adjusted_mutator_cost() < _throughput_goal)) { |
|
1170 |
desired_promo_size = adjust_promo_for_throughput(cur_tenured_free); |
|
1171 |
} else { |
|
1172 |
desired_promo_size = adjust_promo_for_footprint(cur_tenured_free, |
|
1173 |
cur_eden); |
|
1174 |
} |
|
1175 |
||
1176 |
if (PrintGC && PrintAdaptiveSizePolicy) { |
|
1177 |
gclog_or_tty->print_cr( |
|
1178 |
"CMSAdaptiveSizePolicy::compute_tenured_generation_free_space limits:" |
|
1179 |
" desired_promo_size: " SIZE_FORMAT |
|
1180 |
" old_promo_size: " SIZE_FORMAT, |
|
1181 |
desired_promo_size, cur_tenured_free); |
|
1182 |
} |
|
1183 |
||
1184 |
set_promo_size(desired_promo_size); |
|
1185 |
} |
|
1186 |
||
13925 | 1187 |
uint CMSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( |
1 | 1188 |
bool is_survivor_overflow, |
13925 | 1189 |
uint tenuring_threshold, |
1 | 1190 |
size_t survivor_limit) { |
1191 |
assert(survivor_limit >= generation_alignment(), |
|
1192 |
"survivor_limit too small"); |
|
1193 |
assert((size_t)align_size_down(survivor_limit, generation_alignment()) |
|
1194 |
== survivor_limit, "survivor_limit not aligned"); |
|
1195 |
||
1196 |
// Change UsePSAdaptiveSurvivorSizePolicy -> UseAdaptiveSurvivorSizePolicy? |
|
1197 |
if (!UsePSAdaptiveSurvivorSizePolicy || |
|
1198 |
!young_gen_policy_is_ready()) { |
|
1199 |
return tenuring_threshold; |
|
1200 |
} |
|
1201 |
||
1202 |
// We'll decide whether to increase or decrease the tenuring |
|
1203 |
// threshold based partly on the newly computed survivor size |
|
1204 |
// (if we hit the maximum limit allowed, we'll always choose to |
|
1205 |
// decrement the threshold). |
|
1206 |
bool incr_tenuring_threshold = false; |
|
1207 |
bool decr_tenuring_threshold = false; |
|
1208 |
||
1209 |
set_decrement_tenuring_threshold_for_gc_cost(false); |
|
1210 |
set_increment_tenuring_threshold_for_gc_cost(false); |
|
1211 |
set_decrement_tenuring_threshold_for_survivor_limit(false); |
|
1212 |
||
1213 |
if (!is_survivor_overflow) { |
|
1214 |
// Keep running averages on how much survived |
|
1215 |
||
1216 |
// We use the tenuring threshold to equalize the cost of major |
|
1217 |
// and minor collections. |
|
1218 |
// ThresholdTolerance is used to indicate how sensitive the |
|
22551 | 1219 |
// tenuring threshold is to differences in cost between the |
1 | 1220 |
// collection types. |
1221 |
||
1222 |
// Get the times of interest. This involves a little work, so |
|
1223 |
// we cache the values here. |
|
1224 |
const double major_cost = major_gc_cost(); |
|
1225 |
const double minor_cost = minor_gc_cost(); |
|
1226 |
||
1227 |
if (minor_cost > major_cost * _threshold_tolerance_percent) { |
|
1228 |
// Minor times are getting too long; lower the threshold so |
|
1229 |
// less survives and more is promoted. |
|
1230 |
decr_tenuring_threshold = true; |
|
1231 |
set_decrement_tenuring_threshold_for_gc_cost(true); |
|
1232 |
} else if (major_cost > minor_cost * _threshold_tolerance_percent) { |
|
1233 |
// Major times are too long, so we want less promotion. |
|
1234 |
incr_tenuring_threshold = true; |
|
1235 |
set_increment_tenuring_threshold_for_gc_cost(true); |
|
1236 |
} |
|
1237 |
||
1238 |
} else { |
|
1239 |
// Survivor space overflow occurred, so promoted and survived are |
|
1240 |
// not accurate. We'll make our best guess by combining survived |
|
1241 |
// and promoted and count them as survivors. |
|
1242 |
// |
|
1243 |
// We'll lower the tenuring threshold to see if we can correct |
|
1244 |
// things. Also, set the survivor size conservatively. We're |
|
1245 |
// trying to avoid many overflows from occurring if defnew size |
|
1246 |
// is just too small. |
|
1247 |
||
1248 |
decr_tenuring_threshold = true; |
|
1249 |
} |
|
1250 |
||
1251 |
// The padded average also maintains a deviation from the average; |
|
1252 |
// we use this to see how good of an estimate we have of what survived. |
|
1253 |
// We're trying to pad the survivor size as little as possible without |
|
1254 |
// overflowing the survivor spaces. |
|
1255 |
size_t target_size = align_size_up((size_t)_avg_survived->padded_average(), |
|
1256 |
generation_alignment()); |
|
1257 |
target_size = MAX2(target_size, generation_alignment()); |
|
1258 |
||
1259 |
if (target_size > survivor_limit) { |
|
1260 |
// Target size is bigger than we can handle. Let's also reduce |
|
1261 |
// the tenuring threshold. |
|
1262 |
target_size = survivor_limit; |
|
1263 |
decr_tenuring_threshold = true; |
|
1264 |
set_decrement_tenuring_threshold_for_survivor_limit(true); |
|
1265 |
} |
|
1266 |
||
1267 |
// Finally, increment or decrement the tenuring threshold, as decided above. |
|
1268 |
// We test for decrementing first, as we might have hit the target size |
|
1269 |
// limit. |
|
1270 |
if (decr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { |
|
1271 |
if (tenuring_threshold > 1) { |
|
1272 |
tenuring_threshold--; |
|
1273 |
} |
|
1274 |
} else if (incr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { |
|
1275 |
if (tenuring_threshold < MaxTenuringThreshold) { |
|
1276 |
tenuring_threshold++; |
|
1277 |
} |
|
1278 |
} |
|
1279 |
||
1280 |
// We keep a running average of the amount promoted which is used |
|
1281 |
// to decide when we should collect the old generation (when |
|
1282 |
// the amount of old gen free space is less than what we expect to |
|
1283 |
// promote). |
|
1284 |
||
1285 |
if (PrintAdaptiveSizePolicy) { |
|
1286 |
// A little more detail if Verbose is on |
|
1287 |
GenCollectedHeap* gch = GenCollectedHeap::heap(); |
|
1288 |
if (Verbose) { |
|
1289 |
gclog_or_tty->print( " avg_survived: %f" |
|
1290 |
" avg_deviation: %f", |
|
1291 |
_avg_survived->average(), |
|
1292 |
_avg_survived->deviation()); |
|
1293 |
} |
|
1294 |
||
1295 |
gclog_or_tty->print( " avg_survived_padded_avg: %f", |
|
1296 |
_avg_survived->padded_average()); |
|
1297 |
||
1298 |
if (Verbose) { |
|
1299 |
gclog_or_tty->print( " avg_promoted_avg: %f" |
|
1300 |
" avg_promoted_dev: %f", |
|
1301 |
gch->gc_stats(1)->avg_promoted()->average(), |
|
1302 |
gch->gc_stats(1)->avg_promoted()->deviation()); |
|
1303 |
} |
|
1304 |
||
1305 |
gclog_or_tty->print( " avg_promoted_padded_avg: %f" |
|
1306 |
" avg_pretenured_padded_avg: %f" |
|
13925 | 1307 |
" tenuring_thresh: %u" |
1 | 1308 |
" target_size: " SIZE_FORMAT |
1309 |
" survivor_limit: " SIZE_FORMAT, |
|
1310 |
gch->gc_stats(1)->avg_promoted()->padded_average(), |
|
1311 |
_avg_pretenured->padded_average(), |
|
1312 |
tenuring_threshold, target_size, survivor_limit); |
|
1313 |
gclog_or_tty->cr(); |
|
1314 |
} |
|
1315 |
||
1316 |
set_survivor_size(target_size); |
|
1317 |
||
1318 |
return tenuring_threshold; |
|
1319 |
} |
|
1320 |
||
1321 |
bool CMSAdaptiveSizePolicy::get_and_clear_first_after_collection() { |
|
1322 |
bool result = _first_after_collection; |
|
1323 |
_first_after_collection = false; |
|
1324 |
return result; |
|
1325 |
} |
|
1326 |
||
1327 |
bool CMSAdaptiveSizePolicy::print_adaptive_size_policy_on( |
|
1328 |
outputStream* st) const { |
|
1329 |
||
24941
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
22876
diff
changeset
|
1330 |
if (!UseAdaptiveSizePolicy) { |
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
22876
diff
changeset
|
1331 |
return false; |
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
22876
diff
changeset
|
1332 |
} |
1 | 1333 |
|
1334 |
GenCollectedHeap* gch = GenCollectedHeap::heap(); |
|
24941
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
22876
diff
changeset
|
1335 |
Generation* young = gch->get_gen(0); |
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
22876
diff
changeset
|
1336 |
DefNewGeneration* def_new = young->as_DefNewGeneration(); |
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
22876
diff
changeset
|
1337 |
return AdaptiveSizePolicy::print_adaptive_size_policy_on( |
1 | 1338 |
st, |
1339 |
def_new->tenuring_threshold()); |
|
1340 |
} |