src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp

changeset 3114
20213c8a3c40
parent 3066
ae73da50be4b
child 3119
4f41766176cf
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Tue Sep 06 21:03:51 2011 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Sep 07 12:21:23 2011 -0400
     1.3 @@ -28,6 +28,7 @@
     1.4  #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
     1.5  #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
     1.6  #include "gc_implementation/g1/g1CollectorPolicy.hpp"
     1.7 +#include "gc_implementation/g1/g1ErgoVerbose.hpp"
     1.8  #include "gc_implementation/g1/heapRegionRemSet.hpp"
     1.9  #include "gc_implementation/shared/gcPolicyCounters.hpp"
    1.10  #include "runtime/arguments.hpp"
    1.11 @@ -271,15 +272,26 @@
    1.12    _recorded_survivor_tail(NULL),
    1.13    _survivors_age_table(true),
    1.14  
    1.15 -  _gc_overhead_perc(0.0)
    1.16 -
    1.17 -{
    1.18 +  _gc_overhead_perc(0.0) {
    1.19 +
    1.20    // Set up the region size and associated fields. Given that the
    1.21    // policy is created before the heap, we have to set this up here,
    1.22    // so it's done as soon as possible.
    1.23    HeapRegion::setup_heap_region_size(Arguments::min_heap_size());
    1.24    HeapRegionRemSet::setup_remset_size();
    1.25  
    1.26 +  G1ErgoVerbose::initialize();
    1.27 +  if (PrintAdaptiveSizePolicy) {
    1.28 +    // Currently, we only use a single switch for all the heuristics.
    1.29 +    G1ErgoVerbose::set_enabled(true);
    1.30 +    // Given that we don't currently have a verboseness level
    1.31 +    // parameter, we'll hardcode this to high. This can be easily
    1.32 +    // changed in the future.
    1.33 +    G1ErgoVerbose::set_level(ErgoHigh);
    1.34 +  } else {
    1.35 +    G1ErgoVerbose::set_enabled(false);
    1.36 +  }
    1.37 +
    1.38    // Verify PLAB sizes
    1.39    const uint region_size = HeapRegion::GrainWords;
    1.40    if (YoungPLABSize > region_size || OldPLABSize > region_size) {
    1.41 @@ -959,11 +971,9 @@
    1.42  G1CollectorPolicy::
    1.43  record_concurrent_mark_cleanup_end_work1(size_t freed_bytes,
    1.44                                           size_t max_live_bytes) {
    1.45 -  if (_n_marks < 2) _n_marks++;
    1.46 -  if (G1PolicyVerbose > 0)
    1.47 -    gclog_or_tty->print_cr("At end of marking, max_live is " SIZE_FORMAT " MB "
    1.48 -                           " (of " SIZE_FORMAT " MB heap).",
    1.49 -                           max_live_bytes/M, _g1->capacity()/M);
    1.50 +  if (_n_marks < 2) {
    1.51 +    _n_marks++;
    1.52 +  }
    1.53  }
    1.54  
    1.55  // The important thing about this is that it includes "os::elapsedTime".
    1.56 @@ -977,14 +987,6 @@
    1.57    _mmu_tracker->add_pause(_mark_cleanup_start_sec, end_time_sec, true);
    1.58  
    1.59    _num_markings++;
    1.60 -
    1.61 -  // We did a marking, so reset the "since_last_mark" variables.
    1.62 -  double considerConcMarkCost = 1.0;
    1.63 -  // If there are available processors, concurrent activity is free...
    1.64 -  if (Threads::number_of_non_daemon_threads() * 2 <
    1.65 -      os::active_processor_count()) {
    1.66 -    considerConcMarkCost = 0.0;
    1.67 -  }
    1.68    _n_pauses_at_mark_end = _n_pauses;
    1.69    _n_marks_since_last_pause++;
    1.70  }
    1.71 @@ -1148,20 +1150,37 @@
    1.72    if (last_pause_included_initial_mark)
    1.73      record_concurrent_mark_init_end(0.0);
    1.74  
    1.75 -  size_t min_used_targ =
    1.76 +  size_t marking_initiating_used_threshold =
    1.77      (_g1->capacity() / 100) * InitiatingHeapOccupancyPercent;
    1.78  
    1.79 -
    1.80    if (!_g1->mark_in_progress() && !_last_full_young_gc) {
    1.81      assert(!last_pause_included_initial_mark, "invariant");
    1.82 -    if (cur_used_bytes > min_used_targ &&
    1.83 -      cur_used_bytes > _prev_collection_pause_used_at_end_bytes) {
    1.84 +    if (cur_used_bytes > marking_initiating_used_threshold) {
    1.85 +      if (cur_used_bytes > _prev_collection_pause_used_at_end_bytes) {
    1.86          assert(!during_initial_mark_pause(), "we should not see this here");
    1.87  
    1.88 +        ergo_verbose3(ErgoConcCycles,
    1.89 +                      "request concurrent cycle initiation",
    1.90 +                      ergo_format_reason("occupancy higher than threshold")
    1.91 +                      ergo_format_byte("occupancy")
    1.92 +                      ergo_format_byte_perc("threshold"),
    1.93 +                      cur_used_bytes,
    1.94 +                      marking_initiating_used_threshold,
    1.95 +                      (double) InitiatingHeapOccupancyPercent);
    1.96 +
    1.97          // Note: this might have already been set, if during the last
    1.98          // pause we decided to start a cycle but at the beginning of
    1.99          // this pause we decided to postpone it. That's OK.
   1.100          set_initiate_conc_mark_if_possible();
   1.101 +      } else {
   1.102 +        ergo_verbose2(ErgoConcCycles,
   1.103 +                  "do not request concurrent cycle initiation",
   1.104 +                  ergo_format_reason("occupancy lower than previous occupancy")
   1.105 +                  ergo_format_byte("occupancy")
   1.106 +                  ergo_format_byte("previous occupancy"),
   1.107 +                  cur_used_bytes,
   1.108 +                  _prev_collection_pause_used_at_end_bytes);
   1.109 +      }
   1.110      }
   1.111    }
   1.112  
   1.113 @@ -1437,16 +1456,45 @@
   1.114    }
   1.115  
   1.116    if (_last_full_young_gc) {
   1.117 +    ergo_verbose2(ErgoPartiallyYoungGCs,
   1.118 +                  "start partially-young GCs",
   1.119 +                  ergo_format_byte_perc("known garbage"),
   1.120 +                  _known_garbage_bytes, _known_garbage_ratio * 100.0);
   1.121      set_full_young_gcs(false);
   1.122      _last_full_young_gc = false;
   1.123    }
   1.124  
   1.125    if ( !_last_young_gc_full ) {
   1.126 -    if ( _should_revert_to_full_young_gcs ||
   1.127 -      _known_garbage_ratio < 0.05 ||
   1.128 -      (adaptive_young_list_length() &&
   1.129 -      (get_gc_eff_factor() * cur_efficiency < predict_young_gc_eff())) ) {
   1.130 -        set_full_young_gcs(true);
   1.131 +    if (_should_revert_to_full_young_gcs) {
   1.132 +      ergo_verbose2(ErgoPartiallyYoungGCs,
   1.133 +                    "end partially-young GCs",
   1.134 +                    ergo_format_reason("partially-young GCs end requested")
   1.135 +                    ergo_format_byte_perc("known garbage"),
   1.136 +                    _known_garbage_bytes, _known_garbage_ratio * 100.0);
   1.137 +      set_full_young_gcs(true);
   1.138 +    } else if (_known_garbage_ratio < 0.05) {
   1.139 +      ergo_verbose3(ErgoPartiallyYoungGCs,
   1.140 +               "end partially-young GCs",
   1.141 +               ergo_format_reason("known garbage percent lower than threshold")
   1.142 +               ergo_format_byte_perc("known garbage")
   1.143 +               ergo_format_perc("threshold"),
   1.144 +               _known_garbage_bytes, _known_garbage_ratio * 100.0,
   1.145 +               0.05 * 100.0);
   1.146 +      set_full_young_gcs(true);
   1.147 +    } else if (adaptive_young_list_length() &&
   1.148 +              (get_gc_eff_factor() * cur_efficiency < predict_young_gc_eff())) {
   1.149 +      ergo_verbose5(ErgoPartiallyYoungGCs,
   1.150 +                    "end partially-young GCs",
   1.151 +                    ergo_format_reason("current GC efficiency lower than "
   1.152 +                                       "predicted fully-young GC efficiency")
   1.153 +                    ergo_format_double("GC efficiency factor")
   1.154 +                    ergo_format_double("current GC efficiency")
   1.155 +                    ergo_format_double("predicted fully-young GC efficiency")
   1.156 +                    ergo_format_byte_perc("known garbage"),
   1.157 +                    get_gc_eff_factor(), cur_efficiency,
   1.158 +                    predict_young_gc_eff(),
   1.159 +                    _known_garbage_bytes, _known_garbage_ratio * 100.0);
   1.160 +      set_full_young_gcs(true);
   1.161      }
   1.162    }
   1.163    _should_revert_to_full_young_gcs = false;
   1.164 @@ -1877,6 +1925,12 @@
   1.165    // I don't think we need to do this when in young GC mode since
   1.166    // marking will be initiated next time we hit the soft limit anyway...
   1.167    if (predicted_time_ms > _expensive_region_limit_ms) {
   1.168 +    ergo_verbose2(ErgoPartiallyYoungGCs,
   1.169 +              "request partially-young GCs end",
   1.170 +              ergo_format_reason("predicted region time higher than threshold")
   1.171 +              ergo_format_ms("predicted region time")
   1.172 +              ergo_format_ms("threshold"),
   1.173 +              predicted_time_ms, _expensive_region_limit_ms);
   1.174      // no point in doing another partial one
   1.175      _should_revert_to_full_young_gcs = true;
   1.176    }
   1.177 @@ -1986,7 +2040,9 @@
   1.178  }
   1.179  
   1.180  size_t G1CollectorPolicy::expansion_amount() {
   1.181 -  if ((recent_avg_pause_time_ratio() * 100.0) > _gc_overhead_perc) {
   1.182 +  double recent_gc_overhead = recent_avg_pause_time_ratio() * 100.0;
   1.183 +  double threshold = _gc_overhead_perc;
   1.184 +  if (recent_gc_overhead > threshold) {
   1.185      // We will double the existing space, or take
   1.186      // G1ExpandByPercentOfAvailable % of the available expansion
   1.187      // space, whichever is smaller, bounded below by a minimum
   1.188 @@ -2001,20 +2057,19 @@
   1.189      expand_bytes = MIN2(expand_bytes_via_pct, committed_bytes);
   1.190      expand_bytes = MAX2(expand_bytes, min_expand_bytes);
   1.191      expand_bytes = MIN2(expand_bytes, uncommitted_bytes);
   1.192 -    if (G1PolicyVerbose > 1) {
   1.193 -      gclog_or_tty->print("Decided to expand: ratio = %5.2f, "
   1.194 -                 "committed = %d%s, uncommited = %d%s, via pct = %d%s.\n"
   1.195 -                 "                   Answer = %d.\n",
   1.196 -                 recent_avg_pause_time_ratio(),
   1.197 -                 byte_size_in_proper_unit(committed_bytes),
   1.198 -                 proper_unit_for_byte_size(committed_bytes),
   1.199 -                 byte_size_in_proper_unit(uncommitted_bytes),
   1.200 -                 proper_unit_for_byte_size(uncommitted_bytes),
   1.201 -                 byte_size_in_proper_unit(expand_bytes_via_pct),
   1.202 -                 proper_unit_for_byte_size(expand_bytes_via_pct),
   1.203 -                 byte_size_in_proper_unit(expand_bytes),
   1.204 -                 proper_unit_for_byte_size(expand_bytes));
   1.205 -    }
   1.206 +
   1.207 +    ergo_verbose5(ErgoHeapSizing,
   1.208 +                  "attempt heap expansion",
   1.209 +                  ergo_format_reason("recent GC overhead higher than "
   1.210 +                                     "threshold after GC")
   1.211 +                  ergo_format_perc("recent GC overhead")
   1.212 +                  ergo_format_perc("threshold")
   1.213 +                  ergo_format_byte("uncommitted")
   1.214 +                  ergo_format_byte_perc("calculated expansion amount"),
   1.215 +                  recent_gc_overhead, threshold,
   1.216 +                  uncommitted_bytes,
   1.217 +                  expand_bytes_via_pct, (double) G1ExpandByPercentOfAvailable);
   1.218 +
   1.219      return expand_bytes;
   1.220    } else {
   1.221      return 0;
   1.222 @@ -2237,8 +2292,7 @@
   1.223  #endif // PRODUCT
   1.224  }
   1.225  
   1.226 -void
   1.227 -G1CollectorPolicy::update_region_num(bool young) {
   1.228 +void G1CollectorPolicy::update_region_num(bool young) {
   1.229    if (young) {
   1.230      ++_region_num_young;
   1.231    } else {
   1.232 @@ -2315,13 +2369,23 @@
   1.233  }
   1.234  #endif
   1.235  
   1.236 -bool
   1.237 -G1CollectorPolicy::force_initial_mark_if_outside_cycle() {
   1.238 +bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(
   1.239 +                                                     GCCause::Cause gc_cause) {
   1.240    bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
   1.241    if (!during_cycle) {
   1.242 +    ergo_verbose1(ErgoConcCycles,
   1.243 +                  "request concurrent cycle initiation",
   1.244 +                  ergo_format_reason("requested by GC cause")
   1.245 +                  ergo_format_str("GC cause"),
   1.246 +                  GCCause::to_string(gc_cause));
   1.247      set_initiate_conc_mark_if_possible();
   1.248      return true;
   1.249    } else {
   1.250 +    ergo_verbose1(ErgoConcCycles,
   1.251 +                  "do not request concurrent cycle initiation",
   1.252 +                  ergo_format_reason("concurrent cycle already in progress")
   1.253 +                  ergo_format_str("GC cause"),
   1.254 +                  GCCause::to_string(gc_cause));
   1.255      return false;
   1.256    }
   1.257  }
   1.258 @@ -2353,6 +2417,10 @@
   1.259        // And we can now clear initiate_conc_mark_if_possible() as
   1.260        // we've already acted on it.
   1.261        clear_initiate_conc_mark_if_possible();
   1.262 +
   1.263 +      ergo_verbose0(ErgoConcCycles,
   1.264 +                  "initiate concurrent cycle",
   1.265 +                  ergo_format_reason("concurrent cycle initiation requested"));
   1.266      } else {
   1.267        // The concurrent marking thread is still finishing up the
   1.268        // previous cycle. If we start one right now the two cycles
   1.269 @@ -2366,6 +2434,9 @@
   1.270        // and, if it's in a yield point, it's waiting for us to
   1.271        // finish. So, at this point we will not start a cycle and we'll
   1.272        // let the concurrent marking thread complete the last one.
   1.273 +      ergo_verbose0(ErgoConcCycles,
   1.274 +                    "do not initiate concurrent cycle",
   1.275 +                    ergo_format_reason("concurrent cycle already in progress"));
   1.276      }
   1.277    }
   1.278  }
   1.279 @@ -2756,6 +2827,8 @@
   1.280    // Set this here - in case we're not doing young collections.
   1.281    double non_young_start_time_sec = os::elapsedTime();
   1.282  
   1.283 +  YoungList* young_list = _g1->young_list();
   1.284 +
   1.285    start_recording_regions();
   1.286  
   1.287    guarantee(target_pause_time_ms > 0.0,
   1.288 @@ -2768,61 +2841,62 @@
   1.289  
   1.290    double time_remaining_ms = target_pause_time_ms - base_time_ms;
   1.291  
   1.292 +  ergo_verbose3(ErgoCSetConstruction | ErgoHigh,
   1.293 +                "start choosing CSet",
   1.294 +                ergo_format_ms("predicted base time")
   1.295 +                ergo_format_ms("remaining time")
   1.296 +                ergo_format_ms("target pause time"),
   1.297 +                base_time_ms, time_remaining_ms, target_pause_time_ms);
   1.298 +
   1.299    // the 10% and 50% values are arbitrary...
   1.300 -  if (time_remaining_ms < 0.10 * target_pause_time_ms) {
   1.301 +  double threshold = 0.10 * target_pause_time_ms;
   1.302 +  if (time_remaining_ms < threshold) {
   1.303 +    double prev_time_remaining_ms = time_remaining_ms;
   1.304      time_remaining_ms = 0.50 * target_pause_time_ms;
   1.305      _within_target = false;
   1.306 +    ergo_verbose3(ErgoCSetConstruction,
   1.307 +                  "adjust remaining time",
   1.308 +                  ergo_format_reason("remaining time lower than threshold")
   1.309 +                  ergo_format_ms("remaining time")
   1.310 +                  ergo_format_ms("threshold")
   1.311 +                  ergo_format_ms("adjusted remaining time"),
   1.312 +                  prev_time_remaining_ms, threshold, time_remaining_ms);
   1.313    } else {
   1.314      _within_target = true;
   1.315    }
   1.316  
   1.317 -  // We figure out the number of bytes available for future to-space.
   1.318 -  // For new regions without marking information, we must assume the
   1.319 -  // worst-case of complete survival.  If we have marking information for a
   1.320 -  // region, we can bound the amount of live data.  We can add a number of
   1.321 -  // such regions, as long as the sum of the live data bounds does not
   1.322 -  // exceed the available evacuation space.
   1.323 -  size_t max_live_bytes = _g1->free_regions() * HeapRegion::GrainBytes;
   1.324 -
   1.325 -  size_t expansion_bytes =
   1.326 -    _g1->expansion_regions() * HeapRegion::GrainBytes;
   1.327 +  size_t expansion_bytes = _g1->expansion_regions() * HeapRegion::GrainBytes;
   1.328 +
   1.329 +  HeapRegion* hr;
   1.330 +  double young_start_time_sec = os::elapsedTime();
   1.331  
   1.332    _collection_set_bytes_used_before = 0;
   1.333    _collection_set_size = 0;
   1.334 -
   1.335 -  // Adjust for expansion and slop.
   1.336 -  max_live_bytes = max_live_bytes + expansion_bytes;
   1.337 -
   1.338 -  HeapRegion* hr;
   1.339 -  double young_start_time_sec = os::elapsedTime();
   1.340 -
   1.341 -  if (G1PolicyVerbose > 0) {
   1.342 -    gclog_or_tty->print_cr("Adding %d young regions to the CSet",
   1.343 -      _g1->young_list()->length());
   1.344 -  }
   1.345 -
   1.346    _young_cset_length  = 0;
   1.347    _last_young_gc_full = full_young_gcs() ? true : false;
   1.348  
   1.349 -  if (_last_young_gc_full)
   1.350 +  if (_last_young_gc_full) {
   1.351      ++_full_young_pause_num;
   1.352 -  else
   1.353 +  } else {
   1.354      ++_partial_young_pause_num;
   1.355 +  }
   1.356  
   1.357    // The young list is laid with the survivor regions from the previous
   1.358    // pause are appended to the RHS of the young list, i.e.
   1.359    //   [Newly Young Regions ++ Survivors from last pause].
   1.360  
   1.361 -  hr = _g1->young_list()->first_survivor_region();
   1.362 +  size_t survivor_region_num = young_list->survivor_length();
   1.363 +  size_t eden_region_num = young_list->length() - survivor_region_num;
   1.364 +  size_t old_region_num = 0;
   1.365 +  hr = young_list->first_survivor_region();
   1.366    while (hr != NULL) {
   1.367      assert(hr->is_survivor(), "badly formed young list");
   1.368      hr->set_young();
   1.369      hr = hr->get_next_young_region();
   1.370    }
   1.371  
   1.372 -  // Clear the fields that point to the survivor list - they are
   1.373 -  // all young now.
   1.374 -  _g1->young_list()->clear_survivors();
   1.375 +  // Clear the fields that point to the survivor list - they are all young now.
   1.376 +  young_list->clear_survivors();
   1.377  
   1.378    if (_g1->mark_in_progress())
   1.379      _g1->concurrent_mark()->register_collection_set_finger(_inc_cset_max_finger);
   1.380 @@ -2831,14 +2905,17 @@
   1.381    _collection_set = _inc_cset_head;
   1.382    _collection_set_size = _inc_cset_size;
   1.383    _collection_set_bytes_used_before = _inc_cset_bytes_used_before;
   1.384 -
   1.385 -  // For young regions in the collection set, we assume the worst
   1.386 -  // case of complete survival
   1.387 -  max_live_bytes -= _inc_cset_size * HeapRegion::GrainBytes;
   1.388 -
   1.389    time_remaining_ms -= _inc_cset_predicted_elapsed_time_ms;
   1.390    predicted_pause_time_ms += _inc_cset_predicted_elapsed_time_ms;
   1.391  
   1.392 +  ergo_verbose3(ErgoCSetConstruction | ErgoHigh,
   1.393 +                "add young regions to CSet",
   1.394 +                ergo_format_region("eden")
   1.395 +                ergo_format_region("survivors")
   1.396 +                ergo_format_ms("predicted young region time"),
   1.397 +                eden_region_num, survivor_region_num,
   1.398 +                _inc_cset_predicted_elapsed_time_ms);
   1.399 +
   1.400    // The number of recorded young regions is the incremental
   1.401    // collection set's current size
   1.402    set_recorded_young_regions(_inc_cset_size);
   1.403 @@ -2848,14 +2925,7 @@
   1.404    set_predicted_bytes_to_copy(_inc_cset_predicted_bytes_to_copy);
   1.405  #endif // PREDICTIONS_VERBOSE
   1.406  
   1.407 -  if (G1PolicyVerbose > 0) {
   1.408 -    gclog_or_tty->print_cr("  Added " PTR_FORMAT " Young Regions to CS.",
   1.409 -      _inc_cset_size);
   1.410 -    gclog_or_tty->print_cr("    (" SIZE_FORMAT " KB left in heap.)",
   1.411 -      max_live_bytes/K);
   1.412 -  }
   1.413 -
   1.414 -  assert(_inc_cset_size == _g1->young_list()->length(), "Invariant");
   1.415 +  assert(_inc_cset_size == young_list->length(), "Invariant");
   1.416  
   1.417    double young_end_time_sec = os::elapsedTime();
   1.418    _recorded_young_cset_choice_time_ms =
   1.419 @@ -2869,6 +2939,8 @@
   1.420      NumberSeq seq;
   1.421      double avg_prediction = 100000000000000000.0; // something very large
   1.422  
   1.423 +    size_t prev_collection_set_size = _collection_set_size;
   1.424 +    double prev_predicted_pause_time_ms = predicted_pause_time_ms;
   1.425      do {
   1.426        hr = _collectionSetChooser->getNextMarkedRegion(time_remaining_ms,
   1.427                                                        avg_prediction);
   1.428 @@ -2878,23 +2950,58 @@
   1.429          predicted_pause_time_ms += predicted_time_ms;
   1.430          add_to_collection_set(hr);
   1.431          record_non_young_cset_region(hr);
   1.432 -        max_live_bytes -= MIN2(hr->max_live_bytes(), max_live_bytes);
   1.433 -        if (G1PolicyVerbose > 0) {
   1.434 -          gclog_or_tty->print_cr("    (" SIZE_FORMAT " KB left in heap.)",
   1.435 -                        max_live_bytes/K);
   1.436 -        }
   1.437          seq.add(predicted_time_ms);
   1.438          avg_prediction = seq.avg() + seq.sd();
   1.439        }
   1.440 -      should_continue =
   1.441 -        ( hr != NULL) &&
   1.442 -        ( (adaptive_young_list_length()) ? time_remaining_ms > 0.0
   1.443 -          : _collection_set_size < _young_list_fixed_length );
   1.444 +
   1.445 +      should_continue = true;
   1.446 +      if (hr == NULL) {
   1.447 +        // No need for an ergo verbose message here,
   1.448 +        // getNextMarkRegion() does this when it returns NULL.
   1.449 +        should_continue = false;
   1.450 +      } else {
   1.451 +        if (adaptive_young_list_length()) {
   1.452 +          if (time_remaining_ms < 0.0) {
   1.453 +            ergo_verbose1(ErgoCSetConstruction,
   1.454 +                          "stop adding old regions to CSet",
   1.455 +                          ergo_format_reason("remaining time is lower than 0")
   1.456 +                          ergo_format_ms("remaining time"),
   1.457 +                          time_remaining_ms);
   1.458 +            should_continue = false;
   1.459 +          }
   1.460 +        } else {
   1.461 +          if (_collection_set_size < _young_list_fixed_length) {
   1.462 +            ergo_verbose2(ErgoCSetConstruction,
   1.463 +                          "stop adding old regions to CSet",
   1.464 +                          ergo_format_reason("CSet length lower than target")
   1.465 +                          ergo_format_region("CSet")
   1.466 +                          ergo_format_region("young target"),
   1.467 +                          _collection_set_size, _young_list_fixed_length);
   1.468 +            should_continue = false;
   1.469 +          }
   1.470 +        }
   1.471 +      }
   1.472      } while (should_continue);
   1.473  
   1.474      if (!adaptive_young_list_length() &&
   1.475 -        _collection_set_size < _young_list_fixed_length)
   1.476 +        _collection_set_size < _young_list_fixed_length) {
   1.477 +      ergo_verbose2(ErgoCSetConstruction,
   1.478 +                    "request partially-young GCs end",
   1.479 +                    ergo_format_reason("CSet length lower than target")
   1.480 +                    ergo_format_region("CSet")
   1.481 +                    ergo_format_region("young target"),
   1.482 +                    _collection_set_size, _young_list_fixed_length);
   1.483        _should_revert_to_full_young_gcs  = true;
   1.484 +    }
   1.485 +
   1.486 +    old_region_num = _collection_set_size - prev_collection_set_size;
   1.487 +
   1.488 +    ergo_verbose2(ErgoCSetConstruction | ErgoHigh,
   1.489 +                  "add old regions to CSet",
   1.490 +                  ergo_format_region("old")
   1.491 +                  ergo_format_ms("predicted old region time"),
   1.492 +                  old_region_num,
   1.493 +                  predicted_pause_time_ms - prev_predicted_pause_time_ms);
   1.494    }
   1.495  
   1.496    stop_incremental_cset_building();
   1.497 @@ -2903,6 +3010,16 @@
   1.498  
   1.499    end_recording_regions();
   1.500  
   1.501 +  ergo_verbose5(ErgoCSetConstruction,
   1.502 +                "finish choosing CSet",
   1.503 +                ergo_format_region("eden")
   1.504 +                ergo_format_region("survivors")
   1.505 +                ergo_format_region("old")
   1.506 +                ergo_format_ms("predicted pause time")
   1.507 +                ergo_format_ms("target pause time"),
   1.508 +                eden_region_num, survivor_region_num, old_region_num,
   1.509 +                predicted_pause_time_ms, target_pause_time_ms);
   1.510 +
   1.511    double non_young_end_time_sec = os::elapsedTime();
   1.512    _recorded_non_young_cset_choice_time_ms =
   1.513      (non_young_end_time_sec - non_young_start_time_sec) * 1000.0;
   1.514 @@ -2914,12 +3031,6 @@
   1.515  }
   1.516  
   1.517  void G1CollectorPolicy_BestRegionsFirst::
   1.518 -expand_if_possible(size_t numRegions) {
   1.519 -  size_t expansion_bytes = numRegions * HeapRegion::GrainBytes;
   1.520 -  _g1->expand(expansion_bytes);
   1.521 -}
   1.522 -
   1.523 -void G1CollectorPolicy_BestRegionsFirst::
   1.524  record_collection_pause_end() {
   1.525    G1CollectorPolicy::record_collection_pause_end();
   1.526    assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end.");

mercurial