1101 abort_time_to_mixed_tracking(); 1102 } 1103 1104 collector_state()->set_last_young_gc(false); 1105 } 1106 1107 if (!collector_state()->last_gc_was_young()) { 1108 // This is a mixed GC. Here we decide whether to continue doing 1109 // mixed GCs or not. 1110 if (!next_gc_should_be_mixed("continue mixed GCs", 1111 "do not continue mixed GCs")) { 1112 collector_state()->set_gcs_are_young(true); 1113 1114 maybe_start_marking(); 1115 } 1116 } 1117 1118 _short_lived_surv_rate_group->start_adding_regions(); 1119 // Do that for any other surv rate groups 1120 1121 if (update_stats) { 1122 double cost_per_card_ms = 0.0; 1123 double cost_scan_hcc = average_time_ms(G1GCPhaseTimes::ScanHCC); 1124 if (_pending_cards > 0) { 1125 cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS) - cost_scan_hcc) / (double) _pending_cards; 1126 _cost_per_card_ms_seq->add(cost_per_card_ms); 1127 } 1128 _cost_scan_hcc_seq->add(cost_scan_hcc); 1129 1130 double cost_per_entry_ms = 0.0; 1131 if (cards_scanned > 10) { 1132 cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned; 1133 if (collector_state()->last_gc_was_young()) { 1134 _cost_per_entry_ms_seq->add(cost_per_entry_ms); 1135 } else { 1136 _mixed_cost_per_entry_ms_seq->add(cost_per_entry_ms); 1137 } 1138 } 1139 1140 if (_max_rs_lengths > 0) { 1141 double cards_per_entry_ratio = 1142 (double) cards_scanned / (double) _max_rs_lengths; 1143 if (collector_state()->last_gc_was_young()) { 1144 _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio); 1145 } else { 1146 _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio); 1147 } 1148 } 1197 1198 collector_state()->set_in_marking_window(new_in_marking_window); 1199 collector_state()->set_in_marking_window_im(new_in_marking_window_im); 1200 _free_regions_at_end_of_collection = _g1->num_free_regions(); 1201 // IHOP control wants to know the expected young gen length if it were not 1202 // restrained by the heap reserve. Using the actual length would make the 1203 // prediction too small and the limit the young gen every time we get to the 1204 // predicted target occupancy. 1205 size_t last_unrestrained_young_length = update_young_list_max_and_target_length(); 1206 update_rs_lengths_prediction(); 1207 1208 update_ihop_prediction(app_time_ms / 1000.0, 1209 _bytes_allocated_in_old_since_last_gc, 1210 last_unrestrained_young_length * HeapRegion::GrainBytes); 1211 _bytes_allocated_in_old_since_last_gc = 0; 1212 1213 _ihop_control->send_trace_event(_g1->gc_tracer_stw()); 1214 1215 // Note that _mmu_tracker->max_gc_time() returns the time in seconds. 1216 double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0; 1217 1218 double scan_hcc_time_ms = average_time_ms(G1GCPhaseTimes::ScanHCC); 1219 1220 if (update_rs_time_goal_ms < scan_hcc_time_ms) { 1221 log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)." 1222 "Update RS time goal: %1.2fms Scan HCC time: %1.2fms", 1223 update_rs_time_goal_ms, scan_hcc_time_ms); 1224 1225 update_rs_time_goal_ms = 0; 1226 } else { 1227 update_rs_time_goal_ms -= scan_hcc_time_ms; 1228 } 1229 adjust_concurrent_refinement(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms, 1230 phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS), 1231 update_rs_time_goal_ms); 1232 1233 cset_chooser()->verify(); 1234 } 1235 1236 G1IHOPControl* G1CollectorPolicy::create_ihop_control() const { 1237 if (G1UseAdaptiveIHOP) { 1238 return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent, | 1101 abort_time_to_mixed_tracking(); 1102 } 1103 1104 collector_state()->set_last_young_gc(false); 1105 } 1106 1107 if (!collector_state()->last_gc_was_young()) { 1108 // This is a mixed GC. Here we decide whether to continue doing 1109 // mixed GCs or not. 1110 if (!next_gc_should_be_mixed("continue mixed GCs", 1111 "do not continue mixed GCs")) { 1112 collector_state()->set_gcs_are_young(true); 1113 1114 maybe_start_marking(); 1115 } 1116 } 1117 1118 _short_lived_surv_rate_group->start_adding_regions(); 1119 // Do that for any other surv rate groups 1120 1121 double scan_hcc_time_ms = ConcurrentG1Refine::hot_card_cache_enabled() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0; 1122 1123 if (update_stats) { 1124 double cost_per_card_ms = 0.0; 1125 if (_pending_cards > 0) { 1126 cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms) / (double) _pending_cards; 1127 _cost_per_card_ms_seq->add(cost_per_card_ms); 1128 } 1129 _cost_scan_hcc_seq->add(scan_hcc_time_ms); 1130 1131 double cost_per_entry_ms = 0.0; 1132 if (cards_scanned > 10) { 1133 cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned; 1134 if (collector_state()->last_gc_was_young()) { 1135 _cost_per_entry_ms_seq->add(cost_per_entry_ms); 1136 } else { 1137 _mixed_cost_per_entry_ms_seq->add(cost_per_entry_ms); 1138 } 1139 } 1140 1141 if (_max_rs_lengths > 0) { 1142 double cards_per_entry_ratio = 1143 (double) cards_scanned / (double) _max_rs_lengths; 1144 if (collector_state()->last_gc_was_young()) { 1145 _young_cards_per_entry_ratio_seq->add(cards_per_entry_ratio); 1146 } else { 1147 _mixed_cards_per_entry_ratio_seq->add(cards_per_entry_ratio); 1148 } 1149 } 1198 1199 collector_state()->set_in_marking_window(new_in_marking_window); 1200 collector_state()->set_in_marking_window_im(new_in_marking_window_im); 1201 _free_regions_at_end_of_collection = _g1->num_free_regions(); 1202 // IHOP control wants to know the expected young gen length if it were not 1203 // restrained by the heap reserve. Using the actual length would make the 1204 // prediction too small and the limit the young gen every time we get to the 1205 // predicted target occupancy. 1206 size_t last_unrestrained_young_length = update_young_list_max_and_target_length(); 1207 update_rs_lengths_prediction(); 1208 1209 update_ihop_prediction(app_time_ms / 1000.0, 1210 _bytes_allocated_in_old_since_last_gc, 1211 last_unrestrained_young_length * HeapRegion::GrainBytes); 1212 _bytes_allocated_in_old_since_last_gc = 0; 1213 1214 _ihop_control->send_trace_event(_g1->gc_tracer_stw()); 1215 1216 // Note that _mmu_tracker->max_gc_time() returns the time in seconds. 1217 double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0; 1218 1219 if (update_rs_time_goal_ms < scan_hcc_time_ms) { 1220 log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)." 1221 "Update RS time goal: %1.2fms Scan HCC time: %1.2fms", 1222 update_rs_time_goal_ms, scan_hcc_time_ms); 1223 1224 update_rs_time_goal_ms = 0; 1225 } else { 1226 update_rs_time_goal_ms -= scan_hcc_time_ms; 1227 } 1228 adjust_concurrent_refinement(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms, 1229 phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS), 1230 update_rs_time_goal_ms); 1231 1232 cset_chooser()->verify(); 1233 } 1234 1235 G1IHOPControl* G1CollectorPolicy::create_ihop_control() const { 1236 if (G1UseAdaptiveIHOP) { 1237 return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent, |