< prev index next >

src/share/vm/gc/g1/g1IHOPControl.cpp

Print this page
rev 9431 : dihop-changes
rev 9432 : imported patch sihop-thomas-review
rev 9433 : imported patch erik-jmasa-review
rev 9434 : imported patch fix-evac-failure-needs-stats
rev 9435 : imported patch mikael-erik-review
rev 9436 : [mq]: 8136678-implement-adaptive-sizing-algorithm-for-IHOP
rev 9437 : imported patch aihop-thomas-review
rev 9438 : imported patch erik-jon-review2
rev 9439 : imported patch further-jon-reviews
rev 9440 : [mq]: mikael-review


  98   // Whatever we pass, the IHOP value must stay the same.
  99   test_update(&ctrl, 2, 10, 10, 3);
 100   threshold = ctrl.get_conc_mark_start_threshold();
 101   assert(threshold == initial_ihop,
 102          "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
 103 
 104   test_update(&ctrl, 12, 10, 10, 3);
 105   threshold = ctrl.get_conc_mark_start_threshold();
 106   assert(threshold == initial_ihop,
 107          "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
 108 }
 109 #endif
 110 
 111 G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
 112                                              size_t initial_target_occupancy,
 113                                              G1Predictions const* predictor,
 114                                              size_t heap_reserve_percent,
 115                                              size_t heap_waste_percent) :
 116   G1IHOPControl(ihop_percent, initial_target_occupancy),
 117   _predictor(predictor),

 118   _marking_times_s(10, 0.95),
 119   _allocation_rate_s(10, 0.95),
 120   _last_unrestrained_young_size(0),
 121   _heap_reserve_percent(heap_reserve_percent),
 122   _heap_waste_percent(heap_waste_percent)
 123 {
 124 }
 125 
 126 size_t G1AdaptiveIHOPControl::actual_target_threshold() const {
 127   // The actual target threshold takes the heap reserve and the expected waste in
 128   // free space  into account.
 129   // _heap_reserve is that part of the total heap capacity that is reserved for
 130   // eventual promotion failure.
 131   // _heap_waste is the amount of space will never be reclaimed in any
 132   // heap, so can not be used for allocation during marking and must always be
 133   // considered.
 134 
 135   double safe_total_heap_percentage = MIN2((double)(_heap_reserve_percent + _heap_waste_percent), 100.0);
 136 
 137   return MIN2(
 138     G1CollectedHeap::heap()->max_capacity() * (100.0 - safe_total_heap_percentage) / 100.0,
 139     _target_occupancy * (100.0 - _heap_waste_percent) / 100.0
 140     );
 141 }
 142 
 143 bool G1AdaptiveIHOPControl::have_enough_data_for_prediction() const {
 144   return ((size_t)_marking_times_s.num() >= G1AdaptiveIHOPNumInitialSamples) &&
 145          ((size_t)_allocation_rate_s.num() >= G1AdaptiveIHOPNumInitialSamples);
 146 }
 147 
 148 void G1AdaptiveIHOPControl::set_target_occupancy(size_t target_occupancy) {
 149   _target_occupancy = target_occupancy;
 150 }
 151 
 152 size_t G1AdaptiveIHOPControl::get_conc_mark_start_threshold() {
 153   if (have_enough_data_for_prediction()) {
 154     double pred_marking_time = _predictor->get_new_prediction(&_marking_times_s);
 155     double pred_promotion_rate = _predictor->get_new_prediction(&_allocation_rate_s);
 156 
 157     size_t predicted_needed_bytes_during_marking =
 158       (pred_marking_time * pred_promotion_rate +
 159       _last_unrestrained_young_size); // In reality we would need the maximum size of the young gen during marking. This is a conservative estimate.
 160 
 161     size_t internal_threshold = actual_target_threshold();
 162     size_t predicted_initiating_threshold = predicted_needed_bytes_during_marking < internal_threshold ?
 163                                             internal_threshold - predicted_needed_bytes_during_marking :
 164                                             0;
 165     return predicted_initiating_threshold;
 166   } else {
 167     // Use the initial value.
 168     return _initial_ihop_percent * _target_occupancy / 100.0;  
 169   }




  98   // Whatever we pass, the IHOP value must stay the same.
  99   test_update(&ctrl, 2, 10, 10, 3);
 100   threshold = ctrl.get_conc_mark_start_threshold();
 101   assert(threshold == initial_ihop,
 102          "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
 103 
 104   test_update(&ctrl, 12, 10, 10, 3);
 105   threshold = ctrl.get_conc_mark_start_threshold();
 106   assert(threshold == initial_ihop,
 107          "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
 108 }
 109 #endif
 110 
 111 G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
 112                                              size_t initial_target_occupancy,
 113                                              G1Predictions const* predictor,
 114                                              size_t heap_reserve_percent,
 115                                              size_t heap_waste_percent) :
 116   G1IHOPControl(ihop_percent, initial_target_occupancy),
 117   _predictor(predictor),
 118   // A sigma of 0.95 favors more recent samples.
 119   _marking_times_s(10, 0.95),
 120   _allocation_rate_s(10, 0.95),
 121   _last_unrestrained_young_size(0),
 122   _heap_reserve_percent(heap_reserve_percent),
 123   _heap_waste_percent(heap_waste_percent)
 124 {
 125 }
 126 
 127 size_t G1AdaptiveIHOPControl::actual_target_threshold() const {
 128   // The actual target threshold takes the heap reserve and the expected waste in
 129   // free space  into account.
 130   // _heap_reserve is that part of the total heap capacity that is reserved for
 131   // eventual promotion failure.
 132   // _heap_waste is the amount of space will never be reclaimed in any
 133   // heap, so can not be used for allocation during marking and must always be
 134   // considered.
 135 
 136   double safe_total_heap_percentage = MIN2((double)(_heap_reserve_percent + _heap_waste_percent), 100.0);
 137 
 138   return MIN2(
 139     G1CollectedHeap::heap()->max_capacity() * (100.0 - safe_total_heap_percentage) / 100.0,
 140     _target_occupancy * (100.0 - _heap_waste_percent) / 100.0
 141     );
 142 }
 143 
 144 bool G1AdaptiveIHOPControl::have_enough_data_for_prediction() const {
 145   return ((size_t)_marking_times_s.num() >= G1AdaptiveIHOPNumInitialSamples) &&
 146          ((size_t)_allocation_rate_s.num() >= G1AdaptiveIHOPNumInitialSamples);




 147 }
 148 
 149 size_t G1AdaptiveIHOPControl::get_conc_mark_start_threshold() {
 150   if (have_enough_data_for_prediction()) {
 151     double pred_marking_time = _predictor->get_new_prediction(&_marking_times_s);
 152     double pred_promotion_rate = _predictor->get_new_prediction(&_allocation_rate_s);
 153 
 154     size_t predicted_needed_bytes_during_marking =
 155       (pred_marking_time * pred_promotion_rate +
 156       _last_unrestrained_young_size); // In reality we would need the maximum size of the young gen during marking. This is a conservative estimate.
 157 
 158     size_t internal_threshold = actual_target_threshold();
 159     size_t predicted_initiating_threshold = predicted_needed_bytes_during_marking < internal_threshold ?
 160                                             internal_threshold - predicted_needed_bytes_during_marking :
 161                                             0;
 162     return predicted_initiating_threshold;
 163   } else {
 164     // Use the initial value.
 165     return _initial_ihop_percent * _target_occupancy / 100.0;  
 166   }


< prev index next >