hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
changeset 12381 1438e0fbfa27
parent 12272 f87fd1292095
child 12382 6aaecb1cbfe1
equal deleted inserted replaced
12380:48f69987dbca 12381:1438e0fbfa27
   126     SizerMaxNewSizeOnly,
   126     SizerMaxNewSizeOnly,
   127     SizerMaxAndNewSize,
   127     SizerMaxAndNewSize,
   128     SizerNewRatio
   128     SizerNewRatio
   129   };
   129   };
   130   SizerKind _sizer_kind;
   130   SizerKind _sizer_kind;
   131   size_t _min_desired_young_length;
   131   uint _min_desired_young_length;
   132   size_t _max_desired_young_length;
   132   uint _max_desired_young_length;
   133   bool _adaptive_size;
   133   bool _adaptive_size;
   134   size_t calculate_default_min_length(size_t new_number_of_heap_regions);
   134   uint calculate_default_min_length(uint new_number_of_heap_regions);
   135   size_t calculate_default_max_length(size_t new_number_of_heap_regions);
   135   uint calculate_default_max_length(uint new_number_of_heap_regions);
   136 
   136 
   137 public:
   137 public:
   138   G1YoungGenSizer();
   138   G1YoungGenSizer();
   139   void heap_size_changed(size_t new_number_of_heap_regions);
   139   void heap_size_changed(uint new_number_of_heap_regions);
   140   size_t min_desired_young_length() {
   140   uint min_desired_young_length() {
   141     return _min_desired_young_length;
   141     return _min_desired_young_length;
   142   }
   142   }
   143   size_t max_desired_young_length() {
   143   uint max_desired_young_length() {
   144     return _max_desired_young_length;
   144     return _max_desired_young_length;
   145   }
   145   }
   146   bool adaptive_young_list_length() {
   146   bool adaptive_young_list_length() {
   147     return _adaptive_size;
   147     return _adaptive_size;
   148   }
   148   }
   173 
   173 
   174   CollectionSetChooser* _collectionSetChooser;
   174   CollectionSetChooser* _collectionSetChooser;
   175 
   175 
   176   double _cur_collection_start_sec;
   176   double _cur_collection_start_sec;
   177   size_t _cur_collection_pause_used_at_start_bytes;
   177   size_t _cur_collection_pause_used_at_start_bytes;
   178   size_t _cur_collection_pause_used_regions_at_start;
   178   uint   _cur_collection_pause_used_regions_at_start;
   179   double _cur_collection_par_time_ms;
   179   double _cur_collection_par_time_ms;
   180 
   180 
   181   double _cur_collection_code_root_fixup_time_ms;
   181   double _cur_collection_code_root_fixup_time_ms;
   182 
   182 
   183   double _cur_clear_ct_time_ms;
   183   double _cur_clear_ct_time_ms;
   231   double* _par_last_gc_worker_other_times_ms;
   231   double* _par_last_gc_worker_other_times_ms;
   232 
   232 
   233   // indicates whether we are in young or mixed GC mode
   233   // indicates whether we are in young or mixed GC mode
   234   bool _gcs_are_young;
   234   bool _gcs_are_young;
   235 
   235 
   236   size_t _young_list_target_length;
   236   uint _young_list_target_length;
   237   size_t _young_list_fixed_length;
   237   uint _young_list_fixed_length;
   238   size_t _prev_eden_capacity; // used for logging
   238   size_t _prev_eden_capacity; // used for logging
   239 
   239 
   240   // The max number of regions we can extend the eden by while the GC
   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;
   241   // locker is active. This should be >= _young_list_target_length;
   242   size_t _young_list_max_length;
   242   uint _young_list_max_length;
   243 
   243 
   244   bool                  _last_gc_was_young;
   244   bool                  _last_gc_was_young;
   245 
   245 
   246   unsigned              _young_pause_num;
   246   unsigned              _young_pause_num;
   247   unsigned              _mixed_pause_num;
   247   unsigned              _mixed_pause_num;
   255   // add here any more surv rate groups
   255   // add here any more surv rate groups
   256 
   256 
   257   double                _gc_overhead_perc;
   257   double                _gc_overhead_perc;
   258 
   258 
   259   double _reserve_factor;
   259   double _reserve_factor;
   260   size_t _reserve_regions;
   260   uint _reserve_regions;
   261 
   261 
   262   bool during_marking() {
   262   bool during_marking() {
   263     return _during_marking;
   263     return _during_marking;
   264   }
   264   }
   265 
   265 
   290 
   290 
   291   TruncatedSeq* _young_gc_eff_seq;
   291   TruncatedSeq* _young_gc_eff_seq;
   292 
   292 
   293   G1YoungGenSizer* _young_gen_sizer;
   293   G1YoungGenSizer* _young_gen_sizer;
   294 
   294 
   295   size_t _eden_cset_region_length;
   295   uint _eden_cset_region_length;
   296   size_t _survivor_cset_region_length;
   296   uint _survivor_cset_region_length;
   297   size_t _old_cset_region_length;
   297   uint _old_cset_region_length;
   298 
   298 
   299   void init_cset_region_lengths(size_t eden_cset_region_length,
   299   void init_cset_region_lengths(uint eden_cset_region_length,
   300                                 size_t survivor_cset_region_length);
   300                                 uint survivor_cset_region_length);
   301 
   301 
   302   size_t eden_cset_region_length()     { return _eden_cset_region_length;     }
   302   uint eden_cset_region_length()     { return _eden_cset_region_length;     }
   303   size_t survivor_cset_region_length() { return _survivor_cset_region_length; }
   303   uint survivor_cset_region_length() { return _survivor_cset_region_length; }
   304   size_t old_cset_region_length()      { return _old_cset_region_length;      }
   304   uint old_cset_region_length()      { return _old_cset_region_length;      }
   305 
   305 
   306   size_t _free_regions_at_end_of_collection;
   306   uint _free_regions_at_end_of_collection;
   307 
   307 
   308   size_t _recorded_rs_lengths;
   308   size_t _recorded_rs_lengths;
   309   size_t _max_rs_lengths;
   309   size_t _max_rs_lengths;
   310 
   310 
   311   double _recorded_young_free_cset_time_ms;
   311   double _recorded_young_free_cset_time_ms;
   494   size_t predict_bytes_to_copy(HeapRegion* hr);
   494   size_t predict_bytes_to_copy(HeapRegion* hr);
   495   double predict_region_elapsed_time_ms(HeapRegion* hr, bool young);
   495   double predict_region_elapsed_time_ms(HeapRegion* hr, bool young);
   496 
   496 
   497   void set_recorded_rs_lengths(size_t rs_lengths);
   497   void set_recorded_rs_lengths(size_t rs_lengths);
   498 
   498 
   499   size_t cset_region_length()       { return young_cset_region_length() +
   499   uint cset_region_length()       { return young_cset_region_length() +
   500                                              old_cset_region_length(); }
   500                                            old_cset_region_length(); }
   501   size_t young_cset_region_length() { return eden_cset_region_length() +
   501   uint young_cset_region_length() { return eden_cset_region_length() +
   502                                              survivor_cset_region_length(); }
   502                                            survivor_cset_region_length(); }
   503 
   503 
   504   void record_young_free_cset_time_ms(double time_ms) {
   504   void record_young_free_cset_time_ms(double time_ms) {
   505     _recorded_young_free_cset_time_ms = time_ms;
   505     _recorded_young_free_cset_time_ms = time_ms;
   506   }
   506   }
   507 
   507 
   718   void update_young_list_target_length(size_t rs_lengths = (size_t) -1);
   718   void update_young_list_target_length(size_t rs_lengths = (size_t) -1);
   719 
   719 
   720   // Calculate and return the minimum desired young list target
   720   // Calculate and return the minimum desired young list target
   721   // length. This is the minimum desired young list length according
   721   // length. This is the minimum desired young list length according
   722   // to the user's inputs.
   722   // to the user's inputs.
   723   size_t calculate_young_list_desired_min_length(size_t base_min_length);
   723   uint calculate_young_list_desired_min_length(uint base_min_length);
   724 
   724 
   725   // Calculate and return the maximum desired young list target
   725   // Calculate and return the maximum desired young list target
   726   // length. This is the maximum desired young list length according
   726   // length. This is the maximum desired young list length according
   727   // to the user's inputs.
   727   // to the user's inputs.
   728   size_t calculate_young_list_desired_max_length();
   728   uint calculate_young_list_desired_max_length();
   729 
   729 
   730   // Calculate and return the maximum young list target length that
   730   // Calculate and return the maximum young list target length that
   731   // can fit into the pause time goal. The parameters are: rs_lengths
   731   // can fit into the pause time goal. The parameters are: rs_lengths
   732   // represent the prediction of how large the young RSet lengths will
   732   // represent the prediction of how large the young RSet lengths will
   733   // be, base_min_length is the alreay existing number of regions in
   733   // be, base_min_length is the alreay existing number of regions in
   734   // the young list, min_length and max_length are the desired min and
   734   // the young list, min_length and max_length are the desired min and
   735   // max young list length according to the user's inputs.
   735   // max young list length according to the user's inputs.
   736   size_t calculate_young_list_target_length(size_t rs_lengths,
   736   uint calculate_young_list_target_length(size_t rs_lengths,
   737                                             size_t base_min_length,
   737                                           uint base_min_length,
   738                                             size_t desired_min_length,
   738                                           uint desired_min_length,
   739                                             size_t desired_max_length);
   739                                           uint desired_max_length);
   740 
   740 
   741   // Check whether a given young length (young_length) fits into the
   741   // Check whether a given young length (young_length) fits into the
   742   // given target pause time and whether the prediction for the amount
   742   // given target pause time and whether the prediction for the amount
   743   // of objects to be copied for the given length will fit into the
   743   // of objects to be copied for the given length will fit into the
   744   // given free space (expressed by base_free_regions).  It is used by
   744   // given free space (expressed by base_free_regions).  It is used by
   745   // calculate_young_list_target_length().
   745   // calculate_young_list_target_length().
   746   bool predict_will_fit(size_t young_length, double base_time_ms,
   746   bool predict_will_fit(uint young_length, double base_time_ms,
   747                         size_t base_free_regions, double target_pause_time_ms);
   747                         uint base_free_regions, double target_pause_time_ms);
   748 
   748 
   749   // Count the number of bytes used in the CS.
   749   // Count the number of bytes used in the CS.
   750   void count_CS_bytes_used();
   750   void count_CS_bytes_used();
   751 
   751 
   752 public:
   752 public:
   771   unsigned calc_gc_alloc_time_stamp() {
   771   unsigned calc_gc_alloc_time_stamp() {
   772     return _all_pause_times_ms->num() + 1;
   772     return _all_pause_times_ms->num() + 1;
   773   }
   773   }
   774 
   774 
   775   // This should be called after the heap is resized.
   775   // This should be called after the heap is resized.
   776   void record_new_heap_size(size_t new_number_of_regions);
   776   void record_new_heap_size(uint new_number_of_regions);
   777 
   777 
   778   void init();
   778   void init();
   779 
   779 
   780   // Create jstat counters for the policy.
   780   // Create jstat counters for the policy.
   781   virtual void initialize_gc_policy_counters();
   781   virtual void initialize_gc_policy_counters();
  1046     }
  1046     }
  1047     // do that for any other surv rate groups
  1047     // do that for any other surv rate groups
  1048   }
  1048   }
  1049 
  1049 
  1050   bool is_young_list_full() {
  1050   bool is_young_list_full() {
  1051     size_t young_list_length = _g1->young_list()->length();
  1051     uint young_list_length = _g1->young_list()->length();
  1052     size_t young_list_target_length = _young_list_target_length;
  1052     uint young_list_target_length = _young_list_target_length;
  1053     return young_list_length >= young_list_target_length;
  1053     return young_list_length >= young_list_target_length;
  1054   }
  1054   }
  1055 
  1055 
  1056   bool can_expand_young_list() {
  1056   bool can_expand_young_list() {
  1057     size_t young_list_length = _g1->young_list()->length();
  1057     uint young_list_length = _g1->young_list()->length();
  1058     size_t young_list_max_length = _young_list_max_length;
  1058     uint young_list_max_length = _young_list_max_length;
  1059     return young_list_length < young_list_max_length;
  1059     return young_list_length < young_list_max_length;
  1060   }
  1060   }
  1061 
  1061 
  1062   size_t young_list_max_length() {
  1062   uint young_list_max_length() {
  1063     return _young_list_max_length;
  1063     return _young_list_max_length;
  1064   }
  1064   }
  1065 
  1065 
  1066   bool gcs_are_young() {
  1066   bool gcs_are_young() {
  1067     return _gcs_are_young;
  1067     return _gcs_are_young;
  1095   // Current tenuring threshold, set to 0 if the collector reaches the
  1095   // Current tenuring threshold, set to 0 if the collector reaches the
  1096   // maximum amount of suvivors regions.
  1096   // maximum amount of suvivors regions.
  1097   int _tenuring_threshold;
  1097   int _tenuring_threshold;
  1098 
  1098 
  1099   // The limit on the number of regions allocated for survivors.
  1099   // The limit on the number of regions allocated for survivors.
  1100   size_t _max_survivor_regions;
  1100   uint _max_survivor_regions;
  1101 
  1101 
  1102   // For reporting purposes.
  1102   // For reporting purposes.
  1103   size_t _eden_bytes_before_gc;
  1103   size_t _eden_bytes_before_gc;
  1104   size_t _survivor_bytes_before_gc;
  1104   size_t _survivor_bytes_before_gc;
  1105   size_t _capacity_before_gc;
  1105   size_t _capacity_before_gc;
  1106 
  1106 
  1107   // The amount of survor regions after a collection.
  1107   // The amount of survor regions after a collection.
  1108   size_t _recorded_survivor_regions;
  1108   uint _recorded_survivor_regions;
  1109   // List of survivor regions.
  1109   // List of survivor regions.
  1110   HeapRegion* _recorded_survivor_head;
  1110   HeapRegion* _recorded_survivor_head;
  1111   HeapRegion* _recorded_survivor_tail;
  1111   HeapRegion* _recorded_survivor_tail;
  1112 
  1112 
  1113   ageTable _survivors_age_table;
  1113   ageTable _survivors_age_table;
  1125 
  1125 
  1126   inline bool track_object_age(GCAllocPurpose purpose) {
  1126   inline bool track_object_age(GCAllocPurpose purpose) {
  1127     return purpose == GCAllocForSurvived;
  1127     return purpose == GCAllocForSurvived;
  1128   }
  1128   }
  1129 
  1129 
  1130   static const size_t REGIONS_UNLIMITED = ~(size_t)0;
  1130   static const uint REGIONS_UNLIMITED = (uint) -1;
  1131 
  1131 
  1132   size_t max_regions(int purpose);
  1132   uint max_regions(int purpose);
  1133 
  1133 
  1134   // The limit on regions for a particular purpose is reached.
  1134   // The limit on regions for a particular purpose is reached.
  1135   void note_alloc_region_limit_reached(int purpose) {
  1135   void note_alloc_region_limit_reached(int purpose) {
  1136     if (purpose == GCAllocForSurvived) {
  1136     if (purpose == GCAllocForSurvived) {
  1137       _tenuring_threshold = 0;
  1137       _tenuring_threshold = 0;
  1144 
  1144 
  1145   void note_stop_adding_survivor_regions() {
  1145   void note_stop_adding_survivor_regions() {
  1146     _survivor_surv_rate_group->stop_adding_regions();
  1146     _survivor_surv_rate_group->stop_adding_regions();
  1147   }
  1147   }
  1148 
  1148 
  1149   void record_survivor_regions(size_t      regions,
  1149   void record_survivor_regions(uint regions,
  1150                                HeapRegion* head,
  1150                                HeapRegion* head,
  1151                                HeapRegion* tail) {
  1151                                HeapRegion* tail) {
  1152     _recorded_survivor_regions = regions;
  1152     _recorded_survivor_regions = regions;
  1153     _recorded_survivor_head    = head;
  1153     _recorded_survivor_head    = head;
  1154     _recorded_survivor_tail    = tail;
  1154     _recorded_survivor_tail    = tail;
  1155   }
  1155   }
  1156 
  1156 
  1157   size_t recorded_survivor_regions() {
  1157   uint recorded_survivor_regions() {
  1158     return _recorded_survivor_regions;
  1158     return _recorded_survivor_regions;
  1159   }
  1159   }
  1160 
  1160 
  1161   void record_thread_age_table(ageTable* age_table)
  1161   void record_thread_age_table(ageTable* age_table) {
  1162   {
       
  1163     _survivors_age_table.merge_par(age_table);
  1162     _survivors_age_table.merge_par(age_table);
  1164   }
  1163   }
  1165 
  1164 
  1166   void update_max_gc_locker_expansion();
  1165   void update_max_gc_locker_expansion();
  1167 
  1166