< prev index next >

src/hotspot/share/gc/g1/g1Policy.cpp

Print this page

        

@@ -66,12 +66,12 @@
   _survivor_surv_rate_group(new SurvRateGroup()),
   _reserve_factor((double) G1ReservePercent / 100.0),
   _reserve_regions(0),
   _young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
   _free_regions_at_end_of_collection(0),
-  _max_rs_length(0),
-  _rs_length_prediction(0),
+  _max_rs_lengths(0),
+  _rs_lengths_prediction(0),
   _pending_cards(0),
   _bytes_allocated_in_old_since_last_gc(0),
   _initial_mark_to_mixed(),
   _collection_set(NULL),
   _bytes_copied_during_gc(0),

@@ -217,27 +217,27 @@
   // effectively don't set this bound.
   return _young_gen_sizer->max_desired_young_length();
 }
 
 uint G1Policy::update_young_list_max_and_target_length() {
-  return update_young_list_max_and_target_length(_analytics->predict_rs_length());
+  return update_young_list_max_and_target_length(_analytics->predict_rs_lengths());
 }
 
-uint G1Policy::update_young_list_max_and_target_length(size_t rs_length) {
-  uint unbounded_target_length = update_young_list_target_length(rs_length);
+uint G1Policy::update_young_list_max_and_target_length(size_t rs_lengths) {
+  uint unbounded_target_length = update_young_list_target_length(rs_lengths);
   update_max_gc_locker_expansion();
   return unbounded_target_length;
 }
 
-uint G1Policy::update_young_list_target_length(size_t rs_length) {
-  YoungTargetLengths young_lengths = young_list_target_lengths(rs_length);
+uint G1Policy::update_young_list_target_length(size_t rs_lengths) {
+  YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths);
   _young_list_target_length = young_lengths.first;
 
   return young_lengths.second;
 }
 
-G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_length) const {
+G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengths) const {
   YoungTargetLengths result;
 
   // Calculate the absolute and desired min bounds first.
 
   // This is how many young regions we already have (currently: the survivors).

@@ -254,11 +254,11 @@
 
   uint young_list_target_length = 0;
   if (use_adaptive_young_list_length()) {
     if (collector_state()->in_young_only_phase()) {
       young_list_target_length =
-                        calculate_young_list_target_length(rs_length,
+                        calculate_young_list_target_length(rs_lengths,
                                                            base_min_length,
                                                            desired_min_length,
                                                            desired_max_length);
     } else {
       // Don't calculate anything and let the code below bound it to

@@ -299,11 +299,11 @@
   result.first = young_list_target_length;
   return result;
 }
 
 uint
-G1Policy::calculate_young_list_target_length(size_t rs_length,
+G1Policy::calculate_young_list_target_length(size_t rs_lengths,
                                                     uint base_min_length,
                                                     uint desired_min_length,
                                                     uint desired_max_length) const {
   assert(use_adaptive_young_list_length(), "pre-condition");
   assert(collector_state()->in_young_only_phase(), "only call this for young GCs");

@@ -324,12 +324,12 @@
   uint max_young_length = desired_max_length - base_min_length;
 
   const double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0;
   const double survivor_regions_evac_time = predict_survivor_regions_evac_time();
   const size_t pending_cards = _analytics->predict_pending_cards();
-  const size_t adj_rs_length = rs_length + _analytics->predict_rs_length_diff();
-  const size_t scanned_cards = _analytics->predict_card_num(adj_rs_length, true /* for_young_gc */);
+  const size_t adj_rs_lengths = rs_lengths + _analytics->predict_rs_length_diff();
+  const size_t scanned_cards = _analytics->predict_card_num(adj_rs_lengths, true /* for_young_gc */);
   const double base_time_ms =
     predict_base_elapsed_time_ms(pending_cards, scanned_cards) +
     survivor_regions_evac_time;
   const uint available_free_regions = _free_regions_at_end_of_collection;
   const uint base_free_regions =

@@ -412,29 +412,29 @@
     survivor_regions_evac_time += predict_region_elapsed_time_ms(*it, collector_state()->in_young_only_phase());
   }
   return survivor_regions_evac_time;
 }
 
-void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_length) {
+void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_lengths) {
   guarantee(use_adaptive_young_list_length(), "should not call this otherwise" );
 
-  if (rs_length > _rs_length_prediction) {
+  if (rs_lengths > _rs_lengths_prediction) {
     // add 10% to avoid having to recalculate often
-    size_t rs_length_prediction = rs_length * 1100 / 1000;
-    update_rs_length_prediction(rs_length_prediction);
+    size_t rs_lengths_prediction = rs_lengths * 1100 / 1000;
+    update_rs_lengths_prediction(rs_lengths_prediction);
 
-    update_young_list_max_and_target_length(rs_length_prediction);
+    update_young_list_max_and_target_length(rs_lengths_prediction);
   }
 }
 
-void G1Policy::update_rs_length_prediction() {
-  update_rs_length_prediction(_analytics->predict_rs_length());
+void G1Policy::update_rs_lengths_prediction() {
+  update_rs_lengths_prediction(_analytics->predict_rs_lengths());
 }
 
-void G1Policy::update_rs_length_prediction(size_t prediction) {
+void G1Policy::update_rs_lengths_prediction(size_t prediction) {
   if (collector_state()->in_young_only_phase() && use_adaptive_young_list_length()) {
-    _rs_length_prediction = prediction;
+    _rs_lengths_prediction = prediction;
   }
 }
 
 void G1Policy::record_full_collection_start() {
   _full_collection_start_sec = os::elapsedTime();

@@ -469,11 +469,11 @@
 
   _free_regions_at_end_of_collection = _g1h->num_free_regions();
   // Reset survivors SurvRateGroup.
   _survivor_surv_rate_group->reset();
   update_young_list_max_and_target_length();
-  update_rs_length_prediction();
+  update_rs_lengths_prediction();
 
   _bytes_allocated_in_old_since_last_gc = 0;
 
   record_pause(FullGC, _full_collection_start_sec, end_sec);
 }

@@ -570,28 +570,14 @@
   }
 
   return result;
 }
 
-double G1Policy::logged_cards_processing_time() const {
-  double all_cards_processing_time = average_time_ms(G1GCPhaseTimes::ScanHR) + average_time_ms(G1GCPhaseTimes::OptScanHR);
-  size_t logged_dirty_cards = phase_times()->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards);
-  size_t scan_heap_roots_cards = phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanHR, G1GCPhaseTimes::ScanHRScannedCards) +
-                                 phase_times()->sum_thread_work_items(G1GCPhaseTimes::OptScanHR, G1GCPhaseTimes::ScanHRScannedCards);
-  // This may happen if there are duplicate cards in different log buffers.
-  if (logged_dirty_cards > scan_heap_roots_cards) {
-    return all_cards_processing_time + average_time_ms(G1GCPhaseTimes::MergeLB);
-  }
-  return (all_cards_processing_time * logged_dirty_cards / scan_heap_roots_cards) + average_time_ms(G1GCPhaseTimes::MergeLB);
-}
-
 // Anything below that is considered to be zero
 #define MIN_TIMER_GRANULARITY 0.0000001
 
-void G1Policy::record_collection_pause_end(double pause_time_ms, size_t heap_used_bytes_before_gc) {
-  G1GCPhaseTimes* p = phase_times();
-
+void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) {
   double end_time_sec = os::elapsedTime();
 
   assert_used_and_recalculate_used_equal(_g1h);
   size_t cur_used_bytes = _g1h->used();
   bool this_pause_included_initial_mark = false;

@@ -657,66 +643,53 @@
   }
 
   _short_lived_surv_rate_group->start_adding_regions();
   // Do that for any other surv rate groups
 
-  double scan_hcc_time_ms = G1HotCardCache::default_use_cache() ? average_time_ms(G1GCPhaseTimes::MergeHCC) : 0.0;
+  double scan_hcc_time_ms = G1HotCardCache::default_use_cache() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0;
 
   if (update_stats) {
-    double cost_per_logged_card = 0.0;
-    size_t const pending_logged_cards = p->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards);
-    if (pending_logged_cards > 0) {
-      cost_per_logged_card = logged_cards_processing_time() / pending_logged_cards;
-      _analytics->report_cost_per_logged_card_ms(cost_per_logged_card);
+    double cost_per_card_ms = 0.0;
+    if (_pending_cards > 0) {
+      cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS)) / (double) _pending_cards;
+      _analytics->report_cost_per_card_ms(cost_per_card_ms);
     }
     _analytics->report_cost_scan_hcc(scan_hcc_time_ms);
 
-    size_t const total_cards_scanned = p->sum_thread_work_items(G1GCPhaseTimes::ScanHR, G1GCPhaseTimes::ScanHRScannedCards) +
-                                       p->sum_thread_work_items(G1GCPhaseTimes::OptScanHR, G1GCPhaseTimes::ScanHRScannedCards);
-    size_t remset_cards_scanned = 0;
-    // There might have been duplicate log buffer entries in the queues which could
-    // increase this value beyond the cards scanned. In this case attribute all cards
-    // to the log buffers.
-    if (pending_logged_cards <= total_cards_scanned) {
-      remset_cards_scanned = total_cards_scanned - pending_logged_cards;
-    }
-
-    double cost_per_remset_card_ms = 0.0;
-    if (remset_cards_scanned > 10) {
-      double avg_time_remset_scan = ((average_time_ms(G1GCPhaseTimes::ScanHR) + average_time_ms(G1GCPhaseTimes::OptScanHR)) *
-                                     remset_cards_scanned / total_cards_scanned) +
-                                     average_time_ms(G1GCPhaseTimes::MergeER) +
-                                     average_time_ms(G1GCPhaseTimes::MergeRS) +
-                                     average_time_ms(G1GCPhaseTimes::OptMergeRS);
-
-      cost_per_remset_card_ms = avg_time_remset_scan / remset_cards_scanned;
-      _analytics->report_cost_per_remset_card_ms(cost_per_remset_card_ms, this_pause_was_young_only);
+    double cost_per_entry_ms = 0.0;
+    if (cards_scanned > 10) {
+      double avg_time_scan_rs = average_time_ms(G1GCPhaseTimes::ScanRS);
+      if (this_pause_was_young_only) {
+        avg_time_scan_rs += average_time_ms(G1GCPhaseTimes::OptScanRS);
+      }
+      cost_per_entry_ms = avg_time_scan_rs / cards_scanned;
+      _analytics->report_cost_per_entry_ms(cost_per_entry_ms, this_pause_was_young_only);
     }
 
-    if (_max_rs_length > 0) {
+    if (_max_rs_lengths > 0) {
       double cards_per_entry_ratio =
-        (double) remset_cards_scanned / (double) _max_rs_length;
+        (double) cards_scanned / (double) _max_rs_lengths;
       _analytics->report_cards_per_entry_ratio(cards_per_entry_ratio, this_pause_was_young_only);
     }
 
-    // This is defensive. For a while _max_rs_length could get
-    // smaller than _recorded_rs_length which was causing
+    // This is defensive. For a while _max_rs_lengths could get
+    // smaller than _recorded_rs_lengths which was causing
     // rs_length_diff to get very large and mess up the RSet length
     // predictions. The reason was unsafe concurrent updates to the
-    // _inc_cset_recorded_rs_length field which the code below guards
+    // _inc_cset_recorded_rs_lengths field which the code below guards
     // against (see CR 7118202). This bug has now been fixed (see CR
     // 7119027). However, I'm still worried that
-    // _inc_cset_recorded_rs_length might still end up somewhat
+    // _inc_cset_recorded_rs_lengths might still end up somewhat
     // inaccurate. The concurrent refinement thread calculates an
     // RSet's length concurrently with other CR threads updating it
     // which might cause it to calculate the length incorrectly (if,
     // say, it's in mid-coarsening). So I'll leave in the defensive
     // conditional below just in case.
     size_t rs_length_diff = 0;
-    size_t recorded_rs_length = _collection_set->recorded_rs_length();
-    if (_max_rs_length > recorded_rs_length) {
-      rs_length_diff = _max_rs_length - recorded_rs_length;
+    size_t recorded_rs_lengths = _collection_set->recorded_rs_lengths();
+    if (_max_rs_lengths > recorded_rs_lengths) {
+      rs_length_diff = _max_rs_lengths - recorded_rs_lengths;
     }
     _analytics->report_rs_length_diff((double) rs_length_diff);
 
     size_t freed_bytes = heap_used_bytes_before_gc - cur_used_bytes;
     size_t copied_bytes = _collection_set->bytes_used_before() - freed_bytes;

@@ -743,11 +716,11 @@
     // these are is wildly different to during young only gc and mess up young gen sizing right
     // after the mixed gc phase.
     // During mixed gc we do not use them for young gen sizing.
     if (this_pause_was_young_only) {
       _analytics->report_pending_cards((double) _pending_cards);
-      _analytics->report_rs_length((double) _max_rs_length);
+      _analytics->report_rs_lengths((double) _max_rs_lengths);
     }
   }
 
   assert(!(this_pause_included_initial_mark && collector_state()->mark_or_rebuild_in_progress()),
          "If the last pause has been an initial mark, we should not have been in the marking window");

@@ -755,11 +728,11 @@
     collector_state()->set_mark_or_rebuild_in_progress(true);
   }
 
   _free_regions_at_end_of_collection = _g1h->num_free_regions();
 
-  update_rs_length_prediction();
+  update_rs_lengths_prediction();
 
   // Do not update dynamic IHOP due to G1 periodic collection as it is highly likely
   // that in this case we are not running in a "normal" operating mode.
   if (_g1h->gc_cause() != GCCause::_g1_periodic_collection) {
     // IHOP control wants to know the expected young gen length if it were not

@@ -784,30 +757,24 @@
     // the mark start being too late.
     _initial_mark_to_mixed.reset();
   }
 
   // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
-  double scan_logged_cards_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
+  double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
 
-  if (scan_logged_cards_time_goal_ms < scan_hcc_time_ms) {
+  if (update_rs_time_goal_ms < scan_hcc_time_ms) {
     log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)."
-                                "Logged Cards Scan time goal: %1.2fms Scan HCC time: %1.2fms",
-                                scan_logged_cards_time_goal_ms, scan_hcc_time_ms);
+                                "Update RS time goal: %1.2fms Scan HCC time: %1.2fms",
+                                update_rs_time_goal_ms, scan_hcc_time_ms);
 
-    scan_logged_cards_time_goal_ms = 0;
+    update_rs_time_goal_ms = 0;
   } else {
-    scan_logged_cards_time_goal_ms -= scan_hcc_time_ms;
+    update_rs_time_goal_ms -= scan_hcc_time_ms;
   }
-
-  double const logged_cards_time = logged_cards_processing_time();
-
-  log_debug(gc, ergo, refine)("Concurrent refinement times: Logged Cards Scan time goal: %1.2fms Logged Cards Scan time: %1.2fms HCC time: %1.2fms",
-                              scan_logged_cards_time_goal_ms, logged_cards_time, scan_hcc_time_ms);
-
-  _g1h->concurrent_refine()->adjust(logged_cards_time,
-                                    phase_times()->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards),
-                                    scan_logged_cards_time_goal_ms);
+  _g1h->concurrent_refine()->adjust(average_time_ms(G1GCPhaseTimes::UpdateRS),
+                                    phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS),
+                                    update_rs_time_goal_ms);
 }
 
 G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){
   if (G1UseAdaptiveIHOP) {
     return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent,

@@ -887,11 +854,11 @@
     _analytics->predict_rs_scan_time_ms(scanned_cards, collector_state()->in_young_only_phase()) +
     _analytics->predict_constant_other_time_ms();
 }
 
 double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards) const {
-  size_t rs_length = _analytics->predict_rs_length() + _analytics->predict_rs_length_diff();
+  size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff();
   size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->in_young_only_phase());
   return predict_base_elapsed_time_ms(pending_cards, card_num);
 }
 
 size_t G1Policy::predict_bytes_to_copy(HeapRegion* hr) const {
< prev index next >