src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hs-gc-remove-define_num_seq Sdiff src/share/vm/gc_implementation/g1

src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
  27 
  28 #include "gc_implementation/g1/collectionSetChooser.hpp"
  29 #include "gc_implementation/g1/g1MMUTracker.hpp"
  30 #include "memory/collectorPolicy.hpp"
  31 
  32 // A G1CollectorPolicy makes policy decisions that determine the
  33 // characteristics of the collector.  Examples include:
  34 //   * choice of collection set.
  35 //   * when to collect.
  36 
  37 class HeapRegion;
  38 class CollectionSetChooser;
  39 
  40 // Yes, this is a bit unpleasant... but it saves replicating the same thing
  41 // over and over again and introducing subtle problems through small typos and
  42 // cutting and pasting mistakes. The macros below introduces a number
  43 // sequnce into the following two classes and the methods that access it.
  44 
  45 #define define_num_seq(name)                                                  \
  46 private:                                                                      \
  47   NumberSeq _all_##name##_times_ms;                                           \
  48 public:                                                                       \
  49   void record_##name##_time_ms(double ms) {                                   \
  50     _all_##name##_times_ms.add(ms);                                           \
  51   }                                                                           \
  52   NumberSeq* get_##name##_seq() {                                             \
  53     return &_all_##name##_times_ms;                                           \
  54   }
  55 
  56 class MainBodySummary;
  57 
  58 class PauseSummary: public CHeapObj {
  59   define_num_seq(total)
  60     define_num_seq(other)
  61 
  62 public:
  63   virtual MainBodySummary*    main_body_summary()    { return NULL; }
  64 };
  65 
  66 class MainBodySummary: public CHeapObj {
  67   define_num_seq(root_region_scan_wait)
  68   define_num_seq(parallel) // parallel only
  69     define_num_seq(ext_root_scan)
  70     define_num_seq(satb_filtering)
  71     define_num_seq(update_rs)
  72     define_num_seq(scan_rs)
  73     define_num_seq(obj_copy)
  74     define_num_seq(termination) // parallel only
  75     define_num_seq(parallel_other) // parallel only
  76   define_num_seq(clear_ct)
  77 };



  78 
  79 class Summary: public PauseSummary,
  80                public MainBodySummary {
  81 public:
  82   virtual MainBodySummary*    main_body_summary()    { return this; }



























  83 };
  84 
  85 // There are three command line options related to the young gen size:
  86 // NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
  87 // just a short form for NewSize==MaxNewSize). G1 will use its internal
  88 // heuristics to calculate the actual young gen size, so these options
  89 // basically only limit the range within which G1 can pick a young gen
  90 // size. Also, these are general options taking byte sizes. G1 will
  91 // internally work with a number of regions instead. So, some rounding
  92 // will occur.
  93 //
  94 // If nothing related to the the young gen size is set on the command
  95 // line we should allow the young gen to be between
  96 // G1DefaultMinNewGenPercent and G1DefaultMaxNewGenPercent of the
  97 // heap size. This means that every time the heap size changes the
  98 // limits for the young gen size will be updated.
  99 //
 100 // If only -XX:NewSize is set we should use the specified value as the
 101 // minimum size for young gen. Still using G1DefaultMaxNewGenPercent
 102 // of the heap as maximum.


 182 
 183   double _cur_clear_ct_time_ms;
 184   double _cur_ref_proc_time_ms;
 185   double _cur_ref_enq_time_ms;
 186 
 187 #ifndef PRODUCT
 188   // Card Table Count Cache stats
 189   double _min_clear_cc_time_ms;         // min
 190   double _max_clear_cc_time_ms;         // max
 191   double _cur_clear_cc_time_ms;         // clearing time during current pause
 192   double _cum_clear_cc_time_ms;         // cummulative clearing time
 193   jlong  _num_cc_clears;                // number of times the card count cache has been cleared
 194 #endif
 195 
 196   // These exclude marking times.
 197   TruncatedSeq* _recent_gc_times_ms;
 198 
 199   TruncatedSeq* _concurrent_mark_remark_times_ms;
 200   TruncatedSeq* _concurrent_mark_cleanup_times_ms;
 201 
 202   Summary*           _summary;

 203 
 204   NumberSeq* _all_pause_times_ms;
 205   NumberSeq* _all_full_gc_times_ms;
 206   double _stop_world_start;
 207   NumberSeq* _all_stop_world_times_ms;
 208   NumberSeq* _all_yield_times_ms;
 209 
 210   int        _aux_num;
 211   NumberSeq* _all_aux_times_ms;
 212   double*    _cur_aux_start_times_ms;
 213   double*    _cur_aux_times_ms;
 214   bool*      _cur_aux_times_set;
 215 
 216   double* _par_last_gc_worker_start_times_ms;
 217   double* _par_last_ext_root_scan_times_ms;
 218   double* _par_last_satb_filtering_times_ms;
 219   double* _par_last_update_rs_times_ms;
 220   double* _par_last_update_rs_processed_buffers;
 221   double* _par_last_scan_rs_times_ms;
 222   double* _par_last_obj_copy_times_ms;
 223   double* _par_last_termination_times_ms;
 224   double* _par_last_termination_attempts;
 225   double* _par_last_gc_worker_end_times_ms;
 226   double* _par_last_gc_worker_times_ms;
 227 
 228   // Each workers 'other' time i.e. the elapsed time of the parallel
 229   // code executed by a worker minus the sum of the individual sub-phase
 230   // times for that worker thread.
 231   double* _par_last_gc_worker_other_times_ms;
 232 
 233   // indicates whether we are in young or mixed GC mode
 234   bool _gcs_are_young;
 235 
 236   uint _young_list_target_length;
 237   uint _young_list_fixed_length;
 238   size_t _prev_eden_capacity; // used for logging
 239 
 240   // The max number of regions we can extend the eden by while the GC
 241   // locker is active. This should be >= _young_list_target_length;
 242   uint _young_list_max_length;
 243 
 244   bool                  _last_gc_was_young;
 245 
 246   unsigned              _young_pause_num;
 247   unsigned              _mixed_pause_num;
 248 
 249   bool                  _during_marking;
 250   bool                  _in_marking_window;
 251   bool                  _in_marking_window_im;
 252 
 253   SurvRateGroup*        _short_lived_surv_rate_group;
 254   SurvRateGroup*        _survivor_surv_rate_group;
 255   // add here any more surv rate groups
 256 
 257   double                _gc_overhead_perc;
 258 
 259   double _reserve_factor;
 260   uint _reserve_regions;
 261 
 262   bool during_marking() {
 263     return _during_marking;
 264   }
 265 
 266 private:
 267   enum PredictionConstants {
 268     TruncatedSeqLength = 10


 540     if (pred > 1.0)
 541       pred = 1.0;
 542     return pred;
 543   }
 544 
 545   double predict_yg_surv_rate(int age) {
 546     return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
 547   }
 548 
 549   double accum_yg_surv_rate_pred(int age) {
 550     return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
 551   }
 552 
 553 private:
 554   void print_stats(int level, const char* str, double value);
 555   void print_stats(int level, const char* str, double value, int workers);
 556   void print_stats(int level, const char* str, int value);
 557 
 558   void print_par_stats(int level, const char* str, double* data, bool showDecimals = true);
 559 
 560   void check_other_times(int level,
 561                          NumberSeq* other_times_ms,
 562                          NumberSeq* calc_other_times_ms) const;
 563 
 564   void print_summary (PauseSummary* stats) const;
 565 
 566   void print_summary (int level, const char* str, NumberSeq* seq) const;
 567   void print_summary_sd (int level, const char* str, NumberSeq* seq) const;
 568 
 569   double avg_value (double* data);
 570   double max_value (double* data);
 571   double sum_of_values (double* data);
 572   double max_sum (double* data1, double* data2);
 573 
 574   double _last_pause_time_ms;
 575 
 576   size_t _bytes_in_collection_set_before_gc;
 577   size_t _bytes_copied_during_gc;
 578 
 579   // Used to count used bytes in CS.
 580   friend class CountCSClosure;
 581 
 582   // Statistics kept per GC stoppage, pause or full.
 583   TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
 584 
 585   // Add a new GC of the given duration and end time to the record.
 586   void update_recent_gc_times(double end_time_sec, double elapsed_ms);
 587 
 588   // The head of the list (via "next_in_collection_set()") representing the


 728 
 729 public:
 730 
 731   G1CollectorPolicy();
 732 
 733   virtual G1CollectorPolicy* as_g1_policy() { return this; }
 734 
 735   virtual CollectorPolicy::Name kind() {
 736     return CollectorPolicy::G1CollectorPolicyKind;
 737   }
 738 
 739   // Check the current value of the young list RSet lengths and
 740   // compare it against the last prediction. If the current value is
 741   // higher, recalculate the young list target length prediction.
 742   void revise_young_list_target_length_if_necessary();
 743 
 744   size_t bytes_in_collection_set() {
 745     return _bytes_in_collection_set_before_gc;
 746   }
 747 
 748   unsigned calc_gc_alloc_time_stamp() {
 749     return _all_pause_times_ms->num() + 1;
 750   }
 751 
 752   // This should be called after the heap is resized.
 753   void record_new_heap_size(uint new_number_of_regions);
 754 
 755   void init();
 756 
 757   // Create jstat counters for the policy.
 758   virtual void initialize_gc_policy_counters();
 759 
 760   virtual HeapWord* mem_allocate_work(size_t size,
 761                                       bool is_tlab,
 762                                       bool* gc_overhead_limit_was_exceeded);
 763 
 764   // This method controls how a collector handles one or more
 765   // of its generations being fully allocated.
 766   virtual HeapWord* satisfy_failed_allocation(size_t size,
 767                                               bool is_tlab);
 768 
 769   BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
 770 
 771   GenRemSet::Name  rem_set_name()     { return GenRemSet::CardTable; }


 848   }
 849 
 850   void record_gc_worker_end_time(int worker_i, double ms) {
 851     _par_last_gc_worker_end_times_ms[worker_i] = ms;
 852   }
 853 
 854   void record_pause_time_ms(double ms) {
 855     _last_pause_time_ms = ms;
 856   }
 857 
 858   void record_clear_ct_time(double ms) {
 859     _cur_clear_ct_time_ms = ms;
 860   }
 861 
 862   void record_par_time(double ms) {
 863     _cur_collection_par_time_ms = ms;
 864   }
 865 
 866   void record_code_root_fixup_time(double ms) {
 867     _cur_collection_code_root_fixup_time_ms = ms;
 868   }
 869 
 870   void record_aux_start_time(int i) {
 871     guarantee(i < _aux_num, "should be within range");
 872     _cur_aux_start_times_ms[i] = os::elapsedTime() * 1000.0;
 873   }
 874 
 875   void record_aux_end_time(int i) {
 876     guarantee(i < _aux_num, "should be within range");
 877     double ms = os::elapsedTime() * 1000.0 - _cur_aux_start_times_ms[i];
 878     _cur_aux_times_set[i] = true;
 879     _cur_aux_times_ms[i] += ms;
 880   }
 881 
 882   void record_ref_proc_time(double ms) {
 883     _cur_ref_proc_time_ms = ms;
 884   }
 885 
 886   void record_ref_enq_time(double ms) {
 887     _cur_ref_enq_time_ms = ms;
 888   }
 889 
 890 #ifndef PRODUCT
 891   void record_cc_clear_time(double ms) {
 892     if (_min_clear_cc_time_ms < 0.0 || ms <= _min_clear_cc_time_ms)
 893       _min_clear_cc_time_ms = ms;
 894     if (_max_clear_cc_time_ms < 0.0 || ms >= _max_clear_cc_time_ms)
 895       _max_clear_cc_time_ms = ms;
 896     _cur_clear_cc_time_ms = ms;
 897     _cum_clear_cc_time_ms += ms;
 898     _num_cc_clears++;
 899   }




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
  27 
  28 #include "gc_implementation/g1/collectionSetChooser.hpp"
  29 #include "gc_implementation/g1/g1MMUTracker.hpp"
  30 #include "memory/collectorPolicy.hpp"
  31 
  32 // A G1CollectorPolicy makes policy decisions that determine the
  33 // characteristics of the collector.  Examples include:
  34 //   * choice of collection set.
  35 //   * when to collect.
  36 
  37 class HeapRegion;
  38 class CollectionSetChooser;
  39 
  40 class TraceGen0TimeData : public CHeapObj {
  41  private:
  42   unsigned  _young_pause_num;
  43   unsigned  _mixed_pause_num;

















  44 
  45   NumberSeq _all_stop_world_times_ms;
  46   NumberSeq _all_yield_times_ms;

  47 
  48   NumberSeq _total;
  49   NumberSeq _other;
  50   NumberSeq _root_region_scan_wait;
  51   NumberSeq _parallel;
  52   NumberSeq _ext_root_scan;
  53   NumberSeq _satb_filtering;
  54   NumberSeq _update_rs;
  55   NumberSeq _scan_rs;
  56   NumberSeq _obj_copy;
  57   NumberSeq _termination;
  58   NumberSeq _parallel_other;
  59   NumberSeq _clear_ct;
  60 
  61   void print_summary (int level, const char* str, const NumberSeq* seq) const;
  62   void print_summary_sd (int level, const char* str, const NumberSeq* seq) const;
  63 


  64 public:
  65    TraceGen0TimeData() : _young_pause_num(0), _mixed_pause_num(0) {};
  66   void record_start_collection(double time_to_stop_the_world_ms);
  67   void record_yield_time(double yield_time_ms);
  68   void record_end_collection(
  69      double total_ms,
  70      double other_ms,
  71      double root_region_scan_wait_ms,
  72      double parallel_ms,
  73      double ext_root_scan_ms,
  74      double satb_filtering_ms,
  75      double update_rs_ms,
  76      double scan_rs_ms,
  77      double obj_copy_ms,
  78      double termination_ms,
  79      double parallel_other_ms,
  80      double clear_ct_ms);
  81   void increment_young_collection_count();
  82   void increment_mixed_collection_count();
  83   void print() const;
  84 };
  85 
  86 class TraceGen1TimeData : public CHeapObj {
  87  private:
  88   NumberSeq _all_full_gc_times;
  89 
  90  public:
  91   void record_full_collection(double full_gc_time_ms);
  92   void print() const;
  93 };
  94 
  95 // There are three command line options related to the young gen size:
  96 // NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
  97 // just a short form for NewSize==MaxNewSize). G1 will use its internal
  98 // heuristics to calculate the actual young gen size, so these options
  99 // basically only limit the range within which G1 can pick a young gen
 100 // size. Also, these are general options taking byte sizes. G1 will
 101 // internally work with a number of regions instead. So, some rounding
 102 // will occur.
 103 //
 104 // If nothing related to the the young gen size is set on the command
 105 // line we should allow the young gen to be between
 106 // G1DefaultMinNewGenPercent and G1DefaultMaxNewGenPercent of the
 107 // heap size. This means that every time the heap size changes the
 108 // limits for the young gen size will be updated.
 109 //
 110 // If only -XX:NewSize is set we should use the specified value as the
 111 // minimum size for young gen. Still using G1DefaultMaxNewGenPercent
 112 // of the heap as maximum.


 192 
 193   double _cur_clear_ct_time_ms;
 194   double _cur_ref_proc_time_ms;
 195   double _cur_ref_enq_time_ms;
 196 
 197 #ifndef PRODUCT
 198   // Card Table Count Cache stats
 199   double _min_clear_cc_time_ms;         // min
 200   double _max_clear_cc_time_ms;         // max
 201   double _cur_clear_cc_time_ms;         // clearing time during current pause
 202   double _cum_clear_cc_time_ms;         // cummulative clearing time
 203   jlong  _num_cc_clears;                // number of times the card count cache has been cleared
 204 #endif
 205 
 206   // These exclude marking times.
 207   TruncatedSeq* _recent_gc_times_ms;
 208 
 209   TruncatedSeq* _concurrent_mark_remark_times_ms;
 210   TruncatedSeq* _concurrent_mark_cleanup_times_ms;
 211 
 212   TraceGen0TimeData _trace_gen0_time_data;
 213   TraceGen1TimeData _trace_gen1_time_data;
 214 


 215   double _stop_world_start;








 216 
 217   double* _par_last_gc_worker_start_times_ms;
 218   double* _par_last_ext_root_scan_times_ms;
 219   double* _par_last_satb_filtering_times_ms;
 220   double* _par_last_update_rs_times_ms;
 221   double* _par_last_update_rs_processed_buffers;
 222   double* _par_last_scan_rs_times_ms;
 223   double* _par_last_obj_copy_times_ms;
 224   double* _par_last_termination_times_ms;
 225   double* _par_last_termination_attempts;
 226   double* _par_last_gc_worker_end_times_ms;
 227   double* _par_last_gc_worker_times_ms;
 228 
 229   // Each workers 'other' time i.e. the elapsed time of the parallel
 230   // code executed by a worker minus the sum of the individual sub-phase
 231   // times for that worker thread.
 232   double* _par_last_gc_worker_other_times_ms;
 233 
 234   // indicates whether we are in young or mixed GC mode
 235   bool _gcs_are_young;
 236 
 237   uint _young_list_target_length;
 238   uint _young_list_fixed_length;
 239   size_t _prev_eden_capacity; // used for logging
 240 
 241   // The max number of regions we can extend the eden by while the GC
 242   // locker is active. This should be >= _young_list_target_length;
 243   uint _young_list_max_length;
 244 
 245   bool                  _last_gc_was_young;
 246 



 247   bool                  _during_marking;
 248   bool                  _in_marking_window;
 249   bool                  _in_marking_window_im;
 250 
 251   SurvRateGroup*        _short_lived_surv_rate_group;
 252   SurvRateGroup*        _survivor_surv_rate_group;
 253   // add here any more surv rate groups
 254 
 255   double                _gc_overhead_perc;
 256 
 257   double _reserve_factor;
 258   uint _reserve_regions;
 259 
 260   bool during_marking() {
 261     return _during_marking;
 262   }
 263 
 264 private:
 265   enum PredictionConstants {
 266     TruncatedSeqLength = 10


 538     if (pred > 1.0)
 539       pred = 1.0;
 540     return pred;
 541   }
 542 
 543   double predict_yg_surv_rate(int age) {
 544     return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
 545   }
 546 
 547   double accum_yg_surv_rate_pred(int age) {
 548     return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
 549   }
 550 
 551 private:
 552   void print_stats(int level, const char* str, double value);
 553   void print_stats(int level, const char* str, double value, int workers);
 554   void print_stats(int level, const char* str, int value);
 555 
 556   void print_par_stats(int level, const char* str, double* data, bool showDecimals = true);
 557 









 558   double avg_value (double* data);
 559   double max_value (double* data);
 560   double sum_of_values (double* data);
 561   double max_sum (double* data1, double* data2);
 562 
 563   double _last_pause_time_ms;
 564 
 565   size_t _bytes_in_collection_set_before_gc;
 566   size_t _bytes_copied_during_gc;
 567 
 568   // Used to count used bytes in CS.
 569   friend class CountCSClosure;
 570 
 571   // Statistics kept per GC stoppage, pause or full.
 572   TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
 573 
 574   // Add a new GC of the given duration and end time to the record.
 575   void update_recent_gc_times(double end_time_sec, double elapsed_ms);
 576 
 577   // The head of the list (via "next_in_collection_set()") representing the


 717 
 718 public:
 719 
 720   G1CollectorPolicy();
 721 
 722   virtual G1CollectorPolicy* as_g1_policy() { return this; }
 723 
 724   virtual CollectorPolicy::Name kind() {
 725     return CollectorPolicy::G1CollectorPolicyKind;
 726   }
 727 
 728   // Check the current value of the young list RSet lengths and
 729   // compare it against the last prediction. If the current value is
 730   // higher, recalculate the young list target length prediction.
 731   void revise_young_list_target_length_if_necessary();
 732 
 733   size_t bytes_in_collection_set() {
 734     return _bytes_in_collection_set_before_gc;
 735   }
 736 




 737   // This should be called after the heap is resized.
 738   void record_new_heap_size(uint new_number_of_regions);
 739 
 740   void init();
 741 
 742   // Create jstat counters for the policy.
 743   virtual void initialize_gc_policy_counters();
 744 
 745   virtual HeapWord* mem_allocate_work(size_t size,
 746                                       bool is_tlab,
 747                                       bool* gc_overhead_limit_was_exceeded);
 748 
 749   // This method controls how a collector handles one or more
 750   // of its generations being fully allocated.
 751   virtual HeapWord* satisfy_failed_allocation(size_t size,
 752                                               bool is_tlab);
 753 
 754   BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
 755 
 756   GenRemSet::Name  rem_set_name()     { return GenRemSet::CardTable; }


 833   }
 834 
 835   void record_gc_worker_end_time(int worker_i, double ms) {
 836     _par_last_gc_worker_end_times_ms[worker_i] = ms;
 837   }
 838 
 839   void record_pause_time_ms(double ms) {
 840     _last_pause_time_ms = ms;
 841   }
 842 
 843   void record_clear_ct_time(double ms) {
 844     _cur_clear_ct_time_ms = ms;
 845   }
 846 
 847   void record_par_time(double ms) {
 848     _cur_collection_par_time_ms = ms;
 849   }
 850 
 851   void record_code_root_fixup_time(double ms) {
 852     _cur_collection_code_root_fixup_time_ms = ms;












 853   }
 854 
 855   void record_ref_proc_time(double ms) {
 856     _cur_ref_proc_time_ms = ms;
 857   }
 858 
 859   void record_ref_enq_time(double ms) {
 860     _cur_ref_enq_time_ms = ms;
 861   }
 862 
 863 #ifndef PRODUCT
 864   void record_cc_clear_time(double ms) {
 865     if (_min_clear_cc_time_ms < 0.0 || ms <= _min_clear_cc_time_ms)
 866       _min_clear_cc_time_ms = ms;
 867     if (_max_clear_cc_time_ms < 0.0 || ms >= _max_clear_cc_time_ms)
 868       _max_clear_cc_time_ms = ms;
 869     _cur_clear_cc_time_ms = ms;
 870     _cum_clear_cc_time_ms += ms;
 871     _num_cc_clears++;
 872   }


src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File