comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp @ 6219:922993931b3d

7178361: G1: Make sure that PrintGC and PrintGCDetails use the same timing for the GC pause Summary: Also reviewed by: vitalyd@gmail.com. Move the timing out of G1CollectorPolicy into the G1GCPhaseTimes class Reviewed-by: johnc
author brutisso
date Wed, 11 Jul 2012 22:47:38 +0200
parents bbc900c2482a
children 3a431b605145
comparison
equal deleted inserted replaced
6196:3759236eea14 6219:922993931b3d
34 // * choice of collection set. 34 // * choice of collection set.
35 // * when to collect. 35 // * when to collect.
36 36
37 class HeapRegion; 37 class HeapRegion;
38 class CollectionSetChooser; 38 class CollectionSetChooser;
39 class G1GCPhaseTimes;
39 40
40 // TraceGen0Time collects data on _both_ young and mixed evacuation pauses 41 // TraceGen0Time collects data on _both_ young and mixed evacuation pauses
41 // (the latter may contain non-young regions - i.e. regions that are 42 // (the latter may contain non-young regions - i.e. regions that are
42 // technically in Gen1) while TraceGen1Time collects data about full GCs. 43 // technically in Gen1) while TraceGen1Time collects data about full GCs.
43 class TraceGen0TimeData : public CHeapObj { 44 class TraceGen0TimeData : public CHeapObj {
59 NumberSeq _obj_copy; 60 NumberSeq _obj_copy;
60 NumberSeq _termination; 61 NumberSeq _termination;
61 NumberSeq _parallel_other; 62 NumberSeq _parallel_other;
62 NumberSeq _clear_ct; 63 NumberSeq _clear_ct;
63 64
64 void print_summary (int level, const char* str, const NumberSeq* seq) const; 65 void print_summary(const char* str, const NumberSeq* seq) const;
65 void print_summary_sd (int level, const char* str, const NumberSeq* seq) const; 66 void print_summary_sd(const char* str, const NumberSeq* seq) const;
66 67
67 public: 68 public:
68 TraceGen0TimeData() : _young_pause_num(0), _mixed_pause_num(0) {}; 69 TraceGen0TimeData() : _young_pause_num(0), _mixed_pause_num(0) {};
69 void record_start_collection(double time_to_stop_the_world_ms); 70 void record_start_collection(double time_to_stop_the_world_ms);
70 void record_yield_time(double yield_time_ms); 71 void record_yield_time(double yield_time_ms);
71 void record_end_collection( 72 void record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times);
72 double total_ms,
73 double other_ms,
74 double root_region_scan_wait_ms,
75 double parallel_ms,
76 double ext_root_scan_ms,
77 double satb_filtering_ms,
78 double update_rs_ms,
79 double scan_rs_ms,
80 double obj_copy_ms,
81 double termination_ms,
82 double parallel_other_ms,
83 double clear_ct_ms);
84 void increment_young_collection_count(); 73 void increment_young_collection_count();
85 void increment_mixed_collection_count(); 74 void increment_mixed_collection_count();
86 void print() const; 75 void print() const;
87 }; 76 };
88 77
184 initialize_perm_generation(PermGen::MarkSweepCompact); 173 initialize_perm_generation(PermGen::MarkSweepCompact);
185 } 174 }
186 175
187 CollectionSetChooser* _collectionSetChooser; 176 CollectionSetChooser* _collectionSetChooser;
188 177
189 double _cur_collection_start_sec; 178 double _full_collection_start_sec;
190 size_t _cur_collection_pause_used_at_start_bytes; 179 size_t _cur_collection_pause_used_at_start_bytes;
191 uint _cur_collection_pause_used_regions_at_start; 180 uint _cur_collection_pause_used_regions_at_start;
192 double _cur_collection_par_time_ms;
193
194 double _cur_collection_code_root_fixup_time_ms;
195
196 double _cur_clear_ct_time_ms;
197 double _cur_ref_proc_time_ms;
198 double _cur_ref_enq_time_ms;
199
200 #ifndef PRODUCT
201 // Card Table Count Cache stats
202 double _min_clear_cc_time_ms; // min
203 double _max_clear_cc_time_ms; // max
204 double _cur_clear_cc_time_ms; // clearing time during current pause
205 double _cum_clear_cc_time_ms; // cummulative clearing time
206 jlong _num_cc_clears; // number of times the card count cache has been cleared
207 #endif
208 181
209 // These exclude marking times. 182 // These exclude marking times.
210 TruncatedSeq* _recent_gc_times_ms; 183 TruncatedSeq* _recent_gc_times_ms;
211 184
212 TruncatedSeq* _concurrent_mark_remark_times_ms; 185 TruncatedSeq* _concurrent_mark_remark_times_ms;
214 187
215 TraceGen0TimeData _trace_gen0_time_data; 188 TraceGen0TimeData _trace_gen0_time_data;
216 TraceGen1TimeData _trace_gen1_time_data; 189 TraceGen1TimeData _trace_gen1_time_data;
217 190
218 double _stop_world_start; 191 double _stop_world_start;
219
220 double* _par_last_gc_worker_start_times_ms;
221 double* _par_last_ext_root_scan_times_ms;
222 double* _par_last_satb_filtering_times_ms;
223 double* _par_last_update_rs_times_ms;
224 double* _par_last_update_rs_processed_buffers;
225 double* _par_last_scan_rs_times_ms;
226 double* _par_last_obj_copy_times_ms;
227 double* _par_last_termination_times_ms;
228 double* _par_last_termination_attempts;
229 double* _par_last_gc_worker_end_times_ms;
230 double* _par_last_gc_worker_times_ms;
231
232 // Each workers 'other' time i.e. the elapsed time of the parallel
233 // code executed by a worker minus the sum of the individual sub-phase
234 // times for that worker thread.
235 double* _par_last_gc_worker_other_times_ms;
236 192
237 // indicates whether we are in young or mixed GC mode 193 // indicates whether we are in young or mixed GC mode
238 bool _gcs_are_young; 194 bool _gcs_are_young;
239 195
240 uint _young_list_target_length; 196 uint _young_list_target_length;
304 260
305 uint _free_regions_at_end_of_collection; 261 uint _free_regions_at_end_of_collection;
306 262
307 size_t _recorded_rs_lengths; 263 size_t _recorded_rs_lengths;
308 size_t _max_rs_lengths; 264 size_t _max_rs_lengths;
309
310 double _recorded_young_free_cset_time_ms;
311 double _recorded_non_young_free_cset_time_ms;
312
313 double _sigma; 265 double _sigma;
314 266
315 size_t _rs_lengths_prediction; 267 size_t _rs_lengths_prediction;
316 268
317 double sigma() { return _sigma; } 269 double sigma() { return _sigma; }
339 291
340 uintx no_of_gc_threads() { return _no_of_gc_threads; } 292 uintx no_of_gc_threads() { return _no_of_gc_threads; }
341 void set_no_of_gc_threads(uintx v) { _no_of_gc_threads = v; } 293 void set_no_of_gc_threads(uintx v) { _no_of_gc_threads = v; }
342 294
343 double _pause_time_target_ms; 295 double _pause_time_target_ms;
344 double _recorded_young_cset_choice_time_ms; 296
345 double _recorded_non_young_cset_choice_time_ms;
346 size_t _pending_cards; 297 size_t _pending_cards;
347 size_t _max_pending_cards; 298 size_t _max_pending_cards;
348 299
349 public: 300 public:
350 // Accessors 301 // Accessors
494 445
495 uint cset_region_length() { return young_cset_region_length() + 446 uint cset_region_length() { return young_cset_region_length() +
496 old_cset_region_length(); } 447 old_cset_region_length(); }
497 uint young_cset_region_length() { return eden_cset_region_length() + 448 uint young_cset_region_length() { return eden_cset_region_length() +
498 survivor_cset_region_length(); } 449 survivor_cset_region_length(); }
499
500 void record_young_free_cset_time_ms(double time_ms) {
501 _recorded_young_free_cset_time_ms = time_ms;
502 }
503
504 void record_non_young_free_cset_time_ms(double time_ms) {
505 _recorded_non_young_free_cset_time_ms = time_ms;
506 }
507 450
508 double predict_survivor_regions_evac_time(); 451 double predict_survivor_regions_evac_time();
509 452
510 void cset_regions_freed() { 453 void cset_regions_freed() {
511 bool propagate = _last_gc_was_young && !_in_marking_window; 454 bool propagate = _last_gc_was_young && !_in_marking_window;
550 double accum_yg_surv_rate_pred(int age) { 493 double accum_yg_surv_rate_pred(int age) {
551 return _short_lived_surv_rate_group->accum_surv_rate_pred(age); 494 return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
552 } 495 }
553 496
554 private: 497 private:
555 void print_stats(int level, const char* str, double value);
556 void print_stats(int level, const char* str, double value, int workers);
557 void print_stats(int level, const char* str, int value);
558
559 void print_par_stats(int level, const char* str, double* data, bool showDecimals = true);
560
561 double avg_value (double* data);
562 double max_value (double* data);
563 double sum_of_values (double* data);
564 double max_sum (double* data1, double* data2);
565
566 double _last_pause_time_ms;
567
568 size_t _bytes_in_collection_set_before_gc; 498 size_t _bytes_in_collection_set_before_gc;
569 size_t _bytes_copied_during_gc; 499 size_t _bytes_copied_during_gc;
570 500
571 // Used to count used bytes in CS. 501 // Used to count used bytes in CS.
572 friend class CountCSClosure; 502 friend class CountCSClosure;
635 // See the comment for _inc_cset_recorded_rs_lengths_diffs. 565 // See the comment for _inc_cset_recorded_rs_lengths_diffs.
636 double _inc_cset_predicted_elapsed_time_ms_diffs; 566 double _inc_cset_predicted_elapsed_time_ms_diffs;
637 567
638 // Stash a pointer to the g1 heap. 568 // Stash a pointer to the g1 heap.
639 G1CollectedHeap* _g1; 569 G1CollectedHeap* _g1;
570
571 G1GCPhaseTimes* _phase_times;
640 572
641 // The ratio of gc time to elapsed time, computed over recent pauses. 573 // The ratio of gc time to elapsed time, computed over recent pauses.
642 double _recent_avg_pause_time_ratio; 574 double _recent_avg_pause_time_ratio;
643 575
644 double recent_avg_pause_time_ratio() { 576 double recent_avg_pause_time_ratio() {
675 // This set of variables tracks the collector efficiency, in order to 607 // This set of variables tracks the collector efficiency, in order to
676 // determine whether we should initiate a new marking. 608 // determine whether we should initiate a new marking.
677 double _cur_mark_stop_world_time_ms; 609 double _cur_mark_stop_world_time_ms;
678 double _mark_remark_start_sec; 610 double _mark_remark_start_sec;
679 double _mark_cleanup_start_sec; 611 double _mark_cleanup_start_sec;
680 double _root_region_scan_wait_time_ms;
681 612
682 // Update the young list target length either by setting it to the 613 // Update the young list target length either by setting it to the
683 // desired fixed value or by calculating it using G1's pause 614 // desired fixed value or by calculating it using G1's pause
684 // prediction model. If no rs_lengths parameter is passed, predict 615 // prediction model. If no rs_lengths parameter is passed, predict
685 // the RS lengths using the prediction model, otherwise use the 616 // the RS lengths using the prediction model, otherwise use the
726 657
727 virtual CollectorPolicy::Name kind() { 658 virtual CollectorPolicy::Name kind() {
728 return CollectorPolicy::G1CollectorPolicyKind; 659 return CollectorPolicy::G1CollectorPolicyKind;
729 } 660 }
730 661
662 G1GCPhaseTimes* phase_times() const { return _phase_times; }
663
731 // Check the current value of the young list RSet lengths and 664 // Check the current value of the young list RSet lengths and
732 // compare it against the last prediction. If the current value is 665 // compare it against the last prediction. If the current value is
733 // higher, recalculate the young list target length prediction. 666 // higher, recalculate the young list target length prediction.
734 void revise_young_list_target_length_if_necessary(); 667 void revise_young_list_target_length_if_necessary();
735 668
770 703
771 // Must currently be called while the world is stopped. 704 // Must currently be called while the world is stopped.
772 void record_concurrent_mark_init_end(double 705 void record_concurrent_mark_init_end(double
773 mark_init_elapsed_time_ms); 706 mark_init_elapsed_time_ms);
774 707
775 void record_root_region_scan_wait_time(double time_ms) {
776 _root_region_scan_wait_time_ms = time_ms;
777 }
778
779 void record_concurrent_mark_remark_start(); 708 void record_concurrent_mark_remark_start();
780 void record_concurrent_mark_remark_end(); 709 void record_concurrent_mark_remark_end();
781 710
782 void record_concurrent_mark_cleanup_start(); 711 void record_concurrent_mark_cleanup_start();
783 void record_concurrent_mark_cleanup_end(int no_of_gc_threads); 712 void record_concurrent_mark_cleanup_end(int no_of_gc_threads);
784 void record_concurrent_mark_cleanup_completed(); 713 void record_concurrent_mark_cleanup_completed();
785 714
786 void record_concurrent_pause(); 715 void record_concurrent_pause();
787 void record_concurrent_pause_end(); 716
788 717 void record_collection_pause_end(double pause_time);
789 void record_collection_pause_end(int no_of_gc_threads);
790 void print_heap_transition(); 718 void print_heap_transition();
791 719
792 // Record the fact that a full collection occurred. 720 // Record the fact that a full collection occurred.
793 void record_full_collection_start(); 721 void record_full_collection_start();
794 void record_full_collection_end(); 722 void record_full_collection_end();
795
796 void record_gc_worker_start_time(int worker_i, double ms) {
797 _par_last_gc_worker_start_times_ms[worker_i] = ms;
798 }
799
800 void record_ext_root_scan_time(int worker_i, double ms) {
801 _par_last_ext_root_scan_times_ms[worker_i] = ms;
802 }
803
804 void record_satb_filtering_time(int worker_i, double ms) {
805 _par_last_satb_filtering_times_ms[worker_i] = ms;
806 }
807
808 void record_update_rs_time(int thread, double ms) {
809 _par_last_update_rs_times_ms[thread] = ms;
810 }
811
812 void record_update_rs_processed_buffers (int thread,
813 double processed_buffers) {
814 _par_last_update_rs_processed_buffers[thread] = processed_buffers;
815 }
816
817 void record_scan_rs_time(int thread, double ms) {
818 _par_last_scan_rs_times_ms[thread] = ms;
819 }
820
821 void reset_obj_copy_time(int thread) {
822 _par_last_obj_copy_times_ms[thread] = 0.0;
823 }
824
825 void reset_obj_copy_time() {
826 reset_obj_copy_time(0);
827 }
828
829 void record_obj_copy_time(int thread, double ms) {
830 _par_last_obj_copy_times_ms[thread] += ms;
831 }
832
833 void record_termination(int thread, double ms, size_t attempts) {
834 _par_last_termination_times_ms[thread] = ms;
835 _par_last_termination_attempts[thread] = (double) attempts;
836 }
837
838 void record_gc_worker_end_time(int worker_i, double ms) {
839 _par_last_gc_worker_end_times_ms[worker_i] = ms;
840 }
841
842 void record_pause_time_ms(double ms) {
843 _last_pause_time_ms = ms;
844 }
845
846 void record_clear_ct_time(double ms) {
847 _cur_clear_ct_time_ms = ms;
848 }
849
850 void record_par_time(double ms) {
851 _cur_collection_par_time_ms = ms;
852 }
853
854 void record_code_root_fixup_time(double ms) {
855 _cur_collection_code_root_fixup_time_ms = ms;
856 }
857
858 void record_ref_proc_time(double ms) {
859 _cur_ref_proc_time_ms = ms;
860 }
861
862 void record_ref_enq_time(double ms) {
863 _cur_ref_enq_time_ms = ms;
864 }
865
866 #ifndef PRODUCT
867 void record_cc_clear_time(double ms) {
868 if (_min_clear_cc_time_ms < 0.0 || ms <= _min_clear_cc_time_ms)
869 _min_clear_cc_time_ms = ms;
870 if (_max_clear_cc_time_ms < 0.0 || ms >= _max_clear_cc_time_ms)
871 _max_clear_cc_time_ms = ms;
872 _cur_clear_cc_time_ms = ms;
873 _cum_clear_cc_time_ms += ms;
874 _num_cc_clears++;
875 }
876 #endif
877 723
878 // Record how much space we copied during a GC. This is typically 724 // Record how much space we copied during a GC. This is typically
879 // called when a GC alloc region is being retired. 725 // called when a GC alloc region is being retired.
880 void record_bytes_copied_during_gc(size_t bytes) { 726 void record_bytes_copied_during_gc(size_t bytes) {
881 _bytes_copied_during_gc += bytes; 727 _bytes_copied_during_gc += bytes;