1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Wed May 15 11:05:09 2013 +0200 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Wed May 15 10:41:22 2013 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -201,15 +201,232 @@ 1.11 size_t cur_eden, 1.12 size_t max_old_gen_size, 1.13 size_t max_eden_size, 1.14 - bool is_full_gc, 1.15 - GCCause::Cause gc_cause, 1.16 - CollectorPolicy* collector_policy) { 1.17 + bool is_full_gc) { 1.18 + compute_eden_space_size(young_live, 1.19 + eden_live, 1.20 + cur_eden, 1.21 + max_eden_size, 1.22 + is_full_gc); 1.23 + 1.24 + compute_old_gen_free_space(old_live, 1.25 + cur_eden, 1.26 + max_old_gen_size, 1.27 + is_full_gc); 1.28 +} 1.29 + 1.30 +void PSAdaptiveSizePolicy::compute_eden_space_size( 1.31 + size_t young_live, 1.32 + size_t eden_live, 1.33 + size_t cur_eden, 1.34 + size_t max_eden_size, 1.35 + bool is_full_gc) { 1.36 1.37 // Update statistics 1.38 // Time statistics are updated as we go, update footprint stats here 1.39 _avg_base_footprint->sample(BaseFootPrintEstimate); 1.40 avg_young_live()->sample(young_live); 1.41 avg_eden_live()->sample(eden_live); 1.42 + 1.43 + // This code used to return if the policy was not ready , i.e., 1.44 + // policy_is_ready() returning false. The intent was that 1.45 + // decisions below needed major collection times and so could 1.46 + // not be made before two major collections. A consequence was 1.47 + // adjustments to the young generation were not done until after 1.48 + // two major collections even if the minor collections times 1.49 + // exceeded the requested goals. Now let the young generation 1.50 + // adjust for the minor collection times. Major collection times 1.51 + // will be zero for the first collection and will naturally be 1.52 + // ignored. Tenured generation adjustments are only made at the 1.53 + // full collections so until the second major collection has 1.54 + // been reached, no tenured generation adjustments will be made. 1.55 + 1.56 + // Until we know better, desired promotion size uses the last calculation 1.57 + size_t desired_promo_size = _promo_size; 1.58 + 1.59 + // Start eden at the current value. The desired value that is stored 1.60 + // in _eden_size is not bounded by constraints of the heap and can 1.61 + // run away. 1.62 + // 1.63 + // As expected setting desired_eden_size to the current 1.64 + // value of desired_eden_size as a starting point 1.65 + // caused desired_eden_size to grow way too large and caused 1.66 + // an overflow down stream. It may have improved performance in 1.67 + // some case but is dangerous. 1.68 + size_t desired_eden_size = cur_eden; 1.69 + 1.70 + // Cache some values. There's a bit of work getting these, so 1.71 + // we might save a little time. 1.72 + const double major_cost = major_gc_cost(); 1.73 + const double minor_cost = minor_gc_cost(); 1.74 + 1.75 + // This method sets the desired eden size. That plus the 1.76 + // desired survivor space sizes sets the desired young generation 1.77 + // size. This methods does not know what the desired survivor 1.78 + // size is but expects that other policy will attempt to make 1.79 + // the survivor sizes compatible with the live data in the 1.80 + // young generation. This limit is an estimate of the space left 1.81 + // in the young generation after the survivor spaces have been 1.82 + // subtracted out. 1.83 + size_t eden_limit = max_eden_size; 1.84 + 1.85 + const double gc_cost_limit = GCTimeLimit/100.0; 1.86 + 1.87 + // Which way should we go? 1.88 + // if pause requirement is not met 1.89 + // adjust size of any generation with average paus exceeding 1.90 + // the pause limit. Adjust one pause at a time (the larger) 1.91 + // and only make adjustments for the major pause at full collections. 1.92 + // else if throughput requirement not met 1.93 + // adjust the size of the generation with larger gc time. Only 1.94 + // adjust one generation at a time. 1.95 + // else 1.96 + // adjust down the total heap size. Adjust down the larger of the 1.97 + // generations. 1.98 + 1.99 + // Add some checks for a threshold for a change. For example, 1.100 + // a change less than the necessary alignment is probably not worth 1.101 + // attempting. 1.102 + 1.103 + 1.104 + if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) || 1.105 + (_avg_major_pause->padded_average() > gc_pause_goal_sec())) { 1.106 + // 1.107 + // Check pauses 1.108 + // 1.109 + // Make changes only to affect one of the pauses (the larger) 1.110 + // at a time. 1.111 + adjust_eden_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); 1.112 + 1.113 + } else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) { 1.114 + // Adjust only for the minor pause time goal 1.115 + adjust_eden_for_minor_pause_time(is_full_gc, &desired_eden_size); 1.116 + 1.117 + } else if(adjusted_mutator_cost() < _throughput_goal) { 1.118 + // This branch used to require that (mutator_cost() > 0.0 in 1.4.2. 1.119 + // This sometimes resulted in skipping to the minimize footprint 1.120 + // code. Change this to try and reduce GC time if mutator time is 1.121 + // negative for whatever reason. Or for future consideration, 1.122 + // bail out of the code if mutator time is negative. 1.123 + // 1.124 + // Throughput 1.125 + // 1.126 + assert(major_cost >= 0.0, "major cost is < 0.0"); 1.127 + assert(minor_cost >= 0.0, "minor cost is < 0.0"); 1.128 + // Try to reduce the GC times. 1.129 + adjust_eden_for_throughput(is_full_gc, &desired_eden_size); 1.130 + 1.131 + } else { 1.132 + 1.133 + // Be conservative about reducing the footprint. 1.134 + // Do a minimum number of major collections first. 1.135 + // Have reasonable averages for major and minor collections costs. 1.136 + if (UseAdaptiveSizePolicyFootprintGoal && 1.137 + young_gen_policy_is_ready() && 1.138 + avg_major_gc_cost()->average() >= 0.0 && 1.139 + avg_minor_gc_cost()->average() >= 0.0) { 1.140 + size_t desired_sum = desired_eden_size + desired_promo_size; 1.141 + desired_eden_size = adjust_eden_for_footprint(desired_eden_size, desired_sum); 1.142 + } 1.143 + } 1.144 + 1.145 + // Note we make the same tests as in the code block below; the code 1.146 + // seems a little easier to read with the printing in another block. 1.147 + if (PrintAdaptiveSizePolicy) { 1.148 + if (desired_eden_size > eden_limit) { 1.149 + gclog_or_tty->print_cr( 1.150 + "PSAdaptiveSizePolicy::compute_eden_space_size limits:" 1.151 + " desired_eden_size: " SIZE_FORMAT 1.152 + " old_eden_size: " SIZE_FORMAT 1.153 + " eden_limit: " SIZE_FORMAT 1.154 + " cur_eden: " SIZE_FORMAT 1.155 + " max_eden_size: " SIZE_FORMAT 1.156 + " avg_young_live: " SIZE_FORMAT, 1.157 + desired_eden_size, _eden_size, eden_limit, cur_eden, 1.158 + max_eden_size, (size_t)avg_young_live()->average()); 1.159 + } 1.160 + if (gc_cost() > gc_cost_limit) { 1.161 + gclog_or_tty->print_cr( 1.162 + "PSAdaptiveSizePolicy::compute_eden_space_size: gc time limit" 1.163 + " gc_cost: %f " 1.164 + " GCTimeLimit: %d", 1.165 + gc_cost(), GCTimeLimit); 1.166 + } 1.167 + } 1.168 + 1.169 + // Align everything and make a final limit check 1.170 + const size_t alignment = _intra_generation_alignment; 1.171 + desired_eden_size = align_size_up(desired_eden_size, alignment); 1.172 + desired_eden_size = MAX2(desired_eden_size, alignment); 1.173 + 1.174 + eden_limit = align_size_down(eden_limit, alignment); 1.175 + 1.176 + // And one last limit check, now that we've aligned things. 1.177 + if (desired_eden_size > eden_limit) { 1.178 + // If the policy says to get a larger eden but 1.179 + // is hitting the limit, don't decrease eden. 1.180 + // This can lead to a general drifting down of the 1.181 + // eden size. Let the tenuring calculation push more 1.182 + // into the old gen. 1.183 + desired_eden_size = MAX2(eden_limit, cur_eden); 1.184 + } 1.185 + 1.186 + if (PrintAdaptiveSizePolicy) { 1.187 + // Timing stats 1.188 + gclog_or_tty->print( 1.189 + "PSAdaptiveSizePolicy::compute_eden_space_size: costs" 1.190 + " minor_time: %f" 1.191 + " major_cost: %f" 1.192 + " mutator_cost: %f" 1.193 + " throughput_goal: %f", 1.194 + minor_gc_cost(), major_gc_cost(), mutator_cost(), 1.195 + _throughput_goal); 1.196 + 1.197 + // We give more details if Verbose is set 1.198 + if (Verbose) { 1.199 + gclog_or_tty->print( " minor_pause: %f" 1.200 + " major_pause: %f" 1.201 + " minor_interval: %f" 1.202 + " major_interval: %f" 1.203 + " pause_goal: %f", 1.204 + _avg_minor_pause->padded_average(), 1.205 + _avg_major_pause->padded_average(), 1.206 + _avg_minor_interval->average(), 1.207 + _avg_major_interval->average(), 1.208 + gc_pause_goal_sec()); 1.209 + } 1.210 + 1.211 + // Footprint stats 1.212 + gclog_or_tty->print( " live_space: " SIZE_FORMAT 1.213 + " free_space: " SIZE_FORMAT, 1.214 + live_space(), free_space()); 1.215 + // More detail 1.216 + if (Verbose) { 1.217 + gclog_or_tty->print( " base_footprint: " SIZE_FORMAT 1.218 + " avg_young_live: " SIZE_FORMAT 1.219 + " avg_old_live: " SIZE_FORMAT, 1.220 + (size_t)_avg_base_footprint->average(), 1.221 + (size_t)avg_young_live()->average(), 1.222 + (size_t)avg_old_live()->average()); 1.223 + } 1.224 + 1.225 + // And finally, our old and new sizes. 1.226 + gclog_or_tty->print(" old_eden_size: " SIZE_FORMAT 1.227 + " desired_eden_size: " SIZE_FORMAT, 1.228 + _eden_size, desired_eden_size); 1.229 + gclog_or_tty->cr(); 1.230 + } 1.231 + 1.232 + set_eden_size(desired_eden_size); 1.233 +} 1.234 + 1.235 +void PSAdaptiveSizePolicy::compute_old_gen_free_space( 1.236 + size_t old_live, 1.237 + size_t cur_eden, 1.238 + size_t max_old_gen_size, 1.239 + bool is_full_gc) { 1.240 + 1.241 + // Update statistics 1.242 + // Time statistics are updated as we go, update footprint stats here 1.243 if (is_full_gc) { 1.244 // old_live is only accurate after a full gc 1.245 avg_old_live()->sample(old_live); 1.246 @@ -242,32 +459,14 @@ 1.247 // some case but is dangerous. 1.248 size_t desired_eden_size = cur_eden; 1.249 1.250 -#ifdef ASSERT 1.251 - size_t original_promo_size = desired_promo_size; 1.252 - size_t original_eden_size = desired_eden_size; 1.253 -#endif 1.254 - 1.255 // Cache some values. There's a bit of work getting these, so 1.256 // we might save a little time. 1.257 const double major_cost = major_gc_cost(); 1.258 const double minor_cost = minor_gc_cost(); 1.259 1.260 - // Used for diagnostics 1.261 - clear_generation_free_space_flags(); 1.262 - 1.263 // Limits on our growth 1.264 size_t promo_limit = (size_t)(max_old_gen_size - avg_old_live()->average()); 1.265 1.266 - // This method sets the desired eden size. That plus the 1.267 - // desired survivor space sizes sets the desired young generation 1.268 - // size. This methods does not know what the desired survivor 1.269 - // size is but expects that other policy will attempt to make 1.270 - // the survivor sizes compatible with the live data in the 1.271 - // young generation. This limit is an estimate of the space left 1.272 - // in the young generation after the survivor spaces have been 1.273 - // subtracted out. 1.274 - size_t eden_limit = max_eden_size; 1.275 - 1.276 // But don't force a promo size below the current promo size. Otherwise, 1.277 // the promo size will shrink for no good reason. 1.278 promo_limit = MAX2(promo_limit, _promo_size); 1.279 @@ -290,7 +489,6 @@ 1.280 // a change less than the necessary alignment is probably not worth 1.281 // attempting. 1.282 1.283 - 1.284 if ((_avg_minor_pause->padded_average() > gc_pause_goal_sec()) || 1.285 (_avg_major_pause->padded_average() > gc_pause_goal_sec())) { 1.286 // 1.287 @@ -298,12 +496,13 @@ 1.288 // 1.289 // Make changes only to affect one of the pauses (the larger) 1.290 // at a time. 1.291 - adjust_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); 1.292 - 1.293 + if (is_full_gc) { 1.294 + set_decide_at_full_gc(decide_at_full_gc_true); 1.295 + adjust_promo_for_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); 1.296 + } 1.297 } else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) { 1.298 // Adjust only for the minor pause time goal 1.299 - adjust_for_minor_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); 1.300 - 1.301 + adjust_promo_for_minor_pause_time(is_full_gc, &desired_promo_size, &desired_eden_size); 1.302 } else if(adjusted_mutator_cost() < _throughput_goal) { 1.303 // This branch used to require that (mutator_cost() > 0.0 in 1.4.2. 1.304 // This sometimes resulted in skipping to the minimize footprint 1.305 @@ -316,8 +515,10 @@ 1.306 assert(major_cost >= 0.0, "major cost is < 0.0"); 1.307 assert(minor_cost >= 0.0, "minor cost is < 0.0"); 1.308 // Try to reduce the GC times. 1.309 - adjust_for_throughput(is_full_gc, &desired_promo_size, &desired_eden_size); 1.310 - 1.311 + if (is_full_gc) { 1.312 + set_decide_at_full_gc(decide_at_full_gc_true); 1.313 + adjust_promo_for_throughput(is_full_gc, &desired_promo_size); 1.314 + } 1.315 } else { 1.316 1.317 // Be conservative about reducing the footprint. 1.318 @@ -327,13 +528,10 @@ 1.319 young_gen_policy_is_ready() && 1.320 avg_major_gc_cost()->average() >= 0.0 && 1.321 avg_minor_gc_cost()->average() >= 0.0) { 1.322 - size_t desired_sum = desired_eden_size + desired_promo_size; 1.323 - desired_eden_size = adjust_eden_for_footprint(desired_eden_size, 1.324 - desired_sum); 1.325 if (is_full_gc) { 1.326 set_decide_at_full_gc(decide_at_full_gc_true); 1.327 - desired_promo_size = adjust_promo_for_footprint(desired_promo_size, 1.328 - desired_sum); 1.329 + size_t desired_sum = desired_eden_size + desired_promo_size; 1.330 + desired_promo_size = adjust_promo_for_footprint(desired_promo_size, desired_sum); 1.331 } 1.332 } 1.333 } 1.334 @@ -345,7 +543,7 @@ 1.335 // "free_in_old_gen" was the original value for used for promo_limit 1.336 size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average()); 1.337 gclog_or_tty->print_cr( 1.338 - "PSAdaptiveSizePolicy::compute_generation_free_space limits:" 1.339 + "PSAdaptiveSizePolicy::compute_old_gen_free_space limits:" 1.340 " desired_promo_size: " SIZE_FORMAT 1.341 " promo_limit: " SIZE_FORMAT 1.342 " free_in_old_gen: " SIZE_FORMAT 1.343 @@ -354,21 +552,9 @@ 1.344 desired_promo_size, promo_limit, free_in_old_gen, 1.345 max_old_gen_size, (size_t) avg_old_live()->average()); 1.346 } 1.347 - if (desired_eden_size > eden_limit) { 1.348 - gclog_or_tty->print_cr( 1.349 - "AdaptiveSizePolicy::compute_generation_free_space limits:" 1.350 - " desired_eden_size: " SIZE_FORMAT 1.351 - " old_eden_size: " SIZE_FORMAT 1.352 - " eden_limit: " SIZE_FORMAT 1.353 - " cur_eden: " SIZE_FORMAT 1.354 - " max_eden_size: " SIZE_FORMAT 1.355 - " avg_young_live: " SIZE_FORMAT, 1.356 - desired_eden_size, _eden_size, eden_limit, cur_eden, 1.357 - max_eden_size, (size_t)avg_young_live()->average()); 1.358 - } 1.359 if (gc_cost() > gc_cost_limit) { 1.360 gclog_or_tty->print_cr( 1.361 - "AdaptiveSizePolicy::compute_generation_free_space: gc time limit" 1.362 + "PSAdaptiveSizePolicy::compute_old_gen_free_space: gc time limit" 1.363 " gc_cost: %f " 1.364 " GCTimeLimit: %d", 1.365 gc_cost(), GCTimeLimit); 1.366 @@ -377,46 +563,18 @@ 1.367 1.368 // Align everything and make a final limit check 1.369 const size_t alignment = _intra_generation_alignment; 1.370 - desired_eden_size = align_size_up(desired_eden_size, alignment); 1.371 - desired_eden_size = MAX2(desired_eden_size, alignment); 1.372 desired_promo_size = align_size_up(desired_promo_size, alignment); 1.373 desired_promo_size = MAX2(desired_promo_size, alignment); 1.374 1.375 - eden_limit = align_size_down(eden_limit, alignment); 1.376 promo_limit = align_size_down(promo_limit, alignment); 1.377 1.378 - // Is too much time being spent in GC? 1.379 - // Is the heap trying to grow beyond it's limits? 1.380 - 1.381 - const size_t free_in_old_gen = 1.382 - (size_t)(max_old_gen_size - avg_old_live()->average()); 1.383 - if (desired_promo_size > free_in_old_gen && desired_eden_size > eden_limit) { 1.384 - check_gc_overhead_limit(young_live, 1.385 - eden_live, 1.386 - max_old_gen_size, 1.387 - max_eden_size, 1.388 - is_full_gc, 1.389 - gc_cause, 1.390 - collector_policy); 1.391 - } 1.392 - 1.393 - 1.394 // And one last limit check, now that we've aligned things. 1.395 - if (desired_eden_size > eden_limit) { 1.396 - // If the policy says to get a larger eden but 1.397 - // is hitting the limit, don't decrease eden. 1.398 - // This can lead to a general drifting down of the 1.399 - // eden size. Let the tenuring calculation push more 1.400 - // into the old gen. 1.401 - desired_eden_size = MAX2(eden_limit, cur_eden); 1.402 - } 1.403 desired_promo_size = MIN2(desired_promo_size, promo_limit); 1.404 1.405 - 1.406 if (PrintAdaptiveSizePolicy) { 1.407 // Timing stats 1.408 gclog_or_tty->print( 1.409 - "PSAdaptiveSizePolicy::compute_generation_free_space: costs" 1.410 + "PSAdaptiveSizePolicy::compute_old_gen_free_space: costs" 1.411 " minor_time: %f" 1.412 " major_cost: %f" 1.413 " mutator_cost: %f" 1.414 @@ -454,19 +612,13 @@ 1.415 1.416 // And finally, our old and new sizes. 1.417 gclog_or_tty->print(" old_promo_size: " SIZE_FORMAT 1.418 - " old_eden_size: " SIZE_FORMAT 1.419 - " desired_promo_size: " SIZE_FORMAT 1.420 - " desired_eden_size: " SIZE_FORMAT, 1.421 - _promo_size, _eden_size, 1.422 - desired_promo_size, desired_eden_size); 1.423 + " desired_promo_size: " SIZE_FORMAT, 1.424 + _promo_size, desired_promo_size); 1.425 gclog_or_tty->cr(); 1.426 } 1.427 1.428 - decay_supplemental_growth(is_full_gc); 1.429 - 1.430 set_promo_size(desired_promo_size); 1.431 - set_eden_size(desired_eden_size); 1.432 -}; 1.433 +} 1.434 1.435 void PSAdaptiveSizePolicy::decay_supplemental_growth(bool is_full_gc) { 1.436 // Decay the supplemental increment? Decay the supplement growth 1.437 @@ -490,9 +642,39 @@ 1.438 } 1.439 } 1.440 1.441 -void PSAdaptiveSizePolicy::adjust_for_minor_pause_time(bool is_full_gc, 1.442 +void PSAdaptiveSizePolicy::adjust_promo_for_minor_pause_time(bool is_full_gc, 1.443 size_t* desired_promo_size_ptr, size_t* desired_eden_size_ptr) { 1.444 1.445 + if (PSAdjustTenuredGenForMinorPause) { 1.446 + if (is_full_gc) { 1.447 + set_decide_at_full_gc(decide_at_full_gc_true); 1.448 + } 1.449 + // If the desired eden size is as small as it will get, 1.450 + // try to adjust the old gen size. 1.451 + if (*desired_eden_size_ptr <= _intra_generation_alignment) { 1.452 + // Vary the old gen size to reduce the young gen pause. This 1.453 + // may not be a good idea. This is just a test. 1.454 + if (minor_pause_old_estimator()->decrement_will_decrease()) { 1.455 + set_change_old_gen_for_min_pauses(decrease_old_gen_for_min_pauses_true); 1.456 + *desired_promo_size_ptr = 1.457 + _promo_size - promo_decrement_aligned_down(*desired_promo_size_ptr); 1.458 + } else { 1.459 + set_change_old_gen_for_min_pauses(increase_old_gen_for_min_pauses_true); 1.460 + size_t promo_heap_delta = 1.461 + promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); 1.462 + if ((*desired_promo_size_ptr + promo_heap_delta) > 1.463 + *desired_promo_size_ptr) { 1.464 + *desired_promo_size_ptr = 1.465 + _promo_size + promo_heap_delta; 1.466 + } 1.467 + } 1.468 + } 1.469 + } 1.470 +} 1.471 + 1.472 +void PSAdaptiveSizePolicy::adjust_eden_for_minor_pause_time(bool is_full_gc, 1.473 + size_t* desired_eden_size_ptr) { 1.474 + 1.475 // Adjust the young generation size to reduce pause time of 1.476 // of collections. 1.477 // 1.478 @@ -512,49 +694,19 @@ 1.479 set_change_young_gen_for_min_pauses( 1.480 increase_young_gen_for_min_pauses_true); 1.481 } 1.482 - if (PSAdjustTenuredGenForMinorPause) { 1.483 - // If the desired eden size is as small as it will get, 1.484 - // try to adjust the old gen size. 1.485 - if (*desired_eden_size_ptr <= _intra_generation_alignment) { 1.486 - // Vary the old gen size to reduce the young gen pause. This 1.487 - // may not be a good idea. This is just a test. 1.488 - if (minor_pause_old_estimator()->decrement_will_decrease()) { 1.489 - set_change_old_gen_for_min_pauses( 1.490 - decrease_old_gen_for_min_pauses_true); 1.491 - *desired_promo_size_ptr = 1.492 - _promo_size - promo_decrement_aligned_down(*desired_promo_size_ptr); 1.493 - } else { 1.494 - set_change_old_gen_for_min_pauses( 1.495 - increase_old_gen_for_min_pauses_true); 1.496 - size_t promo_heap_delta = 1.497 - promo_increment_with_supplement_aligned_up(*desired_promo_size_ptr); 1.498 - if ((*desired_promo_size_ptr + promo_heap_delta) > 1.499 - *desired_promo_size_ptr) { 1.500 - *desired_promo_size_ptr = 1.501 - _promo_size + promo_heap_delta; 1.502 - } 1.503 - } 1.504 - } 1.505 - } 1.506 } 1.507 1.508 -void PSAdaptiveSizePolicy::adjust_for_pause_time(bool is_full_gc, 1.509 +void PSAdaptiveSizePolicy::adjust_promo_for_pause_time(bool is_full_gc, 1.510 size_t* desired_promo_size_ptr, 1.511 size_t* desired_eden_size_ptr) { 1.512 1.513 size_t promo_heap_delta = 0; 1.514 - size_t eden_heap_delta = 0; 1.515 - // Add some checks for a threshhold for a change. For example, 1.516 + // Add some checks for a threshold for a change. For example, 1.517 // a change less than the required alignment is probably not worth 1.518 // attempting. 1.519 - if (is_full_gc) { 1.520 - set_decide_at_full_gc(decide_at_full_gc_true); 1.521 - } 1.522 1.523 if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) { 1.524 - adjust_for_minor_pause_time(is_full_gc, 1.525 - desired_promo_size_ptr, 1.526 - desired_eden_size_ptr); 1.527 + adjust_promo_for_minor_pause_time(is_full_gc, desired_promo_size_ptr, desired_eden_size_ptr); 1.528 // major pause adjustments 1.529 } else if (is_full_gc) { 1.530 // Adjust for the major pause time only at full gc's because the 1.531 @@ -573,6 +725,33 @@ 1.532 // promo_increment_aligned_up(*desired_promo_size_ptr); 1.533 set_change_old_gen_for_maj_pauses(increase_old_gen_for_maj_pauses_true); 1.534 } 1.535 + } 1.536 + 1.537 + if (PrintAdaptiveSizePolicy && Verbose) { 1.538 + gclog_or_tty->print_cr( 1.539 + "PSAdaptiveSizePolicy::compute_old_gen_free_space " 1.540 + "adjusting gen sizes for major pause (avg %f goal %f). " 1.541 + "desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT, 1.542 + _avg_major_pause->average(), gc_pause_goal_sec(), 1.543 + *desired_promo_size_ptr, promo_heap_delta); 1.544 + } 1.545 +} 1.546 + 1.547 +void PSAdaptiveSizePolicy::adjust_eden_for_pause_time(bool is_full_gc, 1.548 + size_t* desired_promo_size_ptr, 1.549 + size_t* desired_eden_size_ptr) { 1.550 + 1.551 + size_t eden_heap_delta = 0; 1.552 + // Add some checks for a threshold for a change. For example, 1.553 + // a change less than the required alignment is probably not worth 1.554 + // attempting. 1.555 + if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) { 1.556 + adjust_eden_for_minor_pause_time(is_full_gc, 1.557 + desired_eden_size_ptr); 1.558 + // major pause adjustments 1.559 + } else if (is_full_gc) { 1.560 + // Adjust for the major pause time only at full gc's because the 1.561 + // affects of a change can only be seen at full gc's. 1.562 if (PSAdjustYoungGenForMajorPause) { 1.563 // If the promo size is at the minimum (i.e., the old gen 1.564 // size will not actually decrease), consider changing the 1.565 @@ -607,43 +786,35 @@ 1.566 1.567 if (PrintAdaptiveSizePolicy && Verbose) { 1.568 gclog_or_tty->print_cr( 1.569 - "AdaptiveSizePolicy::compute_generation_free_space " 1.570 + "PSAdaptiveSizePolicy::compute_eden_space_size " 1.571 "adjusting gen sizes for major pause (avg %f goal %f). " 1.572 - "desired_promo_size " SIZE_FORMAT "desired_eden_size " 1.573 - SIZE_FORMAT 1.574 - " promo delta " SIZE_FORMAT " eden delta " SIZE_FORMAT, 1.575 + "desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, 1.576 _avg_major_pause->average(), gc_pause_goal_sec(), 1.577 - *desired_promo_size_ptr, *desired_eden_size_ptr, 1.578 - promo_heap_delta, eden_heap_delta); 1.579 + *desired_eden_size_ptr, eden_heap_delta); 1.580 } 1.581 } 1.582 1.583 -void PSAdaptiveSizePolicy::adjust_for_throughput(bool is_full_gc, 1.584 - size_t* desired_promo_size_ptr, 1.585 - size_t* desired_eden_size_ptr) { 1.586 +void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc, 1.587 + size_t* desired_promo_size_ptr) { 1.588 1.589 - // Add some checks for a threshhold for a change. For example, 1.590 + // Add some checks for a threshold for a change. For example, 1.591 // a change less than the required alignment is probably not worth 1.592 // attempting. 1.593 - if (is_full_gc) { 1.594 - set_decide_at_full_gc(decide_at_full_gc_true); 1.595 - } 1.596 1.597 if ((gc_cost() + mutator_cost()) == 0.0) { 1.598 return; 1.599 } 1.600 1.601 if (PrintAdaptiveSizePolicy && Verbose) { 1.602 - gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_for_throughput(" 1.603 - "is_full: %d, promo: " SIZE_FORMAT ", cur_eden: " SIZE_FORMAT "): ", 1.604 - is_full_gc, *desired_promo_size_ptr, *desired_eden_size_ptr); 1.605 + gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_promo_for_throughput(" 1.606 + "is_full: %d, promo: " SIZE_FORMAT "): ", 1.607 + is_full_gc, *desired_promo_size_ptr); 1.608 gclog_or_tty->print_cr("mutator_cost %f major_gc_cost %f " 1.609 "minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost()); 1.610 } 1.611 1.612 // Tenured generation 1.613 if (is_full_gc) { 1.614 - 1.615 // Calculate the change to use for the tenured gen. 1.616 size_t scaled_promo_heap_delta = 0; 1.617 // Can the increment to the generation be scaled? 1.618 @@ -720,6 +891,26 @@ 1.619 *desired_promo_size_ptr, scaled_promo_heap_delta); 1.620 } 1.621 } 1.622 +} 1.623 + 1.624 +void PSAdaptiveSizePolicy::adjust_eden_for_throughput(bool is_full_gc, 1.625 + size_t* desired_eden_size_ptr) { 1.626 + 1.627 + // Add some checks for a threshold for a change. For example, 1.628 + // a change less than the required alignment is probably not worth 1.629 + // attempting. 1.630 + 1.631 + if ((gc_cost() + mutator_cost()) == 0.0) { 1.632 + return; 1.633 + } 1.634 + 1.635 + if (PrintAdaptiveSizePolicy && Verbose) { 1.636 + gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_eden_for_throughput(" 1.637 + "is_full: %d, cur_eden: " SIZE_FORMAT "): ", 1.638 + is_full_gc, *desired_eden_size_ptr); 1.639 + gclog_or_tty->print_cr("mutator_cost %f major_gc_cost %f " 1.640 + "minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost()); 1.641 + } 1.642 1.643 // Young generation 1.644 size_t scaled_eden_heap_delta = 0;