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

changeset 3337
41406797186b
parent 3326
d23d2b18183e
child 3356
67fdcb391461
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Dec 14 17:43:55 2011 -0800
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Fri Dec 16 02:14:27 2011 -0500
     1.3 @@ -50,7 +50,7 @@
     1.4  };
     1.5  
     1.6  // all the same
     1.7 -static double fully_young_cards_per_entry_ratio_defaults[] = {
     1.8 +static double young_cards_per_entry_ratio_defaults[] = {
     1.9    1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
    1.10  };
    1.11  
    1.12 @@ -168,11 +168,10 @@
    1.13    _pending_card_diff_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.14    _rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.15    _cost_per_card_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.16 -  _fully_young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.17 -  _partially_young_cards_per_entry_ratio_seq(
    1.18 -                                         new TruncatedSeq(TruncatedSeqLength)),
    1.19 +  _young_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.20 +  _mixed_cards_per_entry_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.21    _cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.22 -  _partially_young_cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.23 +  _mixed_cost_per_entry_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.24    _cost_per_byte_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.25    _cost_per_byte_ms_during_cm_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.26    _constant_other_time_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.27 @@ -185,9 +184,9 @@
    1.28  
    1.29    _pause_time_target_ms((double) MaxGCPauseMillis),
    1.30  
    1.31 -  _full_young_gcs(true),
    1.32 -  _full_young_pause_num(0),
    1.33 -  _partial_young_pause_num(0),
    1.34 +  _gcs_are_young(true),
    1.35 +  _young_pause_num(0),
    1.36 +  _mixed_pause_num(0),
    1.37  
    1.38    _during_marking(false),
    1.39    _in_marking_window(false),
    1.40 @@ -198,7 +197,8 @@
    1.41  
    1.42    _young_gc_eff_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.43  
    1.44 -   _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)),
    1.45 +  _recent_prev_end_times_for_all_gcs_sec(
    1.46 +                                new TruncatedSeq(NumPrevPausesForHeuristics)),
    1.47  
    1.48    _recent_avg_pause_time_ratio(0.0),
    1.49  
    1.50 @@ -206,8 +206,9 @@
    1.51  
    1.52    _initiate_conc_mark_if_possible(false),
    1.53    _during_initial_mark_pause(false),
    1.54 -  _should_revert_to_full_young_gcs(false),
    1.55 -  _last_full_young_gc(false),
    1.56 +  _should_revert_to_young_gcs(false),
    1.57 +  _last_young_gc(false),
    1.58 +  _last_gc_was_young(false),
    1.59  
    1.60    _eden_bytes_before_gc(0),
    1.61    _survivor_bytes_before_gc(0),
    1.62 @@ -308,8 +309,8 @@
    1.63    _pending_card_diff_seq->add(0.0);
    1.64    _rs_length_diff_seq->add(rs_length_diff_defaults[index]);
    1.65    _cost_per_card_ms_seq->add(cost_per_card_ms_defaults[index]);
    1.66 -  _fully_young_cards_per_entry_ratio_seq->add(
    1.67 -                            fully_young_cards_per_entry_ratio_defaults[index]);
    1.68 +  _young_cards_per_entry_ratio_seq->add(
    1.69 +                                  young_cards_per_entry_ratio_defaults[index]);
    1.70    _cost_per_entry_ms_seq->add(cost_per_entry_ms_defaults[index]);
    1.71    _cost_per_byte_ms_seq->add(cost_per_byte_ms_defaults[index]);
    1.72    _constant_other_time_ms_seq->add(constant_other_time_ms_defaults[index]);
    1.73 @@ -606,7 +607,7 @@
    1.74  
    1.75    size_t young_list_target_length = 0;
    1.76    if (adaptive_young_list_length()) {
    1.77 -    if (full_young_gcs()) {
    1.78 +    if (gcs_are_young()) {
    1.79        young_list_target_length =
    1.80                          calculate_young_list_target_length(rs_lengths,
    1.81                                                             base_min_length,
    1.82 @@ -619,10 +620,10 @@
    1.83        // possible to maximize how many old regions we can add to it.
    1.84      }
    1.85    } else {
    1.86 -    if (full_young_gcs()) {
    1.87 +    if (gcs_are_young()) {
    1.88        young_list_target_length = _young_list_fixed_length;
    1.89      } else {
    1.90 -      // A bit arbitrary: during partially-young GCs we allocate half
    1.91 +      // A bit arbitrary: during mixed GCs we allocate half
    1.92        // the young regions to try to add old regions to the CSet.
    1.93        young_list_target_length = _young_list_fixed_length / 2;
    1.94        // We choose to accept that we might go under the desired min
    1.95 @@ -655,7 +656,7 @@
    1.96                                                     size_t desired_min_length,
    1.97                                                     size_t desired_max_length) {
    1.98    assert(adaptive_young_list_length(), "pre-condition");
    1.99 -  assert(full_young_gcs(), "only call this for fully-young GCs");
   1.100 +  assert(gcs_are_young(), "only call this for young GCs");
   1.101  
   1.102    // In case some edge-condition makes the desired max length too small...
   1.103    if (desired_max_length <= desired_min_length) {
   1.104 @@ -858,12 +859,11 @@
   1.105  
   1.106    _g1->clear_full_collection();
   1.107  
   1.108 -  // "Nuke" the heuristics that control the fully/partially young GC
   1.109 -  // transitions and make sure we start with fully young GCs after the
   1.110 -  // Full GC.
   1.111 -  set_full_young_gcs(true);
   1.112 -  _last_full_young_gc = false;
   1.113 -  _should_revert_to_full_young_gcs = false;
   1.114 +  // "Nuke" the heuristics that control the young/mixed GC
   1.115 +  // transitions and make sure we start with young GCs after the Full GC.
   1.116 +  set_gcs_are_young(true);
   1.117 +  _last_young_gc = false;
   1.118 +  _should_revert_to_young_gcs = false;
   1.119    clear_initiate_conc_mark_if_possible();
   1.120    clear_during_initial_mark_pause();
   1.121    _known_garbage_bytes = 0;
   1.122 @@ -892,7 +892,7 @@
   1.123    if (PrintGCDetails) {
   1.124      gclog_or_tty->stamp(PrintGCTimeStamps);
   1.125      gclog_or_tty->print("[GC pause");
   1.126 -    gclog_or_tty->print(" (%s)", full_young_gcs() ? "young" : "partial");
   1.127 +    gclog_or_tty->print(" (%s)", gcs_are_young() ? "young" : "mixed");
   1.128    }
   1.129  
   1.130    // We only need to do this here as the policy will only be applied
   1.131 @@ -951,7 +951,7 @@
   1.132    // the evacuation pause if marking is in progress.
   1.133    _cur_satb_drain_time_ms = 0.0;
   1.134  
   1.135 -  _last_young_gc_full = false;
   1.136 +  _last_gc_was_young = false;
   1.137  
   1.138    // do that for any other surv rate groups
   1.139    _short_lived_surv_rate_group->stop_adding_regions();
   1.140 @@ -988,8 +988,8 @@
   1.141  }
   1.142  
   1.143  void G1CollectorPolicy::record_concurrent_mark_cleanup_completed() {
   1.144 -  _should_revert_to_full_young_gcs = false;
   1.145 -  _last_full_young_gc = true;
   1.146 +  _should_revert_to_young_gcs = false;
   1.147 +  _last_young_gc = true;
   1.148    _in_marking_window = false;
   1.149  }
   1.150  
   1.151 @@ -1153,7 +1153,7 @@
   1.152    size_t marking_initiating_used_threshold =
   1.153      (_g1->capacity() / 100) * InitiatingHeapOccupancyPercent;
   1.154  
   1.155 -  if (!_g1->mark_in_progress() && !_last_full_young_gc) {
   1.156 +  if (!_g1->mark_in_progress() && !_last_young_gc) {
   1.157      assert(!last_pause_included_initial_mark, "invariant");
   1.158      if (cur_used_bytes > marking_initiating_used_threshold) {
   1.159        if (cur_used_bytes > _prev_collection_pause_used_at_end_bytes) {
   1.160 @@ -1458,57 +1458,57 @@
   1.161      new_in_marking_window_im = true;
   1.162    }
   1.163  
   1.164 -  if (_last_full_young_gc) {
   1.165 +  if (_last_young_gc) {
   1.166      if (!last_pause_included_initial_mark) {
   1.167 -      ergo_verbose2(ErgoPartiallyYoungGCs,
   1.168 -                    "start partially-young GCs",
   1.169 +      ergo_verbose2(ErgoMixedGCs,
   1.170 +                    "start mixed GCs",
   1.171                      ergo_format_byte_perc("known garbage"),
   1.172                      _known_garbage_bytes, _known_garbage_ratio * 100.0);
   1.173 -      set_full_young_gcs(false);
   1.174 +      set_gcs_are_young(false);
   1.175      } else {
   1.176 -      ergo_verbose0(ErgoPartiallyYoungGCs,
   1.177 -                    "do not start partially-young GCs",
   1.178 +      ergo_verbose0(ErgoMixedGCs,
   1.179 +                    "do not start mixed GCs",
   1.180                      ergo_format_reason("concurrent cycle is about to start"));
   1.181      }
   1.182 -    _last_full_young_gc = false;
   1.183 +    _last_young_gc = false;
   1.184    }
   1.185  
   1.186 -  if ( !_last_young_gc_full ) {
   1.187 -    if (_should_revert_to_full_young_gcs) {
   1.188 -      ergo_verbose2(ErgoPartiallyYoungGCs,
   1.189 -                    "end partially-young GCs",
   1.190 -                    ergo_format_reason("partially-young GCs end requested")
   1.191 +  if (!_last_gc_was_young) {
   1.192 +    if (_should_revert_to_young_gcs) {
   1.193 +      ergo_verbose2(ErgoMixedGCs,
   1.194 +                    "end mixed GCs",
   1.195 +                    ergo_format_reason("mixed GCs end requested")
   1.196                      ergo_format_byte_perc("known garbage"),
   1.197                      _known_garbage_bytes, _known_garbage_ratio * 100.0);
   1.198 -      set_full_young_gcs(true);
   1.199 +      set_gcs_are_young(true);
   1.200      } else if (_known_garbage_ratio < 0.05) {
   1.201 -      ergo_verbose3(ErgoPartiallyYoungGCs,
   1.202 -               "end partially-young GCs",
   1.203 +      ergo_verbose3(ErgoMixedGCs,
   1.204 +               "end mixed GCs",
   1.205                 ergo_format_reason("known garbage percent lower than threshold")
   1.206                 ergo_format_byte_perc("known garbage")
   1.207                 ergo_format_perc("threshold"),
   1.208                 _known_garbage_bytes, _known_garbage_ratio * 100.0,
   1.209                 0.05 * 100.0);
   1.210 -      set_full_young_gcs(true);
   1.211 +      set_gcs_are_young(true);
   1.212      } else if (adaptive_young_list_length() &&
   1.213                (get_gc_eff_factor() * cur_efficiency < predict_young_gc_eff())) {
   1.214 -      ergo_verbose5(ErgoPartiallyYoungGCs,
   1.215 -                    "end partially-young GCs",
   1.216 +      ergo_verbose5(ErgoMixedGCs,
   1.217 +                    "end mixed GCs",
   1.218                      ergo_format_reason("current GC efficiency lower than "
   1.219 -                                       "predicted fully-young GC efficiency")
   1.220 +                                       "predicted young GC efficiency")
   1.221                      ergo_format_double("GC efficiency factor")
   1.222                      ergo_format_double("current GC efficiency")
   1.223 -                    ergo_format_double("predicted fully-young GC efficiency")
   1.224 +                    ergo_format_double("predicted young GC efficiency")
   1.225                      ergo_format_byte_perc("known garbage"),
   1.226                      get_gc_eff_factor(), cur_efficiency,
   1.227                      predict_young_gc_eff(),
   1.228                      _known_garbage_bytes, _known_garbage_ratio * 100.0);
   1.229 -      set_full_young_gcs(true);
   1.230 +      set_gcs_are_young(true);
   1.231      }
   1.232    }
   1.233 -  _should_revert_to_full_young_gcs = false;
   1.234 -
   1.235 -  if (_last_young_gc_full && !_during_marking) {
   1.236 +  _should_revert_to_young_gcs = false;
   1.237 +
   1.238 +  if (_last_gc_was_young && !_during_marking) {
   1.239      _young_gc_eff_seq->add(cur_efficiency);
   1.240    }
   1.241  
   1.242 @@ -1534,19 +1534,21 @@
   1.243      double cost_per_entry_ms = 0.0;
   1.244      if (cards_scanned > 10) {
   1.245        cost_per_entry_ms = scan_rs_time / (double) cards_scanned;
   1.246 -      if (_last_young_gc_full)
   1.247 +      if (_last_gc_was_young) {
   1.248          _cost_per_entry_ms_seq->add(cost_per_entry_ms);
   1.249 -      else
   1.250 -        _partially_young_cost_per_entry_ms_seq->add(cost_per_entry_ms);
   1.251 +      } else {
   1.252 +        _mixed_cost_per_entry_ms_seq->add(cost_per_entry_ms);
   1.253 +      }
   1.254      }
   1.255  
   1.256      if (_max_rs_lengths > 0) {
   1.257        double cards_per_entry_ratio =
   1.258          (double) cards_scanned / (double) _max_rs_lengths;
   1.259 -      if (_last_young_gc_full)
   1.260 -        _fully_young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
   1.261 -      else
   1.262 -        _partially_young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
   1.263 +      if (_last_gc_was_young) {
   1.264 +        _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
   1.265 +      } else {
   1.266 +        _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio);
   1.267 +      }
   1.268      }
   1.269  
   1.270      // It turns out that, sometimes, _max_rs_lengths can get smaller
   1.271 @@ -1563,10 +1565,11 @@
   1.272      double cost_per_byte_ms = 0.0;
   1.273      if (copied_bytes > 0) {
   1.274        cost_per_byte_ms = obj_copy_time / (double) copied_bytes;
   1.275 -      if (_in_marking_window)
   1.276 +      if (_in_marking_window) {
   1.277          _cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms);
   1.278 -      else
   1.279 +      } else {
   1.280          _cost_per_byte_ms_seq->add(cost_per_byte_ms);
   1.281 +      }
   1.282      }
   1.283  
   1.284      double all_other_time_ms = pause_time_ms -
   1.285 @@ -1722,10 +1725,11 @@
   1.286    size_t rs_lengths = g1h->young_list()->sampled_rs_lengths() +
   1.287                        predict_rs_length_diff();
   1.288    size_t card_num;
   1.289 -  if (full_young_gcs())
   1.290 +  if (gcs_are_young()) {
   1.291      card_num = predict_young_card_num(rs_lengths);
   1.292 -  else
   1.293 +  } else {
   1.294      card_num = predict_non_young_card_num(rs_lengths);
   1.295 +  }
   1.296    size_t young_byte_size = young_num * HeapRegion::GrainBytes;
   1.297    double accum_yg_surv_rate =
   1.298      _short_lived_surv_rate_group->accum_surv_rate(adjustment);
   1.299 @@ -1745,10 +1749,11 @@
   1.300  G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards) {
   1.301    size_t rs_length = predict_rs_length_diff();
   1.302    size_t card_num;
   1.303 -  if (full_young_gcs())
   1.304 +  if (gcs_are_young()) {
   1.305      card_num = predict_young_card_num(rs_length);
   1.306 -  else
   1.307 +  } else {
   1.308      card_num = predict_non_young_card_num(rs_length);
   1.309 +  }
   1.310    return predict_base_elapsed_time_ms(pending_cards, card_num);
   1.311  }
   1.312  
   1.313 @@ -1766,10 +1771,11 @@
   1.314                                                    bool young) {
   1.315    size_t rs_length = hr->rem_set()->occupied();
   1.316    size_t card_num;
   1.317 -  if (full_young_gcs())
   1.318 +  if (gcs_are_young()) {
   1.319      card_num = predict_young_card_num(rs_length);
   1.320 -  else
   1.321 +  } else {
   1.322      card_num = predict_non_young_card_num(rs_length);
   1.323 +  }
   1.324    size_t bytes_to_copy = predict_bytes_to_copy(hr);
   1.325  
   1.326    double region_elapsed_time_ms =
   1.327 @@ -1817,14 +1823,14 @@
   1.328    // I don't think we need to do this when in young GC mode since
   1.329    // marking will be initiated next time we hit the soft limit anyway...
   1.330    if (predicted_time_ms > _expensive_region_limit_ms) {
   1.331 -    ergo_verbose2(ErgoPartiallyYoungGCs,
   1.332 -              "request partially-young GCs end",
   1.333 +    ergo_verbose2(ErgoMixedGCs,
   1.334 +              "request mixed GCs end",
   1.335                ergo_format_reason("predicted region time higher than threshold")
   1.336                ergo_format_ms("predicted region time")
   1.337                ergo_format_ms("threshold"),
   1.338                predicted_time_ms, _expensive_region_limit_ms);
   1.339 -    // no point in doing another partial one
   1.340 -    _should_revert_to_full_young_gcs = true;
   1.341 +    // no point in doing another mixed GC
   1.342 +    _should_revert_to_young_gcs = true;
   1.343    }
   1.344  }
   1.345  
   1.346 @@ -2033,8 +2039,8 @@
   1.347      print_summary_sd(0, "Total", _all_pause_times_ms);
   1.348      gclog_or_tty->print_cr("");
   1.349      gclog_or_tty->print_cr("");
   1.350 -    gclog_or_tty->print_cr("   Full Young GC Pauses:    %8d", _full_young_pause_num);
   1.351 -    gclog_or_tty->print_cr("   Partial Young GC Pauses: %8d", _partial_young_pause_num);
   1.352 +    gclog_or_tty->print_cr("   Young GC Pauses: %8d", _young_pause_num);
   1.353 +    gclog_or_tty->print_cr("   Mixed GC Pauses: %8d", _mixed_pause_num);
   1.354      gclog_or_tty->print_cr("");
   1.355  
   1.356      gclog_or_tty->print_cr("EVACUATION PAUSES");
   1.357 @@ -2188,11 +2194,11 @@
   1.358        // initiate a new cycle.
   1.359  
   1.360        set_during_initial_mark_pause();
   1.361 -      // We do not allow non-full young GCs during marking.
   1.362 -      if (!full_young_gcs()) {
   1.363 -        set_full_young_gcs(true);
   1.364 -        ergo_verbose0(ErgoPartiallyYoungGCs,
   1.365 -                      "end partially-young GCs",
   1.366 +      // We do not allow mixed GCs during marking.
   1.367 +      if (!gcs_are_young()) {
   1.368 +        set_gcs_are_young(true);
   1.369 +        ergo_verbose0(ErgoMixedGCs,
   1.370 +                      "end mixed GCs",
   1.371                        ergo_format_reason("concurrent cycle is about to start"));
   1.372        }
   1.373  
   1.374 @@ -2623,12 +2629,12 @@
   1.375    double young_start_time_sec = os::elapsedTime();
   1.376  
   1.377    _collection_set_bytes_used_before = 0;
   1.378 -  _last_young_gc_full = full_young_gcs() ? true : false;
   1.379 -
   1.380 -  if (_last_young_gc_full) {
   1.381 -    ++_full_young_pause_num;
   1.382 +  _last_gc_was_young = gcs_are_young() ? true : false;
   1.383 +
   1.384 +  if (_last_gc_was_young) {
   1.385 +    ++_young_pause_num;
   1.386    } else {
   1.387 -    ++_partial_young_pause_num;
   1.388 +    ++_mixed_pause_num;
   1.389    }
   1.390  
   1.391    // The young list is laid with the survivor regions from the previous
   1.392 @@ -2675,7 +2681,7 @@
   1.393    // We are doing young collections so reset this.
   1.394    non_young_start_time_sec = young_end_time_sec;
   1.395  
   1.396 -  if (!full_young_gcs()) {
   1.397 +  if (!gcs_are_young()) {
   1.398      bool should_continue = true;
   1.399      NumberSeq seq;
   1.400      double avg_prediction = 100000000000000000.0; // something very large
   1.401 @@ -2732,14 +2738,14 @@
   1.402      } while (should_continue);
   1.403  
   1.404      if (!adaptive_young_list_length() &&
   1.405 -                             cset_region_length() < _young_list_fixed_length) {
   1.406 +        cset_region_length() < _young_list_fixed_length) {
   1.407        ergo_verbose2(ErgoCSetConstruction,
   1.408 -                    "request partially-young GCs end",
   1.409 +                    "request mixed GCs end",
   1.410                      ergo_format_reason("CSet length lower than target")
   1.411                      ergo_format_region("CSet")
   1.412                      ergo_format_region("young target"),
   1.413                      cset_region_length(), _young_list_fixed_length);
   1.414 -      _should_revert_to_full_young_gcs  = true;
   1.415 +      _should_revert_to_young_gcs  = true;
   1.416      }
   1.417  
   1.418      ergo_verbose2(ErgoCSetConstruction | ErgoHigh,

mercurial