Fri, 18 Nov 2011 12:52:27 -0500
7097002: G1: remove a lot of unused / redundant code from the G1CollectorPolicy class
Summary: Major cleanup of the G1CollectorPolicy class. It removes a lot of unused fields and methods and also consolidates replicated information (mainly various ways of counting the number of CSet regions) into one copy.
Reviewed-by: johnc, brutisso
1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Nov 17 13:14:49 2011 -0500 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Nov 18 12:52:27 2011 -0500 1.3 @@ -176,8 +176,7 @@ 1.4 hr->set_next_young_region(_head); 1.5 _head = hr; 1.6 1.7 - hr->set_young(); 1.8 - double yg_surv_rate = _g1h->g1_policy()->predict_yg_surv_rate((int)_length); 1.9 + _g1h->g1_policy()->set_region_eden(hr, (int) _length); 1.10 ++_length; 1.11 } 1.12 1.13 @@ -190,7 +189,6 @@ 1.14 _survivor_tail = hr; 1.15 } 1.16 _survivor_head = hr; 1.17 - 1.18 ++_survivor_length; 1.19 } 1.20 1.21 @@ -315,16 +313,20 @@ 1.22 _g1h->g1_policy()->note_start_adding_survivor_regions(); 1.23 _g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */); 1.24 1.25 + int young_index_in_cset = 0; 1.26 for (HeapRegion* curr = _survivor_head; 1.27 curr != NULL; 1.28 curr = curr->get_next_young_region()) { 1.29 - _g1h->g1_policy()->set_region_survivors(curr); 1.30 + _g1h->g1_policy()->set_region_survivor(curr, young_index_in_cset); 1.31 1.32 // The region is a non-empty survivor so let's add it to 1.33 // the incremental collection set for the next evacuation 1.34 // pause. 1.35 _g1h->g1_policy()->add_region_to_incremental_cset_rhs(curr); 1.36 - } 1.37 + young_index_in_cset += 1; 1.38 + } 1.39 + assert((size_t) young_index_in_cset == _survivor_length, 1.40 + "post-condition"); 1.41 _g1h->g1_policy()->note_stop_adding_survivor_regions(); 1.42 1.43 _head = _survivor_head; 1.44 @@ -3210,8 +3212,6 @@ 1.45 } 1.46 } 1.47 1.48 -// <NEW PREDICTION> 1.49 - 1.50 double G1CollectedHeap::predict_region_elapsed_time_ms(HeapRegion *hr, 1.51 bool young) { 1.52 return _g1_policy->predict_region_elapsed_time_ms(hr, young); 1.53 @@ -3251,7 +3251,7 @@ 1.54 void 1.55 G1CollectedHeap::setup_surviving_young_words() { 1.56 guarantee( _surviving_young_words == NULL, "pre-condition" ); 1.57 - size_t array_length = g1_policy()->young_cset_length(); 1.58 + size_t array_length = g1_policy()->young_cset_region_length(); 1.59 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, array_length); 1.60 if (_surviving_young_words == NULL) { 1.61 vm_exit_out_of_memory(sizeof(size_t) * array_length, 1.62 @@ -3268,7 +3268,7 @@ 1.63 void 1.64 G1CollectedHeap::update_surviving_young_words(size_t* surv_young_words) { 1.65 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); 1.66 - size_t array_length = g1_policy()->young_cset_length(); 1.67 + size_t array_length = g1_policy()->young_cset_region_length(); 1.68 for (size_t i = 0; i < array_length; ++i) 1.69 _surviving_young_words[i] += surv_young_words[i]; 1.70 } 1.71 @@ -3280,8 +3280,6 @@ 1.72 _surviving_young_words = NULL; 1.73 } 1.74 1.75 -// </NEW PREDICTION> 1.76 - 1.77 #ifdef ASSERT 1.78 class VerifyCSetClosure: public HeapRegionClosure { 1.79 public: 1.80 @@ -4158,7 +4156,7 @@ 1.81 // non-young regions (where the age is -1) 1.82 // We also add a few elements at the beginning and at the end in 1.83 // an attempt to eliminate cache contention 1.84 - size_t real_length = 1 + _g1h->g1_policy()->young_cset_length(); 1.85 + size_t real_length = 1 + _g1h->g1_policy()->young_cset_region_length(); 1.86 size_t array_length = PADDING_ELEM_NUM + 1.87 real_length + 1.88 PADDING_ELEM_NUM; 1.89 @@ -5595,8 +5593,8 @@ 1.90 1.91 if (cur->is_young()) { 1.92 int index = cur->young_index_in_cset(); 1.93 - guarantee( index != -1, "invariant" ); 1.94 - guarantee( (size_t)index < policy->young_cset_length(), "invariant" ); 1.95 + assert(index != -1, "invariant"); 1.96 + assert((size_t) index < policy->young_cset_region_length(), "invariant"); 1.97 size_t words_survived = _surviving_young_words[index]; 1.98 cur->record_surv_words_in_group(words_survived); 1.99 1.100 @@ -5607,7 +5605,7 @@ 1.101 cur->set_next_young_region(NULL); 1.102 } else { 1.103 int index = cur->young_index_in_cset(); 1.104 - guarantee( index == -1, "invariant" ); 1.105 + assert(index == -1, "invariant"); 1.106 } 1.107 1.108 assert( (cur->is_young() && cur->young_index_in_cset() > -1) || 1.109 @@ -5620,8 +5618,9 @@ 1.110 free_region(cur, &pre_used, &local_free_list, false /* par */); 1.111 } else { 1.112 cur->uninstall_surv_rate_group(); 1.113 - if (cur->is_young()) 1.114 + if (cur->is_young()) { 1.115 cur->set_young_index_in_cset(-1); 1.116 + } 1.117 cur->set_not_young(); 1.118 cur->set_evacuation_failed(false); 1.119 // The region is now considered to be old. 1.120 @@ -5722,7 +5721,6 @@ 1.121 assert(heap_lock_held_for_gc(), 1.122 "the heap lock should already be held by or for this thread"); 1.123 _young_list->push_region(hr); 1.124 - g1_policy()->set_region_short_lived(hr); 1.125 } 1.126 1.127 class NoYoungRegionsClosure: public HeapRegionClosure { 1.128 @@ -5880,7 +5878,6 @@ 1.129 HeapRegion* new_alloc_region = new_region(word_size, 1.130 false /* do_expand */); 1.131 if (new_alloc_region != NULL) { 1.132 - g1_policy()->update_region_num(true /* next_is_young */); 1.133 set_region_short_lived_locked(new_alloc_region); 1.134 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Eden, young_list_full); 1.135 return new_alloc_region;
2.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Thu Nov 17 13:14:49 2011 -0500 2.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Fri Nov 18 12:52:27 2011 -0500 2.3 @@ -1610,16 +1610,12 @@ 2.4 public: 2.5 void stop_conc_gc_threads(); 2.6 2.7 - // <NEW PREDICTION> 2.8 - 2.9 double predict_region_elapsed_time_ms(HeapRegion* hr, bool young); 2.10 void check_if_region_is_too_expensive(double predicted_time_ms); 2.11 size_t pending_card_num(); 2.12 size_t max_pending_card_num(); 2.13 size_t cards_scanned(); 2.14 2.15 - // </NEW PREDICTION> 2.16 - 2.17 protected: 2.18 size_t _max_heap_capacity; 2.19 };
3.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Thu Nov 17 13:14:49 2011 -0500 3.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Fri Nov 18 12:52:27 2011 -0500 3.3 @@ -36,10 +36,6 @@ 3.4 #include "runtime/mutexLocker.hpp" 3.5 #include "utilities/debug.hpp" 3.6 3.7 -#define PREDICTIONS_VERBOSE 0 3.8 - 3.9 -// <NEW PREDICTION> 3.10 - 3.11 // Different defaults for different number of GC threads 3.12 // They were chosen by running GCOld and SPECjbb on debris with different 3.13 // numbers of GC threads and choosing them based on the results 3.14 @@ -80,8 +76,6 @@ 3.15 1.0, 0.7, 0.7, 0.5, 0.5, 0.42, 0.42, 0.30 3.16 }; 3.17 3.18 -// </NEW PREDICTION> 3.19 - 3.20 // Help class for avoiding interleaved logging 3.21 class LineBuffer: public StackObj { 3.22 3.23 @@ -137,10 +131,6 @@ 3.24 _parallel_gc_threads(G1CollectedHeap::use_parallel_gc_threads() 3.25 ? ParallelGCThreads : 1), 3.26 3.27 - _n_pauses(0), 3.28 - _recent_rs_scan_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.29 - _recent_pause_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.30 - _recent_rs_sizes(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.31 _recent_gc_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.32 _all_pause_times_ms(new NumberSeq()), 3.33 _stop_world_start(0.0), 3.34 @@ -148,8 +138,6 @@ 3.35 _all_yield_times_ms(new NumberSeq()), 3.36 _using_new_ratio_calculations(false), 3.37 3.38 - _all_mod_union_times_ms(new NumberSeq()), 3.39 - 3.40 _summary(new Summary()), 3.41 3.42 _cur_clear_ct_time_ms(0.0), 3.43 @@ -165,11 +153,6 @@ 3.44 _num_cc_clears(0L), 3.45 #endif 3.46 3.47 - _region_num_young(0), 3.48 - _region_num_tenured(0), 3.49 - _prev_region_num_young(0), 3.50 - _prev_region_num_tenured(0), 3.51 - 3.52 _aux_num(10), 3.53 _all_aux_times_ms(new NumberSeq[_aux_num]), 3.54 _cur_aux_start_times_ms(new double[_aux_num]), 3.55 @@ -179,8 +162,6 @@ 3.56 _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.57 _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.58 3.59 - // <NEW PREDICTION> 3.60 - 3.61 _alloc_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)), 3.62 _prev_collection_pause_end_ms(0.0), 3.63 _pending_card_diff_seq(new TruncatedSeq(TruncatedSeqLength)), 3.64 @@ -199,13 +180,10 @@ 3.65 new TruncatedSeq(TruncatedSeqLength)), 3.66 3.67 _pending_cards_seq(new TruncatedSeq(TruncatedSeqLength)), 3.68 - _scanned_cards_seq(new TruncatedSeq(TruncatedSeqLength)), 3.69 _rs_lengths_seq(new TruncatedSeq(TruncatedSeqLength)), 3.70 3.71 _pause_time_target_ms((double) MaxGCPauseMillis), 3.72 3.73 - // </NEW PREDICTION> 3.74 - 3.75 _full_young_gcs(true), 3.76 _full_young_pause_num(0), 3.77 _partial_young_pause_num(0), 3.78 @@ -221,16 +199,10 @@ 3.79 3.80 _recent_prev_end_times_for_all_gcs_sec(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.81 3.82 - _recent_CS_bytes_used_before(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.83 - _recent_CS_bytes_surviving(new TruncatedSeq(NumPrevPausesForHeuristics)), 3.84 - 3.85 _recent_avg_pause_time_ratio(0.0), 3.86 3.87 _all_full_gc_times_ms(new NumberSeq()), 3.88 3.89 - // G1PausesBtwnConcMark defaults to -1 3.90 - // so the hack is to do the cast QQQ FIXME 3.91 - _pauses_btwn_concurrent_mark((size_t)G1PausesBtwnConcMark), 3.92 _initiate_conc_mark_if_possible(false), 3.93 _during_initial_mark_pause(false), 3.94 _should_revert_to_full_young_gcs(false), 3.95 @@ -242,22 +214,21 @@ 3.96 3.97 _prev_collection_pause_used_at_end_bytes(0), 3.98 3.99 + _eden_cset_region_length(0), 3.100 + _survivor_cset_region_length(0), 3.101 + _old_cset_region_length(0), 3.102 + 3.103 _collection_set(NULL), 3.104 - _collection_set_size(0), 3.105 _collection_set_bytes_used_before(0), 3.106 3.107 // Incremental CSet attributes 3.108 _inc_cset_build_state(Inactive), 3.109 _inc_cset_head(NULL), 3.110 _inc_cset_tail(NULL), 3.111 - _inc_cset_size(0), 3.112 - _inc_cset_young_index(0), 3.113 _inc_cset_bytes_used_before(0), 3.114 _inc_cset_max_finger(NULL), 3.115 - _inc_cset_recorded_young_bytes(0), 3.116 _inc_cset_recorded_rs_lengths(0), 3.117 _inc_cset_predicted_elapsed_time_ms(0.0), 3.118 - _inc_cset_predicted_bytes_to_copy(0), 3.119 3.120 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away 3.121 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list 3.122 @@ -325,8 +296,6 @@ 3.123 // start conservatively 3.124 _expensive_region_limit_ms = 0.5 * (double) MaxGCPauseMillis; 3.125 3.126 - // <NEW PREDICTION> 3.127 - 3.128 int index; 3.129 if (ParallelGCThreads == 0) 3.130 index = 0; 3.131 @@ -348,8 +317,6 @@ 3.132 _non_young_other_cost_per_region_ms_seq->add( 3.133 non_young_other_cost_per_region_ms_defaults[index]); 3.134 3.135 - // </NEW PREDICTION> 3.136 - 3.137 // Below, we might need to calculate the pause time target based on 3.138 // the pause interval. When we do so we are going to give G1 maximum 3.139 // flexibility and allow it to do pauses when it needs to. So, we'll 3.140 @@ -908,9 +875,6 @@ 3.141 3.142 record_survivor_regions(0, NULL, NULL); 3.143 3.144 - _prev_region_num_young = _region_num_young; 3.145 - _prev_region_num_tenured = _region_num_tenured; 3.146 - 3.147 _free_regions_at_end_of_collection = _g1->free_regions(); 3.148 // Reset survivors SurvRateGroup. 3.149 _survivor_surv_rate_group->reset(); 3.150 @@ -1168,8 +1132,10 @@ 3.151 double end_time_sec = os::elapsedTime(); 3.152 double elapsed_ms = _last_pause_time_ms; 3.153 bool parallel = G1CollectedHeap::use_parallel_gc_threads(); 3.154 + assert(_cur_collection_pause_used_regions_at_start >= cset_region_length(), 3.155 + "otherwise, the subtraction below does not make sense"); 3.156 size_t rs_size = 3.157 - _cur_collection_pause_used_regions_at_start - collection_set_size(); 3.158 + _cur_collection_pause_used_regions_at_start - cset_region_length(); 3.159 size_t cur_used_bytes = _g1->used(); 3.160 assert(cur_used_bytes == _g1->recalculate_used(), "It should!"); 3.161 bool last_pause_included_initial_mark = false; 3.162 @@ -1226,10 +1192,6 @@ 3.163 _mmu_tracker->add_pause(end_time_sec - elapsed_ms/1000.0, 3.164 end_time_sec, false); 3.165 3.166 - guarantee(_cur_collection_pause_used_regions_at_start >= 3.167 - collection_set_size(), 3.168 - "Negative RS size?"); 3.169 - 3.170 // This assert is exempted when we're doing parallel collection pauses, 3.171 // because the fragmentation caused by the parallel GC allocation buffers 3.172 // can lead to more memory being used during collection than was used 3.173 @@ -1253,8 +1215,6 @@ 3.174 (double)surviving_bytes/ 3.175 (double)_collection_set_bytes_used_before; 3.176 3.177 - _n_pauses++; 3.178 - 3.179 // These values are used to update the summary information that is 3.180 // displayed when TraceGen0Time is enabled, and are output as part 3.181 // of the PrintGCDetails output, in the non-parallel case. 3.182 @@ -1295,10 +1255,6 @@ 3.183 _all_pause_times_ms->add(elapsed_ms); 3.184 3.185 if (update_stats) { 3.186 - _recent_rs_scan_times_ms->add(scan_rs_time); 3.187 - _recent_pause_times_ms->add(elapsed_ms); 3.188 - _recent_rs_sizes->add(rs_size); 3.189 - 3.190 _summary->record_total_time_ms(elapsed_ms); 3.191 _summary->record_other_time_ms(other_time_ms); 3.192 3.193 @@ -1342,9 +1298,6 @@ 3.194 || surviving_bytes <= _collection_set_bytes_used_before, 3.195 "Or else negative collection!"); 3.196 3.197 - _recent_CS_bytes_used_before->add(_collection_set_bytes_used_before); 3.198 - _recent_CS_bytes_surviving->add(surviving_bytes); 3.199 - 3.200 // this is where we update the allocation rate of the application 3.201 double app_time_ms = 3.202 (_cur_collection_start_sec * 1000.0 - _prev_collection_pause_end_ms); 3.203 @@ -1354,13 +1307,17 @@ 3.204 // We'll just set it to something (arbitrarily) small. 3.205 app_time_ms = 1.0; 3.206 } 3.207 - size_t regions_allocated = 3.208 - (_region_num_young - _prev_region_num_young) + 3.209 - (_region_num_tenured - _prev_region_num_tenured); 3.210 + // We maintain the invariant that all objects allocated by mutator 3.211 + // threads will be allocated out of eden regions. So, we can use 3.212 + // the eden region number allocated since the previous GC to 3.213 + // calculate the application's allocate rate. The only exception 3.214 + // to that is humongous objects that are allocated separately. But 3.215 + // given that humongous object allocations do not really affect 3.216 + // either the pause's duration nor when the next pause will take 3.217 + // place we can safely ignore them here. 3.218 + size_t regions_allocated = eden_cset_region_length(); 3.219 double alloc_rate_ms = (double) regions_allocated / app_time_ms; 3.220 _alloc_rate_ms_seq->add(alloc_rate_ms); 3.221 - _prev_region_num_young = _region_num_young; 3.222 - _prev_region_num_tenured = _region_num_tenured; 3.223 3.224 double interval_ms = 3.225 (end_time_sec - _recent_prev_end_times_for_all_gcs_sec->oldest()) * 1000.0; 3.226 @@ -1398,33 +1355,6 @@ 3.227 } 3.228 } 3.229 3.230 - 3.231 - if (G1PolicyVerbose > 1) { 3.232 - gclog_or_tty->print_cr(" Recording collection pause(%d)", _n_pauses); 3.233 - } 3.234 - 3.235 - if (G1PolicyVerbose > 1) { 3.236 - gclog_or_tty->print_cr(" ET: %10.6f ms (avg: %10.6f ms)\n" 3.237 - " ET-RS: %10.6f ms (avg: %10.6f ms)\n" 3.238 - " |RS|: " SIZE_FORMAT, 3.239 - elapsed_ms, recent_avg_time_for_pauses_ms(), 3.240 - scan_rs_time, recent_avg_time_for_rs_scan_ms(), 3.241 - rs_size); 3.242 - 3.243 - gclog_or_tty->print_cr(" Used at start: " SIZE_FORMAT"K" 3.244 - " At end " SIZE_FORMAT "K\n" 3.245 - " garbage : " SIZE_FORMAT "K" 3.246 - " of " SIZE_FORMAT "K\n" 3.247 - " survival : %6.2f%% (%6.2f%% avg)", 3.248 - _cur_collection_pause_used_at_start_bytes/K, 3.249 - _g1->used()/K, freed_bytes/K, 3.250 - _collection_set_bytes_used_before/K, 3.251 - survival_fraction*100.0, 3.252 - recent_avg_survival_fraction()*100.0); 3.253 - gclog_or_tty->print_cr(" Recent %% gc pause time: %6.2f", 3.254 - recent_avg_pause_time_ratio() * 100.0); 3.255 - } 3.256 - 3.257 // PrintGCDetails output 3.258 if (PrintGCDetails) { 3.259 bool print_marking_info = 3.260 @@ -1576,8 +1506,6 @@ 3.261 _short_lived_surv_rate_group->start_adding_regions(); 3.262 // do that for any other surv rate groupsx 3.263 3.264 - // <NEW PREDICTION> 3.265 - 3.266 if (update_stats) { 3.267 double pause_time_ms = elapsed_ms; 3.268 3.269 @@ -1631,21 +1559,21 @@ 3.270 _mark_closure_time_ms + termination_time); 3.271 3.272 double young_other_time_ms = 0.0; 3.273 - if (_recorded_young_regions > 0) { 3.274 + if (young_cset_region_length() > 0) { 3.275 young_other_time_ms = 3.276 _recorded_young_cset_choice_time_ms + 3.277 _recorded_young_free_cset_time_ms; 3.278 _young_other_cost_per_region_ms_seq->add(young_other_time_ms / 3.279 - (double) _recorded_young_regions); 3.280 + (double) young_cset_region_length()); 3.281 } 3.282 double non_young_other_time_ms = 0.0; 3.283 - if (_recorded_non_young_regions > 0) { 3.284 + if (old_cset_region_length() > 0) { 3.285 non_young_other_time_ms = 3.286 _recorded_non_young_cset_choice_time_ms + 3.287 _recorded_non_young_free_cset_time_ms; 3.288 3.289 _non_young_other_cost_per_region_ms_seq->add(non_young_other_time_ms / 3.290 - (double) _recorded_non_young_regions); 3.291 + (double) old_cset_region_length()); 3.292 } 3.293 3.294 double constant_other_time_ms = all_other_time_ms - 3.295 @@ -1659,7 +1587,6 @@ 3.296 } 3.297 3.298 _pending_cards_seq->add((double) _pending_cards); 3.299 - _scanned_cards_seq->add((double) cards_scanned); 3.300 _rs_lengths_seq->add((double) _max_rs_lengths); 3.301 3.302 double expensive_region_limit_ms = 3.303 @@ -1670,49 +1597,6 @@ 3.304 expensive_region_limit_ms = (double) MaxGCPauseMillis; 3.305 } 3.306 _expensive_region_limit_ms = expensive_region_limit_ms; 3.307 - 3.308 - if (PREDICTIONS_VERBOSE) { 3.309 - gclog_or_tty->print_cr(""); 3.310 - gclog_or_tty->print_cr("PREDICTIONS %1.4lf %d " 3.311 - "REGIONS %d %d %d " 3.312 - "PENDING_CARDS %d %d " 3.313 - "CARDS_SCANNED %d %d " 3.314 - "RS_LENGTHS %d %d " 3.315 - "RS_UPDATE %1.6lf %1.6lf RS_SCAN %1.6lf %1.6lf " 3.316 - "SURVIVAL_RATIO %1.6lf %1.6lf " 3.317 - "OBJECT_COPY %1.6lf %1.6lf OTHER_CONSTANT %1.6lf %1.6lf " 3.318 - "OTHER_YOUNG %1.6lf %1.6lf " 3.319 - "OTHER_NON_YOUNG %1.6lf %1.6lf " 3.320 - "VTIME_DIFF %1.6lf TERMINATION %1.6lf " 3.321 - "ELAPSED %1.6lf %1.6lf ", 3.322 - _cur_collection_start_sec, 3.323 - (!_last_young_gc_full) ? 2 : 3.324 - (last_pause_included_initial_mark) ? 1 : 0, 3.325 - _recorded_region_num, 3.326 - _recorded_young_regions, 3.327 - _recorded_non_young_regions, 3.328 - _predicted_pending_cards, _pending_cards, 3.329 - _predicted_cards_scanned, cards_scanned, 3.330 - _predicted_rs_lengths, _max_rs_lengths, 3.331 - _predicted_rs_update_time_ms, update_rs_time, 3.332 - _predicted_rs_scan_time_ms, scan_rs_time, 3.333 - _predicted_survival_ratio, survival_ratio, 3.334 - _predicted_object_copy_time_ms, obj_copy_time, 3.335 - _predicted_constant_other_time_ms, constant_other_time_ms, 3.336 - _predicted_young_other_time_ms, young_other_time_ms, 3.337 - _predicted_non_young_other_time_ms, 3.338 - non_young_other_time_ms, 3.339 - _vtime_diff_ms, termination_time, 3.340 - _predicted_pause_time_ms, elapsed_ms); 3.341 - } 3.342 - 3.343 - if (G1PolicyVerbose > 0) { 3.344 - gclog_or_tty->print_cr("Pause Time, predicted: %1.4lfms (predicted %s), actual: %1.4lfms", 3.345 - _predicted_pause_time_ms, 3.346 - (_within_target) ? "within" : "outside", 3.347 - elapsed_ms); 3.348 - } 3.349 - 3.350 } 3.351 3.352 _in_marking_window = new_in_marking_window; 3.353 @@ -1723,7 +1607,6 @@ 3.354 // Note that _mmu_tracker->max_gc_time() returns the time in seconds. 3.355 double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0; 3.356 adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms); 3.357 - // </NEW PREDICTION> 3.358 3.359 assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end."); 3.360 } 3.361 @@ -1768,8 +1651,6 @@ 3.362 } 3.363 } 3.364 3.365 -// <NEW PREDICTION> 3.366 - 3.367 void G1CollectorPolicy::adjust_concurrent_refinement(double update_rs_time, 3.368 double update_rs_processed_buffers, 3.369 double goal_ms) { 3.370 @@ -1905,98 +1786,17 @@ 3.371 } 3.372 3.373 void 3.374 -G1CollectorPolicy::start_recording_regions() { 3.375 - _recorded_rs_lengths = 0; 3.376 - _recorded_young_regions = 0; 3.377 - _recorded_non_young_regions = 0; 3.378 - 3.379 -#if PREDICTIONS_VERBOSE 3.380 - _recorded_marked_bytes = 0; 3.381 - _recorded_young_bytes = 0; 3.382 - _predicted_bytes_to_copy = 0; 3.383 - _predicted_rs_lengths = 0; 3.384 - _predicted_cards_scanned = 0; 3.385 -#endif // PREDICTIONS_VERBOSE 3.386 -} 3.387 - 3.388 -void 3.389 -G1CollectorPolicy::record_cset_region_info(HeapRegion* hr, bool young) { 3.390 -#if PREDICTIONS_VERBOSE 3.391 - if (!young) { 3.392 - _recorded_marked_bytes += hr->max_live_bytes(); 3.393 - } 3.394 - _predicted_bytes_to_copy += predict_bytes_to_copy(hr); 3.395 -#endif // PREDICTIONS_VERBOSE 3.396 - 3.397 - size_t rs_length = hr->rem_set()->occupied(); 3.398 - _recorded_rs_lengths += rs_length; 3.399 -} 3.400 - 3.401 -void 3.402 -G1CollectorPolicy::record_non_young_cset_region(HeapRegion* hr) { 3.403 - assert(!hr->is_young(), "should not call this"); 3.404 - ++_recorded_non_young_regions; 3.405 - record_cset_region_info(hr, false); 3.406 -} 3.407 - 3.408 -void 3.409 -G1CollectorPolicy::set_recorded_young_regions(size_t n_regions) { 3.410 - _recorded_young_regions = n_regions; 3.411 -} 3.412 - 3.413 -void G1CollectorPolicy::set_recorded_young_bytes(size_t bytes) { 3.414 -#if PREDICTIONS_VERBOSE 3.415 - _recorded_young_bytes = bytes; 3.416 -#endif // PREDICTIONS_VERBOSE 3.417 +G1CollectorPolicy::init_cset_region_lengths(size_t eden_cset_region_length, 3.418 + size_t survivor_cset_region_length) { 3.419 + _eden_cset_region_length = eden_cset_region_length; 3.420 + _survivor_cset_region_length = survivor_cset_region_length; 3.421 + _old_cset_region_length = 0; 3.422 } 3.423 3.424 void G1CollectorPolicy::set_recorded_rs_lengths(size_t rs_lengths) { 3.425 _recorded_rs_lengths = rs_lengths; 3.426 } 3.427 3.428 -void G1CollectorPolicy::set_predicted_bytes_to_copy(size_t bytes) { 3.429 - _predicted_bytes_to_copy = bytes; 3.430 -} 3.431 - 3.432 -void 3.433 -G1CollectorPolicy::end_recording_regions() { 3.434 - // The _predicted_pause_time_ms field is referenced in code 3.435 - // not under PREDICTIONS_VERBOSE. Let's initialize it. 3.436 - _predicted_pause_time_ms = -1.0; 3.437 - 3.438 -#if PREDICTIONS_VERBOSE 3.439 - _predicted_pending_cards = predict_pending_cards(); 3.440 - _predicted_rs_lengths = _recorded_rs_lengths + predict_rs_length_diff(); 3.441 - if (full_young_gcs()) 3.442 - _predicted_cards_scanned += predict_young_card_num(_predicted_rs_lengths); 3.443 - else 3.444 - _predicted_cards_scanned += 3.445 - predict_non_young_card_num(_predicted_rs_lengths); 3.446 - _recorded_region_num = _recorded_young_regions + _recorded_non_young_regions; 3.447 - 3.448 - _predicted_rs_update_time_ms = 3.449 - predict_rs_update_time_ms(_g1->pending_card_num()); 3.450 - _predicted_rs_scan_time_ms = 3.451 - predict_rs_scan_time_ms(_predicted_cards_scanned); 3.452 - _predicted_object_copy_time_ms = 3.453 - predict_object_copy_time_ms(_predicted_bytes_to_copy); 3.454 - _predicted_constant_other_time_ms = 3.455 - predict_constant_other_time_ms(); 3.456 - _predicted_young_other_time_ms = 3.457 - predict_young_other_time_ms(_recorded_young_regions); 3.458 - _predicted_non_young_other_time_ms = 3.459 - predict_non_young_other_time_ms(_recorded_non_young_regions); 3.460 - 3.461 - _predicted_pause_time_ms = 3.462 - _predicted_rs_update_time_ms + 3.463 - _predicted_rs_scan_time_ms + 3.464 - _predicted_object_copy_time_ms + 3.465 - _predicted_constant_other_time_ms + 3.466 - _predicted_young_other_time_ms + 3.467 - _predicted_non_young_other_time_ms; 3.468 -#endif // PREDICTIONS_VERBOSE 3.469 -} 3.470 - 3.471 void G1CollectorPolicy::check_if_region_is_too_expensive(double 3.472 predicted_time_ms) { 3.473 // I don't think we need to do this when in young GC mode since 3.474 @@ -2013,9 +1813,6 @@ 3.475 } 3.476 } 3.477 3.478 -// </NEW PREDICTION> 3.479 - 3.480 - 3.481 void G1CollectorPolicy::update_recent_gc_times(double end_time_sec, 3.482 double elapsed_ms) { 3.483 _recent_gc_times_ms->add(elapsed_ms); 3.484 @@ -2023,99 +1820,6 @@ 3.485 _prev_collection_pause_end_ms = end_time_sec * 1000.0; 3.486 } 3.487 3.488 -double G1CollectorPolicy::recent_avg_time_for_pauses_ms() { 3.489 - if (_recent_pause_times_ms->num() == 0) { 3.490 - return (double) MaxGCPauseMillis; 3.491 - } 3.492 - return _recent_pause_times_ms->avg(); 3.493 -} 3.494 - 3.495 -double G1CollectorPolicy::recent_avg_time_for_rs_scan_ms() { 3.496 - if (_recent_rs_scan_times_ms->num() == 0) { 3.497 - return (double)MaxGCPauseMillis/3.0; 3.498 - } 3.499 - return _recent_rs_scan_times_ms->avg(); 3.500 -} 3.501 - 3.502 -int G1CollectorPolicy::number_of_recent_gcs() { 3.503 - assert(_recent_rs_scan_times_ms->num() == 3.504 - _recent_pause_times_ms->num(), "Sequence out of sync"); 3.505 - assert(_recent_pause_times_ms->num() == 3.506 - _recent_CS_bytes_used_before->num(), "Sequence out of sync"); 3.507 - assert(_recent_CS_bytes_used_before->num() == 3.508 - _recent_CS_bytes_surviving->num(), "Sequence out of sync"); 3.509 - 3.510 - return _recent_pause_times_ms->num(); 3.511 -} 3.512 - 3.513 -double G1CollectorPolicy::recent_avg_survival_fraction() { 3.514 - return recent_avg_survival_fraction_work(_recent_CS_bytes_surviving, 3.515 - _recent_CS_bytes_used_before); 3.516 -} 3.517 - 3.518 -double G1CollectorPolicy::last_survival_fraction() { 3.519 - return last_survival_fraction_work(_recent_CS_bytes_surviving, 3.520 - _recent_CS_bytes_used_before); 3.521 -} 3.522 - 3.523 -double 3.524 -G1CollectorPolicy::recent_avg_survival_fraction_work(TruncatedSeq* surviving, 3.525 - TruncatedSeq* before) { 3.526 - assert(surviving->num() == before->num(), "Sequence out of sync"); 3.527 - if (before->sum() > 0.0) { 3.528 - double recent_survival_rate = surviving->sum() / before->sum(); 3.529 - // We exempt parallel collection from this check because Alloc Buffer 3.530 - // fragmentation can produce negative collections. 3.531 - // Further, we're now always doing parallel collection. But I'm still 3.532 - // leaving this here as a placeholder for a more precise assertion later. 3.533 - // (DLD, 10/05.) 3.534 - assert((true || G1CollectedHeap::use_parallel_gc_threads()) || 3.535 - _g1->evacuation_failed() || 3.536 - recent_survival_rate <= 1.0, "Or bad frac"); 3.537 - return recent_survival_rate; 3.538 - } else { 3.539 - return 1.0; // Be conservative. 3.540 - } 3.541 -} 3.542 - 3.543 -double 3.544 -G1CollectorPolicy::last_survival_fraction_work(TruncatedSeq* surviving, 3.545 - TruncatedSeq* before) { 3.546 - assert(surviving->num() == before->num(), "Sequence out of sync"); 3.547 - if (surviving->num() > 0 && before->last() > 0.0) { 3.548 - double last_survival_rate = surviving->last() / before->last(); 3.549 - // We exempt parallel collection from this check because Alloc Buffer 3.550 - // fragmentation can produce negative collections. 3.551 - // Further, we're now always doing parallel collection. But I'm still 3.552 - // leaving this here as a placeholder for a more precise assertion later. 3.553 - // (DLD, 10/05.) 3.554 - assert((true || G1CollectedHeap::use_parallel_gc_threads()) || 3.555 - last_survival_rate <= 1.0, "Or bad frac"); 3.556 - return last_survival_rate; 3.557 - } else { 3.558 - return 1.0; 3.559 - } 3.560 -} 3.561 - 3.562 -static const int survival_min_obs = 5; 3.563 -static double survival_min_obs_limits[] = { 0.9, 0.7, 0.5, 0.3, 0.1 }; 3.564 -static const double min_survival_rate = 0.1; 3.565 - 3.566 -double 3.567 -G1CollectorPolicy::conservative_avg_survival_fraction_work(double avg, 3.568 - double latest) { 3.569 - double res = avg; 3.570 - if (number_of_recent_gcs() < survival_min_obs) { 3.571 - res = MAX2(res, survival_min_obs_limits[number_of_recent_gcs()]); 3.572 - } 3.573 - res = MAX2(res, latest); 3.574 - res = MAX2(res, min_survival_rate); 3.575 - // In the parallel case, LAB fragmentation can produce "negative 3.576 - // collections"; so can evac failure. Cap at 1.0 3.577 - res = MIN2(res, 1.0); 3.578 - return res; 3.579 -} 3.580 - 3.581 size_t G1CollectorPolicy::expansion_amount() { 3.582 double recent_gc_overhead = recent_avg_pause_time_ratio() * 100.0; 3.583 double threshold = _gc_overhead_perc; 3.584 @@ -2331,15 +2035,6 @@ 3.585 print_summary_sd(0, buffer, &_all_aux_times_ms[i]); 3.586 } 3.587 } 3.588 - 3.589 - size_t all_region_num = _region_num_young + _region_num_tenured; 3.590 - gclog_or_tty->print_cr(" New Regions %8d, Young %8d (%6.2lf%%), " 3.591 - "Tenured %8d (%6.2lf%%)", 3.592 - all_region_num, 3.593 - _region_num_young, 3.594 - (double) _region_num_young / (double) all_region_num * 100.0, 3.595 - _region_num_tenured, 3.596 - (double) _region_num_tenured / (double) all_region_num * 100.0); 3.597 } 3.598 if (TraceGen1Time) { 3.599 if (_all_full_gc_times_ms->num() > 0) { 3.600 @@ -2361,14 +2056,6 @@ 3.601 #endif // PRODUCT 3.602 } 3.603 3.604 -void G1CollectorPolicy::update_region_num(bool young) { 3.605 - if (young) { 3.606 - ++_region_num_young; 3.607 - } else { 3.608 - ++_region_num_tenured; 3.609 - } 3.610 -} 3.611 - 3.612 #ifndef PRODUCT 3.613 // for debugging, bit of a hack... 3.614 static char* 3.615 @@ -2682,8 +2369,7 @@ 3.616 } 3.617 3.618 // Add the heap region at the head of the non-incremental collection set 3.619 -void G1CollectorPolicy:: 3.620 -add_to_collection_set(HeapRegion* hr) { 3.621 +void G1CollectorPolicy::add_old_region_to_cset(HeapRegion* hr) { 3.622 assert(_inc_cset_build_state == Active, "Precondition"); 3.623 assert(!hr->is_young(), "non-incremental add of young region"); 3.624 3.625 @@ -2694,9 +2380,11 @@ 3.626 hr->set_in_collection_set(true); 3.627 hr->set_next_in_collection_set(_collection_set); 3.628 _collection_set = hr; 3.629 - _collection_set_size++; 3.630 _collection_set_bytes_used_before += hr->used(); 3.631 _g1->register_region_with_in_cset_fast_test(hr); 3.632 + size_t rs_length = hr->rem_set()->occupied(); 3.633 + _recorded_rs_lengths += rs_length; 3.634 + _old_cset_region_length += 1; 3.635 } 3.636 3.637 // Initialize the per-collection-set information 3.638 @@ -2705,16 +2393,11 @@ 3.639 3.640 _inc_cset_head = NULL; 3.641 _inc_cset_tail = NULL; 3.642 - _inc_cset_size = 0; 3.643 _inc_cset_bytes_used_before = 0; 3.644 3.645 - _inc_cset_young_index = 0; 3.646 - 3.647 _inc_cset_max_finger = 0; 3.648 - _inc_cset_recorded_young_bytes = 0; 3.649 _inc_cset_recorded_rs_lengths = 0; 3.650 _inc_cset_predicted_elapsed_time_ms = 0; 3.651 - _inc_cset_predicted_bytes_to_copy = 0; 3.652 _inc_cset_build_state = Active; 3.653 } 3.654 3.655 @@ -2745,20 +2428,6 @@ 3.656 // rset sampling code 3.657 hr->set_recorded_rs_length(rs_length); 3.658 hr->set_predicted_elapsed_time_ms(region_elapsed_time_ms); 3.659 - 3.660 -#if PREDICTIONS_VERBOSE 3.661 - size_t bytes_to_copy = predict_bytes_to_copy(hr); 3.662 - _inc_cset_predicted_bytes_to_copy += bytes_to_copy; 3.663 - 3.664 - // Record the number of bytes used in this region 3.665 - _inc_cset_recorded_young_bytes += used_bytes; 3.666 - 3.667 - // Cache the values we have added to the aggregated informtion 3.668 - // in the heap region in case we have to remove this region from 3.669 - // the incremental collection set, or it is updated by the 3.670 - // rset sampling code 3.671 - hr->set_predicted_bytes_to_copy(bytes_to_copy); 3.672 -#endif // PREDICTIONS_VERBOSE 3.673 } 3.674 3.675 void G1CollectorPolicy::remove_from_incremental_cset_info(HeapRegion* hr) { 3.676 @@ -2784,17 +2453,6 @@ 3.677 // Clear the values cached in the heap region 3.678 hr->set_recorded_rs_length(0); 3.679 hr->set_predicted_elapsed_time_ms(0); 3.680 - 3.681 -#if PREDICTIONS_VERBOSE 3.682 - size_t old_predicted_bytes_to_copy = hr->predicted_bytes_to_copy(); 3.683 - _inc_cset_predicted_bytes_to_copy -= old_predicted_bytes_to_copy; 3.684 - 3.685 - // Subtract the number of bytes used in this region 3.686 - _inc_cset_recorded_young_bytes -= used_bytes; 3.687 - 3.688 - // Clear the values cached in the heap region 3.689 - hr->set_predicted_bytes_to_copy(0); 3.690 -#endif // PREDICTIONS_VERBOSE 3.691 } 3.692 3.693 void G1CollectorPolicy::update_incremental_cset_info(HeapRegion* hr, size_t new_rs_length) { 3.694 @@ -2806,8 +2464,8 @@ 3.695 } 3.696 3.697 void G1CollectorPolicy::add_region_to_incremental_cset_common(HeapRegion* hr) { 3.698 - assert( hr->is_young(), "invariant"); 3.699 - assert( hr->young_index_in_cset() == -1, "invariant" ); 3.700 + assert(hr->is_young(), "invariant"); 3.701 + assert(hr->young_index_in_cset() > -1, "should have already been set"); 3.702 assert(_inc_cset_build_state == Active, "Precondition"); 3.703 3.704 // We need to clear and set the cached recorded/cached collection set 3.705 @@ -2827,11 +2485,7 @@ 3.706 hr->set_in_collection_set(true); 3.707 assert( hr->next_in_collection_set() == NULL, "invariant"); 3.708 3.709 - _inc_cset_size++; 3.710 _g1->register_region_with_in_cset_fast_test(hr); 3.711 - 3.712 - hr->set_young_index_in_cset((int) _inc_cset_young_index); 3.713 - ++_inc_cset_young_index; 3.714 } 3.715 3.716 // Add the region at the RHS of the incremental cset 3.717 @@ -2899,8 +2553,6 @@ 3.718 3.719 YoungList* young_list = _g1->young_list(); 3.720 3.721 - start_recording_regions(); 3.722 - 3.723 guarantee(target_pause_time_ms > 0.0, 3.724 err_msg("target_pause_time_ms = %1.6lf should be positive", 3.725 target_pause_time_ms)); 3.726 @@ -2923,7 +2575,6 @@ 3.727 if (time_remaining_ms < threshold) { 3.728 double prev_time_remaining_ms = time_remaining_ms; 3.729 time_remaining_ms = 0.50 * target_pause_time_ms; 3.730 - _within_target = false; 3.731 ergo_verbose3(ErgoCSetConstruction, 3.732 "adjust remaining time", 3.733 ergo_format_reason("remaining time lower than threshold") 3.734 @@ -2931,8 +2582,6 @@ 3.735 ergo_format_ms("threshold") 3.736 ergo_format_ms("adjusted remaining time"), 3.737 prev_time_remaining_ms, threshold, time_remaining_ms); 3.738 - } else { 3.739 - _within_target = true; 3.740 } 3.741 3.742 size_t expansion_bytes = _g1->expansion_regions() * HeapRegion::GrainBytes; 3.743 @@ -2941,8 +2590,6 @@ 3.744 double young_start_time_sec = os::elapsedTime(); 3.745 3.746 _collection_set_bytes_used_before = 0; 3.747 - _collection_set_size = 0; 3.748 - _young_cset_length = 0; 3.749 _last_young_gc_full = full_young_gcs() ? true : false; 3.750 3.751 if (_last_young_gc_full) { 3.752 @@ -2955,9 +2602,9 @@ 3.753 // pause are appended to the RHS of the young list, i.e. 3.754 // [Newly Young Regions ++ Survivors from last pause]. 3.755 3.756 - size_t survivor_region_num = young_list->survivor_length(); 3.757 - size_t eden_region_num = young_list->length() - survivor_region_num; 3.758 - size_t old_region_num = 0; 3.759 + size_t survivor_region_length = young_list->survivor_length(); 3.760 + size_t eden_region_length = young_list->length() - survivor_region_length; 3.761 + init_cset_region_lengths(eden_region_length, survivor_region_length); 3.762 hr = young_list->first_survivor_region(); 3.763 while (hr != NULL) { 3.764 assert(hr->is_survivor(), "badly formed young list"); 3.765 @@ -2971,9 +2618,7 @@ 3.766 if (_g1->mark_in_progress()) 3.767 _g1->concurrent_mark()->register_collection_set_finger(_inc_cset_max_finger); 3.768 3.769 - _young_cset_length = _inc_cset_young_index; 3.770 _collection_set = _inc_cset_head; 3.771 - _collection_set_size = _inc_cset_size; 3.772 _collection_set_bytes_used_before = _inc_cset_bytes_used_before; 3.773 time_remaining_ms -= _inc_cset_predicted_elapsed_time_ms; 3.774 predicted_pause_time_ms += _inc_cset_predicted_elapsed_time_ms; 3.775 @@ -2983,19 +2628,12 @@ 3.776 ergo_format_region("eden") 3.777 ergo_format_region("survivors") 3.778 ergo_format_ms("predicted young region time"), 3.779 - eden_region_num, survivor_region_num, 3.780 + eden_region_length, survivor_region_length, 3.781 _inc_cset_predicted_elapsed_time_ms); 3.782 3.783 // The number of recorded young regions is the incremental 3.784 // collection set's current size 3.785 - set_recorded_young_regions(_inc_cset_size); 3.786 set_recorded_rs_lengths(_inc_cset_recorded_rs_lengths); 3.787 - set_recorded_young_bytes(_inc_cset_recorded_young_bytes); 3.788 -#if PREDICTIONS_VERBOSE 3.789 - set_predicted_bytes_to_copy(_inc_cset_predicted_bytes_to_copy); 3.790 -#endif // PREDICTIONS_VERBOSE 3.791 - 3.792 - assert(_inc_cset_size == young_list->length(), "Invariant"); 3.793 3.794 double young_end_time_sec = os::elapsedTime(); 3.795 _recorded_young_cset_choice_time_ms = 3.796 @@ -3009,9 +2647,16 @@ 3.797 NumberSeq seq; 3.798 double avg_prediction = 100000000000000000.0; // something very large 3.799 3.800 - size_t prev_collection_set_size = _collection_set_size; 3.801 double prev_predicted_pause_time_ms = predicted_pause_time_ms; 3.802 do { 3.803 + // Note that add_old_region_to_cset() increments the 3.804 + // _old_cset_region_length field and cset_region_length() returns the 3.805 + // sum of _eden_cset_region_length, _survivor_cset_region_length, and 3.806 + // _old_cset_region_length. So, as old regions are added to the 3.807 + // CSet, _old_cset_region_length will be incremented and 3.808 + // cset_region_length(), which is used below, will always reflect 3.809 + // the the total number of regions added up to this point to the CSet. 3.810 + 3.811 hr = _collectionSetChooser->getNextMarkedRegion(time_remaining_ms, 3.812 avg_prediction); 3.813 if (hr != NULL) { 3.814 @@ -3019,8 +2664,7 @@ 3.815 double predicted_time_ms = predict_region_elapsed_time_ms(hr, false); 3.816 time_remaining_ms -= predicted_time_ms; 3.817 predicted_pause_time_ms += predicted_time_ms; 3.818 - add_to_collection_set(hr); 3.819 - record_non_young_cset_region(hr); 3.820 + add_old_region_to_cset(hr); 3.821 seq.add(predicted_time_ms); 3.822 avg_prediction = seq.avg() + seq.sd(); 3.823 } 3.824 @@ -3041,13 +2685,13 @@ 3.825 should_continue = false; 3.826 } 3.827 } else { 3.828 - if (_collection_set_size >= _young_list_fixed_length) { 3.829 + if (cset_region_length() >= _young_list_fixed_length) { 3.830 ergo_verbose2(ErgoCSetConstruction, 3.831 "stop adding old regions to CSet", 3.832 ergo_format_reason("CSet length reached target") 3.833 ergo_format_region("CSet") 3.834 ergo_format_region("young target"), 3.835 - _collection_set_size, _young_list_fixed_length); 3.836 + cset_region_length(), _young_list_fixed_length); 3.837 should_continue = false; 3.838 } 3.839 } 3.840 @@ -3055,23 +2699,21 @@ 3.841 } while (should_continue); 3.842 3.843 if (!adaptive_young_list_length() && 3.844 - _collection_set_size < _young_list_fixed_length) { 3.845 + cset_region_length() < _young_list_fixed_length) { 3.846 ergo_verbose2(ErgoCSetConstruction, 3.847 "request partially-young GCs end", 3.848 ergo_format_reason("CSet length lower than target") 3.849 ergo_format_region("CSet") 3.850 ergo_format_region("young target"), 3.851 - _collection_set_size, _young_list_fixed_length); 3.852 + cset_region_length(), _young_list_fixed_length); 3.853 _should_revert_to_full_young_gcs = true; 3.854 } 3.855 3.856 - old_region_num = _collection_set_size - prev_collection_set_size; 3.857 - 3.858 ergo_verbose2(ErgoCSetConstruction | ErgoHigh, 3.859 "add old regions to CSet", 3.860 ergo_format_region("old") 3.861 ergo_format_ms("predicted old region time"), 3.862 - old_region_num, 3.863 + old_cset_region_length(), 3.864 predicted_pause_time_ms - prev_predicted_pause_time_ms); 3.865 } 3.866 3.867 @@ -3079,8 +2721,6 @@ 3.868 3.869 count_CS_bytes_used(); 3.870 3.871 - end_recording_regions(); 3.872 - 3.873 ergo_verbose5(ErgoCSetConstruction, 3.874 "finish choosing CSet", 3.875 ergo_format_region("eden") 3.876 @@ -3088,7 +2728,8 @@ 3.877 ergo_format_region("old") 3.878 ergo_format_ms("predicted pause time") 3.879 ergo_format_ms("target pause time"), 3.880 - eden_region_num, survivor_region_num, old_region_num, 3.881 + eden_region_length, survivor_region_length, 3.882 + old_cset_region_length(), 3.883 predicted_pause_time_ms, target_pause_time_ms); 3.884 3.885 double non_young_end_time_sec = os::elapsedTime();
4.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Thu Nov 17 13:14:49 2011 -0500 4.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Fri Nov 18 12:52:27 2011 -0500 4.3 @@ -85,9 +85,6 @@ 4.4 4.5 class G1CollectorPolicy: public CollectorPolicy { 4.6 private: 4.7 - // The number of pauses during the execution. 4.8 - long _n_pauses; 4.9 - 4.10 // either equal to the number of parallel threads, if ParallelGCThreads 4.11 // has been set, or 1 otherwise 4.12 int _parallel_gc_threads; 4.13 @@ -127,18 +124,9 @@ 4.14 jlong _num_cc_clears; // number of times the card count cache has been cleared 4.15 #endif 4.16 4.17 - // Statistics for recent GC pauses. See below for how indexed. 4.18 - TruncatedSeq* _recent_rs_scan_times_ms; 4.19 - 4.20 // These exclude marking times. 4.21 - TruncatedSeq* _recent_pause_times_ms; 4.22 TruncatedSeq* _recent_gc_times_ms; 4.23 4.24 - TruncatedSeq* _recent_CS_bytes_used_before; 4.25 - TruncatedSeq* _recent_CS_bytes_surviving; 4.26 - 4.27 - TruncatedSeq* _recent_rs_sizes; 4.28 - 4.29 TruncatedSeq* _concurrent_mark_remark_times_ms; 4.30 TruncatedSeq* _concurrent_mark_cleanup_times_ms; 4.31 4.32 @@ -150,13 +138,6 @@ 4.33 NumberSeq* _all_stop_world_times_ms; 4.34 NumberSeq* _all_yield_times_ms; 4.35 4.36 - size_t _region_num_young; 4.37 - size_t _region_num_tenured; 4.38 - size_t _prev_region_num_young; 4.39 - size_t _prev_region_num_tenured; 4.40 - 4.41 - NumberSeq* _all_mod_union_times_ms; 4.42 - 4.43 int _aux_num; 4.44 NumberSeq* _all_aux_times_ms; 4.45 double* _cur_aux_start_times_ms; 4.46 @@ -194,7 +175,6 @@ 4.47 // locker is active. This should be >= _young_list_target_length; 4.48 size_t _young_list_max_length; 4.49 4.50 - size_t _young_cset_length; 4.51 bool _last_young_gc_full; 4.52 4.53 unsigned _full_young_pause_num; 4.54 @@ -217,8 +197,6 @@ 4.55 return _during_marking; 4.56 } 4.57 4.58 - // <NEW PREDICTION> 4.59 - 4.60 private: 4.61 enum PredictionConstants { 4.62 TruncatedSeqLength = 10 4.63 @@ -240,47 +218,32 @@ 4.64 TruncatedSeq* _non_young_other_cost_per_region_ms_seq; 4.65 4.66 TruncatedSeq* _pending_cards_seq; 4.67 - TruncatedSeq* _scanned_cards_seq; 4.68 TruncatedSeq* _rs_lengths_seq; 4.69 4.70 TruncatedSeq* _cost_per_byte_ms_during_cm_seq; 4.71 4.72 TruncatedSeq* _young_gc_eff_seq; 4.73 4.74 - TruncatedSeq* _max_conc_overhead_seq; 4.75 - 4.76 bool _using_new_ratio_calculations; 4.77 size_t _min_desired_young_length; // as set on the command line or default calculations 4.78 size_t _max_desired_young_length; // as set on the command line or default calculations 4.79 4.80 - size_t _recorded_young_regions; 4.81 - size_t _recorded_non_young_regions; 4.82 - size_t _recorded_region_num; 4.83 + size_t _eden_cset_region_length; 4.84 + size_t _survivor_cset_region_length; 4.85 + size_t _old_cset_region_length; 4.86 + 4.87 + void init_cset_region_lengths(size_t eden_cset_region_length, 4.88 + size_t survivor_cset_region_length); 4.89 + 4.90 + size_t eden_cset_region_length() { return _eden_cset_region_length; } 4.91 + size_t survivor_cset_region_length() { return _survivor_cset_region_length; } 4.92 + size_t old_cset_region_length() { return _old_cset_region_length; } 4.93 4.94 size_t _free_regions_at_end_of_collection; 4.95 4.96 size_t _recorded_rs_lengths; 4.97 size_t _max_rs_lengths; 4.98 4.99 - size_t _recorded_marked_bytes; 4.100 - size_t _recorded_young_bytes; 4.101 - 4.102 - size_t _predicted_pending_cards; 4.103 - size_t _predicted_cards_scanned; 4.104 - size_t _predicted_rs_lengths; 4.105 - size_t _predicted_bytes_to_copy; 4.106 - 4.107 - double _predicted_survival_ratio; 4.108 - double _predicted_rs_update_time_ms; 4.109 - double _predicted_rs_scan_time_ms; 4.110 - double _predicted_object_copy_time_ms; 4.111 - double _predicted_constant_other_time_ms; 4.112 - double _predicted_young_other_time_ms; 4.113 - double _predicted_non_young_other_time_ms; 4.114 - double _predicted_pause_time_ms; 4.115 - 4.116 - double _vtime_diff_ms; 4.117 - 4.118 double _recorded_young_free_cset_time_ms; 4.119 double _recorded_non_young_free_cset_time_ms; 4.120 4.121 @@ -320,18 +283,21 @@ 4.122 double _pause_time_target_ms; 4.123 double _recorded_young_cset_choice_time_ms; 4.124 double _recorded_non_young_cset_choice_time_ms; 4.125 - bool _within_target; 4.126 size_t _pending_cards; 4.127 size_t _max_pending_cards; 4.128 4.129 public: 4.130 4.131 - void set_region_short_lived(HeapRegion* hr) { 4.132 + void set_region_eden(HeapRegion* hr, int young_index_in_cset) { 4.133 + hr->set_young(); 4.134 hr->install_surv_rate_group(_short_lived_surv_rate_group); 4.135 + hr->set_young_index_in_cset(young_index_in_cset); 4.136 } 4.137 4.138 - void set_region_survivors(HeapRegion* hr) { 4.139 + void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { 4.140 + assert(hr->is_young() && hr->is_survivor(), "pre-condition"); 4.141 hr->install_surv_rate_group(_survivor_surv_rate_group); 4.142 + hr->set_young_index_in_cset(young_index_in_cset); 4.143 } 4.144 4.145 #ifndef PRODUCT 4.146 @@ -343,10 +309,6 @@ 4.147 seq->davg() * confidence_factor(seq->num())); 4.148 } 4.149 4.150 - size_t young_cset_length() { 4.151 - return _young_cset_length; 4.152 - } 4.153 - 4.154 void record_max_rs_lengths(size_t rs_lengths) { 4.155 _max_rs_lengths = rs_lengths; 4.156 } 4.157 @@ -465,20 +427,12 @@ 4.158 size_t predict_bytes_to_copy(HeapRegion* hr); 4.159 double predict_region_elapsed_time_ms(HeapRegion* hr, bool young); 4.160 4.161 - void start_recording_regions(); 4.162 - void record_cset_region_info(HeapRegion* hr, bool young); 4.163 - void record_non_young_cset_region(HeapRegion* hr); 4.164 + void set_recorded_rs_lengths(size_t rs_lengths); 4.165 4.166 - void set_recorded_young_regions(size_t n_regions); 4.167 - void set_recorded_young_bytes(size_t bytes); 4.168 - void set_recorded_rs_lengths(size_t rs_lengths); 4.169 - void set_predicted_bytes_to_copy(size_t bytes); 4.170 - 4.171 - void end_recording_regions(); 4.172 - 4.173 - void record_vtime_diff_ms(double vtime_diff_ms) { 4.174 - _vtime_diff_ms = vtime_diff_ms; 4.175 - } 4.176 + size_t cset_region_length() { return young_cset_region_length() + 4.177 + old_cset_region_length(); } 4.178 + size_t young_cset_region_length() { return eden_cset_region_length() + 4.179 + survivor_cset_region_length(); } 4.180 4.181 void record_young_free_cset_time_ms(double time_ms) { 4.182 _recorded_young_free_cset_time_ms = time_ms; 4.183 @@ -494,8 +448,6 @@ 4.184 4.185 double predict_survivor_regions_evac_time(); 4.186 4.187 - // </NEW PREDICTION> 4.188 - 4.189 void cset_regions_freed() { 4.190 bool propagate = _last_young_gc_full && !_in_marking_window; 4.191 _short_lived_surv_rate_group->all_surviving_words_recorded(propagate); 4.192 @@ -576,7 +528,6 @@ 4.193 double max_sum (double* data1, double* data2); 4.194 4.195 int _last_satb_drain_processed_buffers; 4.196 - int _last_update_rs_processed_buffers; 4.197 double _last_pause_time_ms; 4.198 4.199 size_t _bytes_in_collection_set_before_gc; 4.200 @@ -596,10 +547,6 @@ 4.201 // set at the start of the pause. 4.202 HeapRegion* _collection_set; 4.203 4.204 - // The number of regions in the collection set. Set from the incrementally 4.205 - // built collection set at the start of an evacuation pause. 4.206 - size_t _collection_set_size; 4.207 - 4.208 // The number of bytes in the collection set before the pause. Set from 4.209 // the incrementally built collection set at the start of an evacuation 4.210 // pause. 4.211 @@ -622,16 +569,6 @@ 4.212 // The tail of the incrementally built collection set. 4.213 HeapRegion* _inc_cset_tail; 4.214 4.215 - // The number of regions in the incrementally built collection set. 4.216 - // Used to set _collection_set_size at the start of an evacuation 4.217 - // pause. 4.218 - size_t _inc_cset_size; 4.219 - 4.220 - // Used as the index in the surving young words structure 4.221 - // which tracks the amount of space, for each young region, 4.222 - // that survives the pause. 4.223 - size_t _inc_cset_young_index; 4.224 - 4.225 // The number of bytes in the incrementally built collection set. 4.226 // Used to set _collection_set_bytes_used_before at the start of 4.227 // an evacuation pause. 4.228 @@ -640,11 +577,6 @@ 4.229 // Used to record the highest end of heap region in collection set 4.230 HeapWord* _inc_cset_max_finger; 4.231 4.232 - // The number of recorded used bytes in the young regions 4.233 - // of the collection set. This is the sum of the used() bytes 4.234 - // of retired young regions in the collection set. 4.235 - size_t _inc_cset_recorded_young_bytes; 4.236 - 4.237 // The RSet lengths recorded for regions in the collection set 4.238 // (updated by the periodic sampling of the regions in the 4.239 // young list/collection set). 4.240 @@ -655,68 +587,9 @@ 4.241 // regions in the young list/collection set). 4.242 double _inc_cset_predicted_elapsed_time_ms; 4.243 4.244 - // The predicted bytes to copy for the regions in the collection 4.245 - // set (updated by the periodic sampling of the regions in the 4.246 - // young list/collection set). 4.247 - size_t _inc_cset_predicted_bytes_to_copy; 4.248 - 4.249 // Stash a pointer to the g1 heap. 4.250 G1CollectedHeap* _g1; 4.251 4.252 - // The average time in ms per collection pause, averaged over recent pauses. 4.253 - double recent_avg_time_for_pauses_ms(); 4.254 - 4.255 - // The average time in ms for RS scanning, per pause, averaged 4.256 - // over recent pauses. (Note the RS scanning time for a pause 4.257 - // is itself an average of the RS scanning time for each worker 4.258 - // thread.) 4.259 - double recent_avg_time_for_rs_scan_ms(); 4.260 - 4.261 - // The number of "recent" GCs recorded in the number sequences 4.262 - int number_of_recent_gcs(); 4.263 - 4.264 - // The average survival ratio, computed by the total number of bytes 4.265 - // suriviving / total number of bytes before collection over the last 4.266 - // several recent pauses. 4.267 - double recent_avg_survival_fraction(); 4.268 - // The survival fraction of the most recent pause; if there have been no 4.269 - // pauses, returns 1.0. 4.270 - double last_survival_fraction(); 4.271 - 4.272 - // Returns a "conservative" estimate of the recent survival rate, i.e., 4.273 - // one that may be higher than "recent_avg_survival_fraction". 4.274 - // This is conservative in several ways: 4.275 - // If there have been few pauses, it will assume a potential high 4.276 - // variance, and err on the side of caution. 4.277 - // It puts a lower bound (currently 0.1) on the value it will return. 4.278 - // To try to detect phase changes, if the most recent pause ("latest") has a 4.279 - // higher-than average ("avg") survival rate, it returns that rate. 4.280 - // "work" version is a utility function; young is restricted to young regions. 4.281 - double conservative_avg_survival_fraction_work(double avg, 4.282 - double latest); 4.283 - 4.284 - // The arguments are the two sequences that keep track of the number of bytes 4.285 - // surviving and the total number of bytes before collection, resp., 4.286 - // over the last evereal recent pauses 4.287 - // Returns the survival rate for the category in the most recent pause. 4.288 - // If there have been no pauses, returns 1.0. 4.289 - double last_survival_fraction_work(TruncatedSeq* surviving, 4.290 - TruncatedSeq* before); 4.291 - 4.292 - // The arguments are the two sequences that keep track of the number of bytes 4.293 - // surviving and the total number of bytes before collection, resp., 4.294 - // over the last several recent pauses 4.295 - // Returns the average survival ration over the last several recent pauses 4.296 - // If there have been no pauses, return 1.0 4.297 - double recent_avg_survival_fraction_work(TruncatedSeq* surviving, 4.298 - TruncatedSeq* before); 4.299 - 4.300 - double conservative_avg_survival_fraction() { 4.301 - double avg = recent_avg_survival_fraction(); 4.302 - double latest = last_survival_fraction(); 4.303 - return conservative_avg_survival_fraction_work(avg, latest); 4.304 - } 4.305 - 4.306 // The ratio of gc time to elapsed time, computed over recent pauses. 4.307 double _recent_avg_pause_time_ratio; 4.308 4.309 @@ -724,9 +597,6 @@ 4.310 return _recent_avg_pause_time_ratio; 4.311 } 4.312 4.313 - // Number of pauses between concurrent marking. 4.314 - size_t _pauses_btwn_concurrent_mark; 4.315 - 4.316 // At the end of a pause we check the heap occupancy and we decide 4.317 // whether we will start a marking cycle during the next pause. If 4.318 // we decide that we want to do that, we will set this parameter to 4.319 @@ -849,9 +719,6 @@ 4.320 4.321 GenRemSet::Name rem_set_name() { return GenRemSet::CardTable; } 4.322 4.323 - // The number of collection pauses so far. 4.324 - long n_pauses() const { return _n_pauses; } 4.325 - 4.326 // Update the heuristic info to record a collection pause of the given 4.327 // start time, where the given number of bytes were used at the start. 4.328 // This may involve changing the desired size of a collection set. 4.329 @@ -905,10 +772,6 @@ 4.330 _last_satb_drain_processed_buffers = processed_buffers; 4.331 } 4.332 4.333 - void record_mod_union_time(double ms) { 4.334 - _all_mod_union_times_ms->add(ms); 4.335 - } 4.336 - 4.337 void record_update_rs_time(int thread, double ms) { 4.338 _par_last_update_rs_times_ms[thread] = ms; 4.339 } 4.340 @@ -1009,11 +872,8 @@ 4.341 4.342 void clear_collection_set() { _collection_set = NULL; } 4.343 4.344 - // The number of elements in the current collection set. 4.345 - size_t collection_set_size() { return _collection_set_size; } 4.346 - 4.347 - // Add "hr" to the CS. 4.348 - void add_to_collection_set(HeapRegion* hr); 4.349 + // Add old region "hr" to the CSet. 4.350 + void add_old_region_to_cset(HeapRegion* hr); 4.351 4.352 // Incremental CSet Support 4.353 4.354 @@ -1023,9 +883,6 @@ 4.355 // The tail of the incrementally built collection set. 4.356 HeapRegion* inc_set_tail() { return _inc_cset_tail; } 4.357 4.358 - // The number of elements in the incrementally built collection set. 4.359 - size_t inc_cset_size() { return _inc_cset_size; } 4.360 - 4.361 // Initialize incremental collection set info. 4.362 void start_incremental_cset_building(); 4.363 4.364 @@ -1125,8 +982,6 @@ 4.365 return _young_list_max_length; 4.366 } 4.367 4.368 - void update_region_num(bool young); 4.369 - 4.370 bool full_young_gcs() { 4.371 return _full_young_gcs; 4.372 }
5.1 --- a/src/share/vm/gc_implementation/g1/g1RemSet.cpp Thu Nov 17 13:14:49 2011 -0500 5.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSet.cpp Fri Nov 18 12:52:27 2011 -0500 5.3 @@ -219,7 +219,7 @@ 5.4 HeapRegion* G1RemSet::calculateStartRegion(int worker_i) { 5.5 HeapRegion* result = _g1p->collection_set(); 5.6 if (ParallelGCThreads > 0) { 5.7 - size_t cs_size = _g1p->collection_set_size(); 5.8 + size_t cs_size = _g1p->cset_region_length(); 5.9 int n_workers = _g1->workers()->total_workers(); 5.10 size_t cs_spans = cs_size / n_workers; 5.11 size_t ind = cs_spans * worker_i;
6.1 --- a/src/share/vm/gc_implementation/g1/g1_globals.hpp Thu Nov 17 13:14:49 2011 -0500 6.2 +++ b/src/share/vm/gc_implementation/g1/g1_globals.hpp Fri Nov 18 12:52:27 2011 -0500 6.3 @@ -39,10 +39,6 @@ 6.4 develop(intx, G1MarkingOverheadPercent, 0, \ 6.5 "Overhead of concurrent marking") \ 6.6 \ 6.7 - \ 6.8 - develop(intx, G1PolicyVerbose, 0, \ 6.9 - "The verbosity level on G1 policy decisions") \ 6.10 - \ 6.11 develop(intx, G1MarkingVerboseLevel, 0, \ 6.12 "Level (0-4) of verboseness of the marking code") \ 6.13 \ 6.14 @@ -58,9 +54,6 @@ 6.15 develop(bool, G1TraceMarkStackOverflow, false, \ 6.16 "If true, extra debugging code for CM restart for ovflw.") \ 6.17 \ 6.18 - develop(intx, G1PausesBtwnConcMark, -1, \ 6.19 - "If positive, fixed number of pauses between conc markings") \ 6.20 - \ 6.21 diagnostic(bool, G1SummarizeConcMark, false, \ 6.22 "Summarize concurrent mark info") \ 6.23 \