< prev index next >

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

Print this page
rev 9416 : dihop-changes
rev 9418 : imported patch erik-jmasa-review
rev 9419 : [mq]: fix-evac-failure-needs-stats


1192       _non_young_other_cost_per_region_ms_seq->add(non_young_other_time_ms() /
1193                                                    old_cset_region_length());
1194     }
1195 
1196     _constant_other_time_ms_seq->add(constant_other_time_ms(pause_time_ms));
1197 
1198     _pending_cards_seq->add((double) _pending_cards);
1199     _rs_lengths_seq->add((double) _max_rs_lengths);
1200   }
1201 
1202   collector_state()->set_in_marking_window(new_in_marking_window);
1203   collector_state()->set_in_marking_window_im(new_in_marking_window_im);
1204   _free_regions_at_end_of_collection = _g1->num_free_regions();
1205   // IHOP control wants to know the expected young gen length if it were not
1206   // restrained by the heap reserve. Using the actual length would make the
1207   // prediction too small and the limit the young gen every time we get to the
1208   // predicted target occupancy.
1209   size_t last_unrestrained_young_length = update_young_list_max_and_target_length();
1210   update_rs_lengths_prediction();
1211 
1212   // Only update IHOP information on regular GCs.
1213   if (update_stats) {
1214     double marking_to_mixed_time = -1.0;
1215     if (!collector_state()->last_gc_was_young() && _initial_mark_to_mixed.has_result()) {
1216       marking_to_mixed_time = _initial_mark_to_mixed.last_marking_time();
1217       assert(marking_to_mixed_time > 0.0,
1218              "Initial mark to mixed time must be larger than zero but is %.3f",
1219              marking_to_mixed_time);
1220     }
1221 
1222     update_ihop_statistics(marking_to_mixed_time,
1223                            app_time_ms / 1000.0,
1224                            _last_old_allocated_bytes,
1225                            last_unrestrained_young_length * HeapRegion::GrainBytes);
1226   }
1227   _last_old_allocated_bytes = 0;
1228 
1229   // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
1230   double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
1231 
1232   double scan_hcc_time_ms = average_time_ms(G1GCPhaseTimes::ScanHCC);
1233 
1234   if (update_rs_time_goal_ms < scan_hcc_time_ms) {
1235     ergo_verbose2(ErgoTiming,
1236                   "adjust concurrent refinement thresholds",
1237                   ergo_format_reason("Scanning the HCC expected to take longer than Update RS time goal")
1238                   ergo_format_ms("Update RS time goal")
1239                   ergo_format_ms("Scan HCC time"),
1240                   update_rs_time_goal_ms,
1241                   scan_hcc_time_ms);
1242 
1243     update_rs_time_goal_ms = 0;
1244   } else {
1245     update_rs_time_goal_ms -= scan_hcc_time_ms;
1246   }
1247   adjust_concurrent_refinement(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms,
1248                                phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS),
1249                                update_rs_time_goal_ms);
1250 
1251   _collectionSetChooser->verify();
1252 }
1253 
1254 G1IHOPControl* G1CollectorPolicy::create_ihop_control() const {
1255   return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent,
1256                                  G1CollectedHeap::heap()->max_capacity());
1257 }
1258 
1259 void G1CollectorPolicy::update_ihop_statistics(double marking_time,
1260                                                double mutator_time_s,
1261                                                size_t mutator_alloc_bytes,
1262                                                size_t young_gen_size) {
1263   bool report = false;

1264 
1265   // To avoid using really small times that may be caused by e.g. back-to-back gcs
1266   // we filter them out.
1267   double const min_valid_time = 1e-6;
1268 
1269   if (marking_time > min_valid_time) {
1270     _ihop_control->update_marking_length(marking_time);








1271     report = true;

1272   }
1273 
1274   // As an approximation for the young gc promotion rates during marking we use
1275   // all of them. In many applications there are only a few if any young gcs during
1276   // marking, which makes any prediction useless. This increases the accuracy of the
1277   // prediction.
1278   if (collector_state()->last_gc_was_young() && mutator_time_s > min_valid_time) {
1279     _ihop_control->update_allocation_info(mutator_time_s, mutator_alloc_bytes, young_gen_size);
1280     report = true;
1281   }
1282 
1283   if (report) {
1284     report_ihop_statistics();
1285   }
1286 }
1287 
1288 void G1CollectorPolicy::report_ihop_statistics() {
1289   _ihop_control->print();
1290 }
1291 




1192       _non_young_other_cost_per_region_ms_seq->add(non_young_other_time_ms() /
1193                                                    old_cset_region_length());
1194     }
1195 
1196     _constant_other_time_ms_seq->add(constant_other_time_ms(pause_time_ms));
1197 
1198     _pending_cards_seq->add((double) _pending_cards);
1199     _rs_lengths_seq->add((double) _max_rs_lengths);
1200   }
1201 
1202   collector_state()->set_in_marking_window(new_in_marking_window);
1203   collector_state()->set_in_marking_window_im(new_in_marking_window_im);
1204   _free_regions_at_end_of_collection = _g1->num_free_regions();
1205   // IHOP control wants to know the expected young gen length if it were not
1206   // restrained by the heap reserve. Using the actual length would make the
1207   // prediction too small and the limit the young gen every time we get to the
1208   // predicted target occupancy.
1209   size_t last_unrestrained_young_length = update_young_list_max_and_target_length();
1210   update_rs_lengths_prediction();
1211 
1212   update_ihop_prediction(app_time_ms / 1000.0,











1213                          _last_old_allocated_bytes,
1214                          last_unrestrained_young_length * HeapRegion::GrainBytes);

1215   _last_old_allocated_bytes = 0;
1216 
1217   // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
1218   double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
1219 
1220   double scan_hcc_time_ms = average_time_ms(G1GCPhaseTimes::ScanHCC);
1221 
1222   if (update_rs_time_goal_ms < scan_hcc_time_ms) {
1223     ergo_verbose2(ErgoTiming,
1224                   "adjust concurrent refinement thresholds",
1225                   ergo_format_reason("Scanning the HCC expected to take longer than Update RS time goal")
1226                   ergo_format_ms("Update RS time goal")
1227                   ergo_format_ms("Scan HCC time"),
1228                   update_rs_time_goal_ms,
1229                   scan_hcc_time_ms);
1230 
1231     update_rs_time_goal_ms = 0;
1232   } else {
1233     update_rs_time_goal_ms -= scan_hcc_time_ms;
1234   }
1235   adjust_concurrent_refinement(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms,
1236                                phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS),
1237                                update_rs_time_goal_ms);
1238 
1239   _collectionSetChooser->verify();
1240 }
1241 
1242 G1IHOPControl* G1CollectorPolicy::create_ihop_control() const {
1243   return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent,
1244                                  G1CollectedHeap::heap()->max_capacity());
1245 }
1246 
1247 void G1CollectorPolicy::update_ihop_prediction(double mutator_time_s,

1248                                                size_t mutator_alloc_bytes,
1249                                                size_t young_gen_size) {
1250   // Always try to update IHOP prediction. Even evacuation failures give information
1251   // about e.g. whether to start IHOP earlier next time.
1252 
1253   // Avoid using really small application times that might create samples with
1254   // very high or very low values. They may be caused by e.g. back-to-back gcs.
1255   double const min_valid_time = 1e-6;
1256 
1257   bool report = false;
1258 
1259   double marking_to_mixed_time = -1.0;
1260   if (!collector_state()->last_gc_was_young() && _initial_mark_to_mixed.has_result()) {
1261     marking_to_mixed_time = _initial_mark_to_mixed.last_marking_time();
1262     assert(marking_to_mixed_time > 0.0,
1263            "Initial mark to mixed time must be larger than zero but is %.3f",
1264            marking_to_mixed_time);
1265     if (marking_to_mixed_time > min_valid_time) {
1266       _ihop_control->update_marking_length(marking_to_mixed_time);
1267       report = true;
1268     }
1269   }
1270 
1271   // As an approximation for the young gc promotion rates during marking we use
1272   // all of them. In many applications there are only a few if any young gcs during
1273   // marking, which makes any prediction useless. This increases the accuracy of the
1274   // prediction.
1275   if (collector_state()->last_gc_was_young() && mutator_time_s > min_valid_time) {
1276     _ihop_control->update_allocation_info(mutator_time_s, mutator_alloc_bytes, young_gen_size);
1277     report = true;
1278   }
1279 
1280   if (report) {
1281     report_ihop_statistics();
1282   }
1283 }
1284 
1285 void G1CollectorPolicy::report_ihop_statistics() {
1286   _ihop_control->print();
1287 }
1288 


< prev index next >