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;


 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_collection_count(bool mixed);
  82   void print() const;
  83 };
  84 
  85 class TraceGen1TimeData : public CHeapObj {
  86  private:
  87   NumberSeq _all_full_gc_times;
  88 
  89  public:
  90   void record_full_collection(double full_gc_time_ms);
  91   void print() const;
  92 };
  93 
  94 // There are three command line options related to the young gen size:
  95 // NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
  96 // just a short form for NewSize==MaxNewSize). G1 will use its internal
  97 // heuristics to calculate the actual young gen size, so these options
  98 // basically only limit the range within which G1 can pick a young gen
  99 // size. Also, these are general options taking byte sizes. G1 will
 100 // internally work with a number of regions instead. So, some rounding
 101 // will occur.
 102 //
 103 // If nothing related to the the young gen size is set on the command
 104 // line we should allow the young gen to be between
 105 // G1DefaultMinNewGenPercent and G1DefaultMaxNewGenPercent of the
 106 // heap size. This means that every time the heap size changes the
 107 // limits for the young gen size will be updated.
 108 //
 109 // If only -XX:NewSize is set we should use the specified value as the
 110 // minimum size for young gen. Still using G1DefaultMaxNewGenPercent
 111 // of the heap as maximum.


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


 214   double _stop_world_start;








 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;


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


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




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


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












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


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