1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Mon Jun 28 14:13:18 2010 -0400 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Mon Jun 28 14:13:17 2010 -0400 1.3 @@ -154,7 +154,6 @@ 1.4 _known_garbage_bytes(0), 1.5 1.6 _young_gc_eff_seq(new TruncatedSeq(TruncatedSeqLength)), 1.7 - _target_pause_time_ms(-1.0), 1.8 1.9 _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)), 1.10 1.11 @@ -1635,8 +1634,6 @@ 1.12 double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0; 1.13 adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms); 1.14 // </NEW PREDICTION> 1.15 - 1.16 - _target_pause_time_ms = -1.0; 1.17 } 1.18 1.19 // <NEW PREDICTION> 1.20 @@ -2366,7 +2363,6 @@ 1.21 if (reached_target_length) { 1.22 assert( young_list_length > 0 && _g1->young_list()->length() > 0, 1.23 "invariant" ); 1.24 - _target_pause_time_ms = max_pause_time_ms; 1.25 return true; 1.26 } 1.27 } else { 1.28 @@ -2398,6 +2394,17 @@ 1.29 } 1.30 #endif 1.31 1.32 +bool 1.33 +G1CollectorPolicy::force_initial_mark_if_outside_cycle() { 1.34 + bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle(); 1.35 + if (!during_cycle) { 1.36 + set_initiate_conc_mark_if_possible(); 1.37 + return true; 1.38 + } else { 1.39 + return false; 1.40 + } 1.41 +} 1.42 + 1.43 void 1.44 G1CollectorPolicy::decide_on_conc_mark_initiation() { 1.45 // We are about to decide on whether this pause will be an 1.46 @@ -2864,7 +2871,8 @@ 1.47 #endif // !PRODUCT 1.48 1.49 bool 1.50 -G1CollectorPolicy_BestRegionsFirst::choose_collection_set() { 1.51 +G1CollectorPolicy_BestRegionsFirst::choose_collection_set( 1.52 + double target_pause_time_ms) { 1.53 // Set this here - in case we're not doing young collections. 1.54 double non_young_start_time_sec = os::elapsedTime(); 1.55 1.56 @@ -2877,26 +2885,19 @@ 1.57 1.58 start_recording_regions(); 1.59 1.60 - guarantee(_target_pause_time_ms > -1.0 1.61 - NOT_PRODUCT(|| Universe::heap()->gc_cause() == GCCause::_scavenge_alot), 1.62 - "_target_pause_time_ms should have been set!"); 1.63 -#ifndef PRODUCT 1.64 - if (_target_pause_time_ms <= -1.0) { 1.65 - assert(ScavengeALot && Universe::heap()->gc_cause() == GCCause::_scavenge_alot, "Error"); 1.66 - _target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; 1.67 - } 1.68 -#endif 1.69 - assert(_collection_set == NULL, "Precondition"); 1.70 + guarantee(target_pause_time_ms > 0.0, 1.71 + err_msg("target_pause_time_ms = %1.6lf should be positive", 1.72 + target_pause_time_ms)); 1.73 + guarantee(_collection_set == NULL, "Precondition"); 1.74 1.75 double base_time_ms = predict_base_elapsed_time_ms(_pending_cards); 1.76 double predicted_pause_time_ms = base_time_ms; 1.77 1.78 - double target_time_ms = _target_pause_time_ms; 1.79 - double time_remaining_ms = target_time_ms - base_time_ms; 1.80 + double time_remaining_ms = target_pause_time_ms - base_time_ms; 1.81 1.82 // the 10% and 50% values are arbitrary... 1.83 - if (time_remaining_ms < 0.10*target_time_ms) { 1.84 - time_remaining_ms = 0.50 * target_time_ms; 1.85 + if (time_remaining_ms < 0.10 * target_pause_time_ms) { 1.86 + time_remaining_ms = 0.50 * target_pause_time_ms; 1.87 _within_target = false; 1.88 } else { 1.89 _within_target = true; 1.90 @@ -3059,7 +3060,18 @@ 1.91 _recorded_non_young_cset_choice_time_ms = 1.92 (non_young_end_time_sec - non_young_start_time_sec) * 1000.0; 1.93 1.94 - return abandon_collection; 1.95 + // Here we are supposed to return whether the pause should be 1.96 + // abandoned or not (i.e., whether the collection set is empty or 1.97 + // not). However, this introduces a subtle issue when a pause is 1.98 + // initiated explicitly with System.gc() and 1.99 + // +ExplicitGCInvokesConcurrent (see Comment #2 in CR 6944166), it's 1.100 + // supposed to start a marking cycle, and it's abandoned. So, by 1.101 + // returning false here we are telling the caller never to consider 1.102 + // a pause to be abandoned. We'll actually remove all the code 1.103 + // associated with abandoned pauses as part of CR 6963209, but we are 1.104 + // just disabling them this way for the moment to avoid increasing 1.105 + // further the amount of changes for CR 6944166. 1.106 + return false; 1.107 } 1.108 1.109 void G1CollectorPolicy_BestRegionsFirst::record_full_collection_end() {