1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Tue Nov 23 13:22:55 2010 -0800 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Tue Aug 24 17:24:33 2010 -0400 1.3 @@ -458,8 +458,8 @@ 1.4 double now_sec = os::elapsedTime(); 1.5 double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0; 1.6 double alloc_rate_ms = predict_alloc_rate_ms(); 1.7 - int min_regions = (int) ceil(alloc_rate_ms * when_ms); 1.8 - int current_region_num = (int) _g1->young_list()->length(); 1.9 + size_t min_regions = (size_t) ceil(alloc_rate_ms * when_ms); 1.10 + size_t current_region_num = _g1->young_list()->length(); 1.11 _young_list_min_length = min_regions + current_region_num; 1.12 } 1.13 } 1.14 @@ -473,9 +473,12 @@ 1.15 _young_list_target_length = _young_list_fixed_length; 1.16 else 1.17 _young_list_target_length = _young_list_fixed_length / 2; 1.18 - 1.19 - _young_list_target_length = MAX2(_young_list_target_length, (size_t)1); 1.20 } 1.21 + 1.22 + // Make sure we allow the application to allocate at least one 1.23 + // region before we need to do a collection again. 1.24 + size_t min_length = _g1->young_list()->length() + 1; 1.25 + _young_list_target_length = MAX2(_young_list_target_length, min_length); 1.26 calculate_survivors_policy(); 1.27 } 1.28 1.29 @@ -568,7 +571,7 @@ 1.30 1.31 // we should have at least one region in the target young length 1.32 _young_list_target_length = 1.33 - MAX2((size_t) 1, final_young_length + _recorded_survivor_regions); 1.34 + final_young_length + _recorded_survivor_regions; 1.35 1.36 // let's keep an eye of how long we spend on this calculation 1.37 // right now, I assume that we'll print it when we need it; we 1.38 @@ -617,8 +620,7 @@ 1.39 _young_list_min_length); 1.40 #endif // TRACE_CALC_YOUNG_LENGTH 1.41 // we'll do the pause as soon as possible by choosing the minimum 1.42 - _young_list_target_length = 1.43 - MAX2(_young_list_min_length, (size_t) 1); 1.44 + _young_list_target_length = _young_list_min_length; 1.45 } 1.46 1.47 _rs_lengths_prediction = rs_lengths; 1.48 @@ -801,7 +803,7 @@ 1.49 _survivor_surv_rate_group->reset(); 1.50 calculate_young_list_min_length(); 1.51 calculate_young_list_target_length(); 1.52 - } 1.53 +} 1.54 1.55 void G1CollectorPolicy::record_before_bytes(size_t bytes) { 1.56 _bytes_in_to_space_before_gc += bytes; 1.57 @@ -824,9 +826,9 @@ 1.58 gclog_or_tty->print(" (%s)", full_young_gcs() ? "young" : "partial"); 1.59 } 1.60 1.61 - assert(_g1->used_regions() == _g1->recalculate_used_regions(), 1.62 - "sanity"); 1.63 - assert(_g1->used() == _g1->recalculate_used(), "sanity"); 1.64 + assert(_g1->used() == _g1->recalculate_used(), 1.65 + err_msg("sanity, used: "SIZE_FORMAT" recalculate_used: "SIZE_FORMAT, 1.66 + _g1->used(), _g1->recalculate_used())); 1.67 1.68 double s_w_t_ms = (start_time_sec - _stop_world_start) * 1000.0; 1.69 _all_stop_world_times_ms->add(s_w_t_ms); 1.70 @@ -2266,24 +2268,13 @@ 1.71 #endif // PRODUCT 1.72 } 1.73 1.74 -bool 1.75 -G1CollectorPolicy::should_add_next_region_to_young_list() { 1.76 - assert(in_young_gc_mode(), "should be in young GC mode"); 1.77 - bool ret; 1.78 - size_t young_list_length = _g1->young_list()->length(); 1.79 - size_t young_list_max_length = _young_list_target_length; 1.80 - if (G1FixedEdenSize) { 1.81 - young_list_max_length -= _max_survivor_regions; 1.82 - } 1.83 - if (young_list_length < young_list_max_length) { 1.84 - ret = true; 1.85 +void 1.86 +G1CollectorPolicy::update_region_num(bool young) { 1.87 + if (young) { 1.88 ++_region_num_young; 1.89 } else { 1.90 - ret = false; 1.91 ++_region_num_tenured; 1.92 } 1.93 - 1.94 - return ret; 1.95 } 1.96 1.97 #ifndef PRODUCT 1.98 @@ -2327,32 +2318,6 @@ 1.99 } 1.100 } 1.101 1.102 -bool 1.103 -G1CollectorPolicy_BestRegionsFirst::should_do_collection_pause(size_t 1.104 - word_size) { 1.105 - assert(_g1->regions_accounted_for(), "Region leakage!"); 1.106 - double max_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; 1.107 - 1.108 - size_t young_list_length = _g1->young_list()->length(); 1.109 - size_t young_list_max_length = _young_list_target_length; 1.110 - if (G1FixedEdenSize) { 1.111 - young_list_max_length -= _max_survivor_regions; 1.112 - } 1.113 - bool reached_target_length = young_list_length >= young_list_max_length; 1.114 - 1.115 - if (in_young_gc_mode()) { 1.116 - if (reached_target_length) { 1.117 - assert( young_list_length > 0 && _g1->young_list()->length() > 0, 1.118 - "invariant" ); 1.119 - return true; 1.120 - } 1.121 - } else { 1.122 - guarantee( false, "should not reach here" ); 1.123 - } 1.124 - 1.125 - return false; 1.126 -} 1.127 - 1.128 #ifndef PRODUCT 1.129 class HRSortIndexIsOKClosure: public HeapRegionClosure { 1.130 CollectionSetChooser* _chooser;