comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp @ 4090:a88de71c4e3a

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
author tonyp
date Fri, 18 Nov 2011 12:52:27 -0500
parents c6a6e936dc68
children bca17e38de00
comparison
equal deleted inserted replaced
4077:b1754f3fbbd8 4090:a88de71c4e3a
83 virtual MainBodySummary* main_body_summary() { return this; } 83 virtual MainBodySummary* main_body_summary() { return this; }
84 }; 84 };
85 85
86 class G1CollectorPolicy: public CollectorPolicy { 86 class G1CollectorPolicy: public CollectorPolicy {
87 private: 87 private:
88 // The number of pauses during the execution.
89 long _n_pauses;
90
91 // either equal to the number of parallel threads, if ParallelGCThreads 88 // either equal to the number of parallel threads, if ParallelGCThreads
92 // has been set, or 1 otherwise 89 // has been set, or 1 otherwise
93 int _parallel_gc_threads; 90 int _parallel_gc_threads;
94 91
95 enum SomePrivateConstants { 92 enum SomePrivateConstants {
125 double _cur_clear_cc_time_ms; // clearing time during current pause 122 double _cur_clear_cc_time_ms; // clearing time during current pause
126 double _cum_clear_cc_time_ms; // cummulative clearing time 123 double _cum_clear_cc_time_ms; // cummulative clearing time
127 jlong _num_cc_clears; // number of times the card count cache has been cleared 124 jlong _num_cc_clears; // number of times the card count cache has been cleared
128 #endif 125 #endif
129 126
130 // Statistics for recent GC pauses. See below for how indexed.
131 TruncatedSeq* _recent_rs_scan_times_ms;
132
133 // These exclude marking times. 127 // These exclude marking times.
134 TruncatedSeq* _recent_pause_times_ms;
135 TruncatedSeq* _recent_gc_times_ms; 128 TruncatedSeq* _recent_gc_times_ms;
136
137 TruncatedSeq* _recent_CS_bytes_used_before;
138 TruncatedSeq* _recent_CS_bytes_surviving;
139
140 TruncatedSeq* _recent_rs_sizes;
141 129
142 TruncatedSeq* _concurrent_mark_remark_times_ms; 130 TruncatedSeq* _concurrent_mark_remark_times_ms;
143 TruncatedSeq* _concurrent_mark_cleanup_times_ms; 131 TruncatedSeq* _concurrent_mark_cleanup_times_ms;
144 132
145 Summary* _summary; 133 Summary* _summary;
147 NumberSeq* _all_pause_times_ms; 135 NumberSeq* _all_pause_times_ms;
148 NumberSeq* _all_full_gc_times_ms; 136 NumberSeq* _all_full_gc_times_ms;
149 double _stop_world_start; 137 double _stop_world_start;
150 NumberSeq* _all_stop_world_times_ms; 138 NumberSeq* _all_stop_world_times_ms;
151 NumberSeq* _all_yield_times_ms; 139 NumberSeq* _all_yield_times_ms;
152
153 size_t _region_num_young;
154 size_t _region_num_tenured;
155 size_t _prev_region_num_young;
156 size_t _prev_region_num_tenured;
157
158 NumberSeq* _all_mod_union_times_ms;
159 140
160 int _aux_num; 141 int _aux_num;
161 NumberSeq* _all_aux_times_ms; 142 NumberSeq* _all_aux_times_ms;
162 double* _cur_aux_start_times_ms; 143 double* _cur_aux_start_times_ms;
163 double* _cur_aux_times_ms; 144 double* _cur_aux_times_ms;
192 173
193 // The max number of regions we can extend the eden by while the GC 174 // The max number of regions we can extend the eden by while the GC
194 // locker is active. This should be >= _young_list_target_length; 175 // locker is active. This should be >= _young_list_target_length;
195 size_t _young_list_max_length; 176 size_t _young_list_max_length;
196 177
197 size_t _young_cset_length;
198 bool _last_young_gc_full; 178 bool _last_young_gc_full;
199 179
200 unsigned _full_young_pause_num; 180 unsigned _full_young_pause_num;
201 unsigned _partial_young_pause_num; 181 unsigned _partial_young_pause_num;
202 182
214 size_t _reserve_regions; 194 size_t _reserve_regions;
215 195
216 bool during_marking() { 196 bool during_marking() {
217 return _during_marking; 197 return _during_marking;
218 } 198 }
219
220 // <NEW PREDICTION>
221 199
222 private: 200 private:
223 enum PredictionConstants { 201 enum PredictionConstants {
224 TruncatedSeqLength = 10 202 TruncatedSeqLength = 10
225 }; 203 };
238 TruncatedSeq* _constant_other_time_ms_seq; 216 TruncatedSeq* _constant_other_time_ms_seq;
239 TruncatedSeq* _young_other_cost_per_region_ms_seq; 217 TruncatedSeq* _young_other_cost_per_region_ms_seq;
240 TruncatedSeq* _non_young_other_cost_per_region_ms_seq; 218 TruncatedSeq* _non_young_other_cost_per_region_ms_seq;
241 219
242 TruncatedSeq* _pending_cards_seq; 220 TruncatedSeq* _pending_cards_seq;
243 TruncatedSeq* _scanned_cards_seq;
244 TruncatedSeq* _rs_lengths_seq; 221 TruncatedSeq* _rs_lengths_seq;
245 222
246 TruncatedSeq* _cost_per_byte_ms_during_cm_seq; 223 TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
247 224
248 TruncatedSeq* _young_gc_eff_seq; 225 TruncatedSeq* _young_gc_eff_seq;
249
250 TruncatedSeq* _max_conc_overhead_seq;
251 226
252 bool _using_new_ratio_calculations; 227 bool _using_new_ratio_calculations;
253 size_t _min_desired_young_length; // as set on the command line or default calculations 228 size_t _min_desired_young_length; // as set on the command line or default calculations
254 size_t _max_desired_young_length; // as set on the command line or default calculations 229 size_t _max_desired_young_length; // as set on the command line or default calculations
255 230
256 size_t _recorded_young_regions; 231 size_t _eden_cset_region_length;
257 size_t _recorded_non_young_regions; 232 size_t _survivor_cset_region_length;
258 size_t _recorded_region_num; 233 size_t _old_cset_region_length;
234
235 void init_cset_region_lengths(size_t eden_cset_region_length,
236 size_t survivor_cset_region_length);
237
238 size_t eden_cset_region_length() { return _eden_cset_region_length; }
239 size_t survivor_cset_region_length() { return _survivor_cset_region_length; }
240 size_t old_cset_region_length() { return _old_cset_region_length; }
259 241
260 size_t _free_regions_at_end_of_collection; 242 size_t _free_regions_at_end_of_collection;
261 243
262 size_t _recorded_rs_lengths; 244 size_t _recorded_rs_lengths;
263 size_t _max_rs_lengths; 245 size_t _max_rs_lengths;
264
265 size_t _recorded_marked_bytes;
266 size_t _recorded_young_bytes;
267
268 size_t _predicted_pending_cards;
269 size_t _predicted_cards_scanned;
270 size_t _predicted_rs_lengths;
271 size_t _predicted_bytes_to_copy;
272
273 double _predicted_survival_ratio;
274 double _predicted_rs_update_time_ms;
275 double _predicted_rs_scan_time_ms;
276 double _predicted_object_copy_time_ms;
277 double _predicted_constant_other_time_ms;
278 double _predicted_young_other_time_ms;
279 double _predicted_non_young_other_time_ms;
280 double _predicted_pause_time_ms;
281
282 double _vtime_diff_ms;
283 246
284 double _recorded_young_free_cset_time_ms; 247 double _recorded_young_free_cset_time_ms;
285 double _recorded_non_young_free_cset_time_ms; 248 double _recorded_non_young_free_cset_time_ms;
286 249
287 double _sigma; 250 double _sigma;
318 double goal_ms); 281 double goal_ms);
319 282
320 double _pause_time_target_ms; 283 double _pause_time_target_ms;
321 double _recorded_young_cset_choice_time_ms; 284 double _recorded_young_cset_choice_time_ms;
322 double _recorded_non_young_cset_choice_time_ms; 285 double _recorded_non_young_cset_choice_time_ms;
323 bool _within_target;
324 size_t _pending_cards; 286 size_t _pending_cards;
325 size_t _max_pending_cards; 287 size_t _max_pending_cards;
326 288
327 public: 289 public:
328 290
329 void set_region_short_lived(HeapRegion* hr) { 291 void set_region_eden(HeapRegion* hr, int young_index_in_cset) {
292 hr->set_young();
330 hr->install_surv_rate_group(_short_lived_surv_rate_group); 293 hr->install_surv_rate_group(_short_lived_surv_rate_group);
331 } 294 hr->set_young_index_in_cset(young_index_in_cset);
332 295 }
333 void set_region_survivors(HeapRegion* hr) { 296
297 void set_region_survivor(HeapRegion* hr, int young_index_in_cset) {
298 assert(hr->is_young() && hr->is_survivor(), "pre-condition");
334 hr->install_surv_rate_group(_survivor_surv_rate_group); 299 hr->install_surv_rate_group(_survivor_surv_rate_group);
300 hr->set_young_index_in_cset(young_index_in_cset);
335 } 301 }
336 302
337 #ifndef PRODUCT 303 #ifndef PRODUCT
338 bool verify_young_ages(); 304 bool verify_young_ages();
339 #endif // PRODUCT 305 #endif // PRODUCT
340 306
341 double get_new_prediction(TruncatedSeq* seq) { 307 double get_new_prediction(TruncatedSeq* seq) {
342 return MAX2(seq->davg() + sigma() * seq->dsd(), 308 return MAX2(seq->davg() + sigma() * seq->dsd(),
343 seq->davg() * confidence_factor(seq->num())); 309 seq->davg() * confidence_factor(seq->num()));
344 }
345
346 size_t young_cset_length() {
347 return _young_cset_length;
348 } 310 }
349 311
350 void record_max_rs_lengths(size_t rs_lengths) { 312 void record_max_rs_lengths(size_t rs_lengths) {
351 _max_rs_lengths = rs_lengths; 313 _max_rs_lengths = rs_lengths;
352 } 314 }
463 double predict_base_elapsed_time_ms(size_t pending_cards, 425 double predict_base_elapsed_time_ms(size_t pending_cards,
464 size_t scanned_cards); 426 size_t scanned_cards);
465 size_t predict_bytes_to_copy(HeapRegion* hr); 427 size_t predict_bytes_to_copy(HeapRegion* hr);
466 double predict_region_elapsed_time_ms(HeapRegion* hr, bool young); 428 double predict_region_elapsed_time_ms(HeapRegion* hr, bool young);
467 429
468 void start_recording_regions();
469 void record_cset_region_info(HeapRegion* hr, bool young);
470 void record_non_young_cset_region(HeapRegion* hr);
471
472 void set_recorded_young_regions(size_t n_regions);
473 void set_recorded_young_bytes(size_t bytes);
474 void set_recorded_rs_lengths(size_t rs_lengths); 430 void set_recorded_rs_lengths(size_t rs_lengths);
475 void set_predicted_bytes_to_copy(size_t bytes); 431
476 432 size_t cset_region_length() { return young_cset_region_length() +
477 void end_recording_regions(); 433 old_cset_region_length(); }
478 434 size_t young_cset_region_length() { return eden_cset_region_length() +
479 void record_vtime_diff_ms(double vtime_diff_ms) { 435 survivor_cset_region_length(); }
480 _vtime_diff_ms = vtime_diff_ms;
481 }
482 436
483 void record_young_free_cset_time_ms(double time_ms) { 437 void record_young_free_cset_time_ms(double time_ms) {
484 _recorded_young_free_cset_time_ms = time_ms; 438 _recorded_young_free_cset_time_ms = time_ms;
485 } 439 }
486 440
491 double predict_young_gc_eff() { 445 double predict_young_gc_eff() {
492 return get_new_neg_prediction(_young_gc_eff_seq); 446 return get_new_neg_prediction(_young_gc_eff_seq);
493 } 447 }
494 448
495 double predict_survivor_regions_evac_time(); 449 double predict_survivor_regions_evac_time();
496
497 // </NEW PREDICTION>
498 450
499 void cset_regions_freed() { 451 void cset_regions_freed() {
500 bool propagate = _last_young_gc_full && !_in_marking_window; 452 bool propagate = _last_young_gc_full && !_in_marking_window;
501 _short_lived_surv_rate_group->all_surviving_words_recorded(propagate); 453 _short_lived_surv_rate_group->all_surviving_words_recorded(propagate);
502 _survivor_surv_rate_group->all_surviving_words_recorded(propagate); 454 _survivor_surv_rate_group->all_surviving_words_recorded(propagate);
574 double max_value (double* data); 526 double max_value (double* data);
575 double sum_of_values (double* data); 527 double sum_of_values (double* data);
576 double max_sum (double* data1, double* data2); 528 double max_sum (double* data1, double* data2);
577 529
578 int _last_satb_drain_processed_buffers; 530 int _last_satb_drain_processed_buffers;
579 int _last_update_rs_processed_buffers;
580 double _last_pause_time_ms; 531 double _last_pause_time_ms;
581 532
582 size_t _bytes_in_collection_set_before_gc; 533 size_t _bytes_in_collection_set_before_gc;
583 size_t _bytes_copied_during_gc; 534 size_t _bytes_copied_during_gc;
584 535
594 // The head of the list (via "next_in_collection_set()") representing the 545 // The head of the list (via "next_in_collection_set()") representing the
595 // current collection set. Set from the incrementally built collection 546 // current collection set. Set from the incrementally built collection
596 // set at the start of the pause. 547 // set at the start of the pause.
597 HeapRegion* _collection_set; 548 HeapRegion* _collection_set;
598 549
599 // The number of regions in the collection set. Set from the incrementally
600 // built collection set at the start of an evacuation pause.
601 size_t _collection_set_size;
602
603 // The number of bytes in the collection set before the pause. Set from 550 // The number of bytes in the collection set before the pause. Set from
604 // the incrementally built collection set at the start of an evacuation 551 // the incrementally built collection set at the start of an evacuation
605 // pause. 552 // pause.
606 size_t _collection_set_bytes_used_before; 553 size_t _collection_set_bytes_used_before;
607 554
620 HeapRegion* _inc_cset_head; 567 HeapRegion* _inc_cset_head;
621 568
622 // The tail of the incrementally built collection set. 569 // The tail of the incrementally built collection set.
623 HeapRegion* _inc_cset_tail; 570 HeapRegion* _inc_cset_tail;
624 571
625 // The number of regions in the incrementally built collection set.
626 // Used to set _collection_set_size at the start of an evacuation
627 // pause.
628 size_t _inc_cset_size;
629
630 // Used as the index in the surving young words structure
631 // which tracks the amount of space, for each young region,
632 // that survives the pause.
633 size_t _inc_cset_young_index;
634
635 // The number of bytes in the incrementally built collection set. 572 // The number of bytes in the incrementally built collection set.
636 // Used to set _collection_set_bytes_used_before at the start of 573 // Used to set _collection_set_bytes_used_before at the start of
637 // an evacuation pause. 574 // an evacuation pause.
638 size_t _inc_cset_bytes_used_before; 575 size_t _inc_cset_bytes_used_before;
639 576
640 // Used to record the highest end of heap region in collection set 577 // Used to record the highest end of heap region in collection set
641 HeapWord* _inc_cset_max_finger; 578 HeapWord* _inc_cset_max_finger;
642 579
643 // The number of recorded used bytes in the young regions
644 // of the collection set. This is the sum of the used() bytes
645 // of retired young regions in the collection set.
646 size_t _inc_cset_recorded_young_bytes;
647
648 // The RSet lengths recorded for regions in the collection set 580 // The RSet lengths recorded for regions in the collection set
649 // (updated by the periodic sampling of the regions in the 581 // (updated by the periodic sampling of the regions in the
650 // young list/collection set). 582 // young list/collection set).
651 size_t _inc_cset_recorded_rs_lengths; 583 size_t _inc_cset_recorded_rs_lengths;
652 584
653 // The predicted elapsed time it will take to collect the regions 585 // The predicted elapsed time it will take to collect the regions
654 // in the collection set (updated by the periodic sampling of the 586 // in the collection set (updated by the periodic sampling of the
655 // regions in the young list/collection set). 587 // regions in the young list/collection set).
656 double _inc_cset_predicted_elapsed_time_ms; 588 double _inc_cset_predicted_elapsed_time_ms;
657 589
658 // The predicted bytes to copy for the regions in the collection
659 // set (updated by the periodic sampling of the regions in the
660 // young list/collection set).
661 size_t _inc_cset_predicted_bytes_to_copy;
662
663 // Stash a pointer to the g1 heap. 590 // Stash a pointer to the g1 heap.
664 G1CollectedHeap* _g1; 591 G1CollectedHeap* _g1;
665 592
666 // The average time in ms per collection pause, averaged over recent pauses.
667 double recent_avg_time_for_pauses_ms();
668
669 // The average time in ms for RS scanning, per pause, averaged
670 // over recent pauses. (Note the RS scanning time for a pause
671 // is itself an average of the RS scanning time for each worker
672 // thread.)
673 double recent_avg_time_for_rs_scan_ms();
674
675 // The number of "recent" GCs recorded in the number sequences
676 int number_of_recent_gcs();
677
678 // The average survival ratio, computed by the total number of bytes
679 // suriviving / total number of bytes before collection over the last
680 // several recent pauses.
681 double recent_avg_survival_fraction();
682 // The survival fraction of the most recent pause; if there have been no
683 // pauses, returns 1.0.
684 double last_survival_fraction();
685
686 // Returns a "conservative" estimate of the recent survival rate, i.e.,
687 // one that may be higher than "recent_avg_survival_fraction".
688 // This is conservative in several ways:
689 // If there have been few pauses, it will assume a potential high
690 // variance, and err on the side of caution.
691 // It puts a lower bound (currently 0.1) on the value it will return.
692 // To try to detect phase changes, if the most recent pause ("latest") has a
693 // higher-than average ("avg") survival rate, it returns that rate.
694 // "work" version is a utility function; young is restricted to young regions.
695 double conservative_avg_survival_fraction_work(double avg,
696 double latest);
697
698 // The arguments are the two sequences that keep track of the number of bytes
699 // surviving and the total number of bytes before collection, resp.,
700 // over the last evereal recent pauses
701 // Returns the survival rate for the category in the most recent pause.
702 // If there have been no pauses, returns 1.0.
703 double last_survival_fraction_work(TruncatedSeq* surviving,
704 TruncatedSeq* before);
705
706 // The arguments are the two sequences that keep track of the number of bytes
707 // surviving and the total number of bytes before collection, resp.,
708 // over the last several recent pauses
709 // Returns the average survival ration over the last several recent pauses
710 // If there have been no pauses, return 1.0
711 double recent_avg_survival_fraction_work(TruncatedSeq* surviving,
712 TruncatedSeq* before);
713
714 double conservative_avg_survival_fraction() {
715 double avg = recent_avg_survival_fraction();
716 double latest = last_survival_fraction();
717 return conservative_avg_survival_fraction_work(avg, latest);
718 }
719
720 // The ratio of gc time to elapsed time, computed over recent pauses. 593 // The ratio of gc time to elapsed time, computed over recent pauses.
721 double _recent_avg_pause_time_ratio; 594 double _recent_avg_pause_time_ratio;
722 595
723 double recent_avg_pause_time_ratio() { 596 double recent_avg_pause_time_ratio() {
724 return _recent_avg_pause_time_ratio; 597 return _recent_avg_pause_time_ratio;
725 } 598 }
726
727 // Number of pauses between concurrent marking.
728 size_t _pauses_btwn_concurrent_mark;
729 599
730 // At the end of a pause we check the heap occupancy and we decide 600 // At the end of a pause we check the heap occupancy and we decide
731 // whether we will start a marking cycle during the next pause. If 601 // whether we will start a marking cycle during the next pause. If
732 // we decide that we want to do that, we will set this parameter to 602 // we decide that we want to do that, we will set this parameter to
733 // true. So, this parameter will stay true between the end of a 603 // true. So, this parameter will stay true between the end of a
847 717
848 BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; } 718 BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
849 719
850 GenRemSet::Name rem_set_name() { return GenRemSet::CardTable; } 720 GenRemSet::Name rem_set_name() { return GenRemSet::CardTable; }
851 721
852 // The number of collection pauses so far.
853 long n_pauses() const { return _n_pauses; }
854
855 // Update the heuristic info to record a collection pause of the given 722 // Update the heuristic info to record a collection pause of the given
856 // start time, where the given number of bytes were used at the start. 723 // start time, where the given number of bytes were used at the start.
857 // This may involve changing the desired size of a collection set. 724 // This may involve changing the desired size of a collection set.
858 725
859 void record_stop_world_start(); 726 void record_stop_world_start();
901 } 768 }
902 769
903 void record_satb_drain_processed_buffers(int processed_buffers) { 770 void record_satb_drain_processed_buffers(int processed_buffers) {
904 assert(_g1->mark_in_progress(), "shouldn't be here otherwise"); 771 assert(_g1->mark_in_progress(), "shouldn't be here otherwise");
905 _last_satb_drain_processed_buffers = processed_buffers; 772 _last_satb_drain_processed_buffers = processed_buffers;
906 }
907
908 void record_mod_union_time(double ms) {
909 _all_mod_union_times_ms->add(ms);
910 } 773 }
911 774
912 void record_update_rs_time(int thread, double ms) { 775 void record_update_rs_time(int thread, double ms) {
913 _par_last_update_rs_times_ms[thread] = ms; 776 _par_last_update_rs_times_ms[thread] = ms;
914 } 777 }
1007 // current collection set. 870 // current collection set.
1008 HeapRegion* collection_set() { return _collection_set; } 871 HeapRegion* collection_set() { return _collection_set; }
1009 872
1010 void clear_collection_set() { _collection_set = NULL; } 873 void clear_collection_set() { _collection_set = NULL; }
1011 874
1012 // The number of elements in the current collection set. 875 // Add old region "hr" to the CSet.
1013 size_t collection_set_size() { return _collection_set_size; } 876 void add_old_region_to_cset(HeapRegion* hr);
1014
1015 // Add "hr" to the CS.
1016 void add_to_collection_set(HeapRegion* hr);
1017 877
1018 // Incremental CSet Support 878 // Incremental CSet Support
1019 879
1020 // The head of the incrementally built collection set. 880 // The head of the incrementally built collection set.
1021 HeapRegion* inc_cset_head() { return _inc_cset_head; } 881 HeapRegion* inc_cset_head() { return _inc_cset_head; }
1022 882
1023 // The tail of the incrementally built collection set. 883 // The tail of the incrementally built collection set.
1024 HeapRegion* inc_set_tail() { return _inc_cset_tail; } 884 HeapRegion* inc_set_tail() { return _inc_cset_tail; }
1025
1026 // The number of elements in the incrementally built collection set.
1027 size_t inc_cset_size() { return _inc_cset_size; }
1028 885
1029 // Initialize incremental collection set info. 886 // Initialize incremental collection set info.
1030 void start_incremental_cset_building(); 887 void start_incremental_cset_building();
1031 888
1032 void clear_incremental_cset() { 889 void clear_incremental_cset() {
1122 } 979 }
1123 980
1124 size_t young_list_max_length() { 981 size_t young_list_max_length() {
1125 return _young_list_max_length; 982 return _young_list_max_length;
1126 } 983 }
1127
1128 void update_region_num(bool young);
1129 984
1130 bool full_young_gcs() { 985 bool full_young_gcs() {
1131 return _full_young_gcs; 986 return _full_young_gcs;
1132 } 987 }
1133 void set_full_young_gcs(bool full_young_gcs) { 988 void set_full_young_gcs(bool full_young_gcs) {