8155634: Clean out old logging and dead code from SurvRateGroup
authormgerdin
Wed, 27 Apr 2016 16:20:05 +0200
changeset 38185 c432f8466c73
parent 38184 c149a974c35b
child 38186 ccaa890f8617
8155634: Clean out old logging and dead code from SurvRateGroup Reviewed-by: jmasa, tschatzl, sjohanss
hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp
hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp
hotspot/src/share/vm/gc/g1/g1Policy.hpp
hotspot/src/share/vm/gc/g1/g1_globals.hpp
hotspot/src/share/vm/gc/g1/survRateGroup.cpp
hotspot/src/share/vm/gc/g1/survRateGroup.hpp
hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Wed Apr 27 16:20:05 2016 +0200
@@ -2710,7 +2710,6 @@
 void G1CollectedHeap::print_tracing_info() const {
   g1_rem_set()->print_summary_info();
   concurrent_mark()->print_summary_info();
-  g1_policy()->print_yg_surv_rate_info();
 }
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp	Wed Apr 27 16:20:05 2016 +0200
@@ -54,8 +54,8 @@
   _ihop_control(create_ihop_control(&_predictor)),
   _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)),
   _young_list_fixed_length(0),
-  _short_lived_surv_rate_group(new SurvRateGroup(&_predictor, "Short Lived", G1YoungSurvRateNumRegionsSummary)),
-  _survivor_surv_rate_group(new SurvRateGroup(&_predictor, "Survivor", G1YoungSurvRateNumRegionsSummary)),
+  _short_lived_surv_rate_group(new SurvRateGroup()),
+  _survivor_surv_rate_group(new SurvRateGroup()),
   _reserve_factor((double) G1ReservePercent / 100.0),
   _reserve_regions(0),
   _rs_lengths_prediction(0),
@@ -396,35 +396,29 @@
 
 #ifndef PRODUCT
 bool G1DefaultPolicy::verify_young_ages() {
-  return verify_young_ages(_collection_set->inc_head(), _short_lived_surv_rate_group);
-}
-
-bool G1DefaultPolicy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) {
-  guarantee( surv_rate_group != NULL, "pre-condition" );
-
-  const char* name = surv_rate_group->name();
   bool ret = true;
 
-  for (HeapRegion* curr = head;
+  for (HeapRegion* curr = _collection_set->inc_head();
        curr != NULL;
        curr = curr->next_in_collection_set()) {
+    guarantee(curr->is_young(), "Region must be young");
+
     SurvRateGroup* group = curr->surv_rate_group();
-    if (group == NULL && !curr->is_survivor()) {
-      log_error(gc, verify)("## %s: encountered NULL surv_rate_group", name);
+
+    if (group == NULL) {
+      log_error(gc, verify)("## encountered NULL surv_rate_group in young region");
       ret = false;
     }
 
-    if (surv_rate_group == group) {
-      if (curr->age_in_surv_rate_group() < 0) {
-        log_error(gc, verify)("## %s: encountered negative age", name);
-        ret = false;
-      }
+    if (curr->age_in_surv_rate_group() < 0) {
+      log_error(gc, verify)("## encountered negative age in young region");
+      ret = false;
     }
   }
 
   if (!ret) {
     LogStreamHandle(Error, gc, verify) log;
-    _collection_set->print(head, &log);
+    _collection_set->print(_collection_set->inc_head(), &log);
   }
 
   return ret;
@@ -841,10 +835,6 @@
   return pred;
 }
 
-double G1DefaultPolicy::predict_yg_surv_rate(int age) const {
-  return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
-}
-
 double G1DefaultPolicy::accum_yg_surv_rate_pred(int age) const {
   return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
 }
@@ -898,14 +888,6 @@
   return region_elapsed_time_ms;
 }
 
-
-void G1DefaultPolicy::print_yg_surv_rate_info() const {
-#ifndef PRODUCT
-  _short_lived_surv_rate_group->print_surv_rate_summary();
-  // add this call for any other surv rate groups
-#endif // PRODUCT
-}
-
 bool G1DefaultPolicy::should_allocate_mutator_region() const {
   uint young_list_length = _g1->young_regions_count();
   uint young_list_target_length = _young_list_target_length;
--- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp	Wed Apr 27 16:20:05 2016 +0200
@@ -148,8 +148,8 @@
   void cset_regions_freed() {
     bool update = should_update_surv_rate_group_predictors();
 
-    _short_lived_surv_rate_group->all_surviving_words_recorded(update);
-    _survivor_surv_rate_group->all_surviving_words_recorded(update);
+    _short_lived_surv_rate_group->all_surviving_words_recorded(predictor(), update);
+    _survivor_surv_rate_group->all_surviving_words_recorded(predictor(), update);
   }
 
   G1MMUTracker* mmu_tracker() {
@@ -370,9 +370,6 @@
   // the initial-mark work and start a marking cycle.
   void decide_on_conc_mark_initiation();
 
-  // Print stats on young survival ratio
-  void print_yg_surv_rate_info() const;
-
   void finished_recalculating_age_indexes(bool is_survivors) {
     if (is_survivors) {
       _survivor_surv_rate_group->finished_recalculating_age_indexes();
--- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp	Wed Apr 27 16:20:05 2016 +0200
@@ -156,8 +156,6 @@
   // the initial-mark work and start a marking cycle.
   virtual void decide_on_conc_mark_initiation() = 0;
 
-  // Print stats on young survival ratio
-  virtual void print_yg_surv_rate_info() const = 0;
 
   virtual void finished_recalculating_age_indexes(bool is_survivors) = 0;
 
--- a/hotspot/src/share/vm/gc/g1/g1_globals.hpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1_globals.hpp	Wed Apr 27 16:20:05 2016 +0200
@@ -179,12 +179,6 @@
   develop(bool, G1ScrubRemSets, true,                                       \
           "When true, do RS scrubbing after cleanup.")                      \
                                                                             \
-  develop(intx, G1YoungSurvRateNumRegionsSummary, 0,                        \
-          "the number of regions for which we'll print a surv rate "        \
-          "summary.")                                                       \
-          range(0, max_intx)                                                \
-          constraint(G1YoungSurvRateNumRegionsSummaryConstraintFunc,AfterErgo)\
-                                                                            \
   product(uintx, G1ReservePercent, 10,                                      \
           "It determines the minimum reserve we should have in the heap "   \
           "to minimize the probability of promotion failure.")              \
--- a/hotspot/src/share/vm/gc/g1/survRateGroup.cpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/survRateGroup.cpp	Wed Apr 27 16:20:05 2016 +0200
@@ -30,33 +30,14 @@
 #include "logging/log.hpp"
 #include "memory/allocation.hpp"
 
-SurvRateGroup::SurvRateGroup(G1Predictions* predictor,
-                             const char* name,
-                             size_t summary_surv_rates_len) :
-    _predictor(predictor), _name(name),
-    _summary_surv_rates_len(summary_surv_rates_len),
-    _summary_surv_rates_max_len(0),
-    _summary_surv_rates(NULL),
-    _surv_rate(NULL),
+SurvRateGroup::SurvRateGroup() :
     _accum_surv_rate_pred(NULL),
     _surv_rate_pred(NULL),
     _stats_arrays_length(0) {
   reset();
-  if (summary_surv_rates_len > 0) {
-    size_t length = summary_surv_rates_len;
-      _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length, mtGC);
-    for (size_t i = 0; i < length; ++i) {
-      _summary_surv_rates[i] = new NumberSeq();
-    }
-  }
-
   start_adding_regions();
 }
 
-double SurvRateGroup::get_new_prediction(TruncatedSeq const* seq) const {
-  return _predictor->get_new_prediction(seq);
-}
-
 void SurvRateGroup::reset() {
   _all_regions_allocated = 0;
   _setup_seq_num         = 0;
@@ -73,10 +54,14 @@
   _stats_arrays_length = 0;
 
   stop_adding_regions();
+
+  // Seed initial _surv_rate_pred and _accum_surv_rate_pred values
   guarantee( _stats_arrays_length == 1, "invariant" );
   guarantee( _surv_rate_pred[0] != NULL, "invariant" );
-  _surv_rate_pred[0]->add(0.4);
-  all_surviving_words_recorded(false);
+  const double initial_surv_rate = 0.4;
+  _surv_rate_pred[0]->add(initial_surv_rate);
+  _last_pred = _accum_surv_rate_pred[0] = initial_surv_rate;
+
   _region_num = 0;
 }
 
@@ -87,131 +72,49 @@
 
 void SurvRateGroup::stop_adding_regions() {
   if (_region_num > _stats_arrays_length) {
-    double* old_surv_rate = _surv_rate;
-    double* old_accum_surv_rate_pred = _accum_surv_rate_pred;
-    TruncatedSeq** old_surv_rate_pred = _surv_rate_pred;
+    _accum_surv_rate_pred = REALLOC_C_HEAP_ARRAY(double, _accum_surv_rate_pred, _region_num, mtGC);
+    _surv_rate_pred = REALLOC_C_HEAP_ARRAY(TruncatedSeq*, _surv_rate_pred, _region_num, mtGC);
 
-    _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
-    _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
-    _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num, mtGC);
-
-    for (size_t i = 0; i < _stats_arrays_length; ++i) {
-      _surv_rate_pred[i] = old_surv_rate_pred[i];
-    }
     for (size_t i = _stats_arrays_length; i < _region_num; ++i) {
       _surv_rate_pred[i] = new TruncatedSeq(10);
     }
 
     _stats_arrays_length = _region_num;
-
-    if (old_surv_rate != NULL) {
-      FREE_C_HEAP_ARRAY(double, old_surv_rate);
-    }
-    if (old_accum_surv_rate_pred != NULL) {
-      FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred);
-    }
-    if (old_surv_rate_pred != NULL) {
-      FREE_C_HEAP_ARRAY(TruncatedSeq*, old_surv_rate_pred);
-    }
   }
-
-  for (size_t i = 0; i < _stats_arrays_length; ++i) {
-    _surv_rate[i] = 0.0;
-  }
-}
-
-int SurvRateGroup::next_age_index() {
-  ++_region_num;
-  return (int) ++_all_regions_allocated;
 }
 
 void SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) {
   guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num,
              "pre-condition" );
-  guarantee( _surv_rate[age_in_group] <= 0.00001,
-             "should only update each slot once" );
 
   double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords;
-  _surv_rate[age_in_group] = surv_rate;
   _surv_rate_pred[age_in_group]->add(surv_rate);
-  if ((size_t)age_in_group < _summary_surv_rates_len) {
-    _summary_surv_rates[age_in_group]->add(surv_rate);
-    if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len)
-      _summary_surv_rates_max_len = age_in_group+1;
+}
+
+void SurvRateGroup::all_surviving_words_recorded(const G1Predictions& predictor, bool update_predictors) {
+  if (update_predictors) {
+    fill_in_last_surv_rates();
+  }
+  finalize_predictions(predictor);
+}
+
+void SurvRateGroup::fill_in_last_surv_rates() {
+  if (_region_num > 0) { // conservative
+    double surv_rate = _surv_rate_pred[_region_num-1]->last();
+    for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
+      _surv_rate_pred[i]->add(surv_rate);
+    }
   }
 }
 
-void SurvRateGroup::all_surviving_words_recorded(bool update_predictors) {
-  if (update_predictors && _region_num > 0) { // conservative
-    double surv_rate = _surv_rate_pred[_region_num-1]->last();
-    for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
-      guarantee( _surv_rate[i] <= 0.00001,
-                 "the slot should not have been updated" );
-      _surv_rate_pred[i]->add(surv_rate);
-    }
-  }
-
+void SurvRateGroup::finalize_predictions(const G1Predictions& predictor) {
   double accum = 0.0;
   double pred = 0.0;
   for (size_t i = 0; i < _stats_arrays_length; ++i) {
-    pred = get_new_prediction(_surv_rate_pred[i]);
+    pred = predictor.get_new_prediction(_surv_rate_pred[i]);
     if (pred > 1.0) pred = 1.0;
     accum += pred;
     _accum_surv_rate_pred[i] = accum;
   }
   _last_pred = pred;
 }
-
-#ifndef PRODUCT
-void SurvRateGroup::print() {
-  log_develop_trace(gc, survivor)("Surv Rate Group: %s (" SIZE_FORMAT " entries)", _name, _region_num);
-  for (size_t i = 0; i < _region_num; ++i) {
-    log_develop_trace(gc, survivor)("    age " SIZE_FORMAT_W(4) "   surv rate %6.2lf %%   pred %6.2lf %%",
-                                    i, _surv_rate[i] * 100.0,
-                                    _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0);
-  }
-}
-
-void
-SurvRateGroup::print_surv_rate_summary() {
-  size_t length = _summary_surv_rates_max_len;
-  if (length == 0)
-    return;
-
-  log_trace(gc, survivor)("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1);
-  log_trace(gc, survivor)("      age range     survival rate (avg)      samples (avg)");
-  log_trace(gc, survivor)("  ---------------------------------------------------------");
-
-  size_t index = 0;
-  size_t limit = MIN2((int) length, 10);
-  while (index < limit) {
-    log_trace(gc, survivor)("           " SIZE_FORMAT_W(4) "                 %6.2lf%%             %6.2lf",
-                            index, _summary_surv_rates[index]->avg() * 100.0,
-                            (double) _summary_surv_rates[index]->num());
-    ++index;
-  }
-
-  log_trace(gc, survivor)("  ---------------------------------------------------------");
-
-  int num = 0;
-  double sum = 0.0;
-  int samples = 0;
-  while (index < length) {
-    ++num;
-    sum += _summary_surv_rates[index]->avg() * 100.0;
-    samples += _summary_surv_rates[index]->num();
-    ++index;
-
-    if (index == length || num % 10 == 0) {
-      log_trace(gc, survivor)("   " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4) "                 %6.2lf%%             %6.2lf",
-                              (index-1) / 10 * 10, index-1, sum / (double) num,
-                              (double) samples / (double) num);
-      sum = 0.0;
-      num = 0;
-      samples = 0;
-    }
-  }
-
-  log_trace(gc, survivor)("  ---------------------------------------------------------");
-}
-#endif // PRODUCT
--- a/hotspot/src/share/vm/gc/g1/survRateGroup.hpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/survRateGroup.hpp	Wed Apr 27 16:20:05 2016 +0200
@@ -31,37 +31,27 @@
 
 class SurvRateGroup : public CHeapObj<mtGC> {
 private:
-  G1Predictions* _predictor;
-
-  double get_new_prediction(TruncatedSeq const* seq) const;
-
-  const char* _name;
-
   size_t  _stats_arrays_length;
-  double* _surv_rate;
   double* _accum_surv_rate_pred;
   double  _last_pred;
   TruncatedSeq** _surv_rate_pred;
-  NumberSeq**    _summary_surv_rates;
-  size_t         _summary_surv_rates_len;
-  size_t         _summary_surv_rates_max_len;
 
   int _all_regions_allocated;
   size_t _region_num;
   size_t _setup_seq_num;
 
+  void fill_in_last_surv_rates();
+  void finalize_predictions(const G1Predictions& predictor);
 public:
-  SurvRateGroup(G1Predictions* predictor,
-                const char* name,
-                size_t summary_surv_rates_len);
+  SurvRateGroup();
   void reset();
   void start_adding_regions();
   void stop_adding_regions();
   void record_surviving_words(int age_in_group, size_t surv_words);
-  void all_surviving_words_recorded(bool update_predictors);
-  const char* name() { return _name; }
+  void all_surviving_words_recorded(const G1Predictions& predictor, bool update_predictors);
 
-  size_t region_num() { return _region_num; }
+  size_t region_num() const { return _region_num; }
+
   double accum_surv_rate_pred(int age) const {
     assert(age >= 0, "must be");
     if ((size_t)age < _stats_arrays_length)
@@ -82,8 +72,12 @@
     return seq;
   }
 
-  int next_age_index();
-  int age_in_group(int age_index) {
+  int next_age_index() {
+    ++_region_num;
+    return (int) ++_all_regions_allocated;
+  }
+
+  int age_in_group(int age_index) const {
     int ret = (int) (_all_regions_allocated - age_index);
     assert( ret >= 0, "invariant" );
     return ret;
@@ -92,10 +86,6 @@
     _all_regions_allocated = 0;
   }
 
-#ifndef PRODUCT
-  void print();
-  void print_surv_rate_summary();
-#endif // PRODUCT
 };
 
 #endif // SHARE_VM_GC_G1_SURVRATEGROUP_HPP
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Wed Apr 27 16:20:05 2016 +0200
@@ -312,20 +312,6 @@
   }
 }
 
-Flag::Error G1YoungSurvRateNumRegionsSummaryConstraintFunc(intx value, bool verbose) {
-  if (!UseG1GC) return Flag::SUCCESS;
-
-  if (value > (intx)HeapRegionBounds::target_number()) {
-    CommandLineError::print(verbose,
-                            "G1YoungSurvRateNumRegionsSummary (" INTX_FORMAT ") must be "
-                            "less than or equal to region count (" SIZE_FORMAT ")\n",
-                            value, HeapRegionBounds::target_number());
-    return Flag::VIOLATES_CONSTRAINT;
-  } else {
-    return Flag::SUCCESS;
-  }
-}
-
 Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) {
   if (!UseG1GC) return Flag::SUCCESS;
 
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp	Wed May 04 10:06:00 2016 +0200
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp	Wed Apr 27 16:20:05 2016 +0200
@@ -49,7 +49,6 @@
 #if INCLUDE_ALL_GCS
 Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose);
 Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose);
-Flag::Error G1YoungSurvRateNumRegionsSummaryConstraintFunc(intx value, bool verbose);
 Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose);
 Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose);
 Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose);