src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/gc_implementation/shared

src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp

Print this page
rev 5732 : [mq]: comments2


  57 
  58     increase_old_gen_for_min_pauses_true = -5,
  59     decrease_old_gen_for_min_pauses_true = -4,
  60     decrease_young_gen_for_maj_pauses_true = -3,
  61     increase_young_gen_for_min_pauses_true = -2,
  62     increase_old_gen_for_maj_pauses_true = -1,
  63 
  64     decrease_young_gen_for_min_pauses_true = 1,
  65     decrease_old_gen_for_maj_pauses_true = 2,
  66     increase_young_gen_for_maj_pauses_true = 3,
  67 
  68     increase_old_gen_for_throughput_true = 4,
  69     increase_young_gen_for_througput_true = 5,
  70 
  71     decrease_young_gen_for_footprint_true = 6,
  72     decrease_old_gen_for_footprint_true = 7,
  73     decide_at_full_gc_true = 8
  74   };
  75 
  76   // Goal for the fraction of the total time during which application
  77   // threads run.
  78   const double _throughput_goal;
  79 
  80   // Last calculated sizes, in bytes, and aligned
  81   size_t _eden_size;        // calculated eden free space in bytes
  82   size_t _promo_size;       // calculated cms gen free space in bytes
  83 
  84   size_t _survivor_size;    // calculated survivor size in bytes
  85 
  86   // This is a hint for the heap:  we've detected that gc times
  87   // are taking longer than GCTimeLimit allows.
  88   bool _gc_overhead_limit_exceeded;
  89   // Use for diagnostics only.  If UseGCOverheadLimit is false,
  90   // this variable is still set.
  91   bool _print_gc_overhead_limit_would_be_exceeded;
  92   // Count of consecutive GC that have exceeded the
  93   // GC time limit criterion.
  94   uint _gc_overhead_limit_count;
  95   // This flag signals that GCTimeLimit is being exceeded
  96   // but may not have done so for the required number of consequetive
  97   // collections.
  98 
  99   // Minor collection timers used to determine both
 100   // pause and interval times for collections.
 101   static elapsedTimer _minor_timer;
 102 
 103   // Major collection timers, used to determine both
 104   // pause and interval times for collections
 105   static elapsedTimer _major_timer;
 106 
 107   // Time statistics
 108   AdaptivePaddedAverage*   _avg_minor_pause;
 109   AdaptiveWeightedAverage* _avg_minor_interval;
 110   AdaptiveWeightedAverage* _avg_minor_gc_cost;
 111 
 112   AdaptiveWeightedAverage* _avg_major_interval;
 113   AdaptiveWeightedAverage* _avg_major_gc_cost;
 114 
 115   // Footprint statistics
 116   AdaptiveWeightedAverage* _avg_young_live;
 117   AdaptiveWeightedAverage* _avg_eden_live;
 118   AdaptiveWeightedAverage* _avg_old_live;
 119 
 120   // Statistics for survivor space calculation for young generation
 121   AdaptivePaddedAverage*   _avg_survived;
 122 
 123   // Objects that have been directly allocated in the old generation.
 124   AdaptivePaddedNoZeroDevAverage*   _avg_pretenured;
 125 
 126   // Variable for estimating the major and minor pause times.
 127   // These variables represent linear least-squares fits of
 128   // the data.
 129   //   minor pause time vs. old gen size
 130   LinearLeastSquareFit* _minor_pause_old_estimator;
 131   //   minor pause time vs. young gen size
 132   LinearLeastSquareFit* _minor_pause_young_estimator;
 133 
 134   // Variables for estimating the major and minor collection costs
 135   //   minor collection time vs. young gen size
 136   LinearLeastSquareFit* _minor_collection_estimator;
 137   //   major collection time vs. cms gen size
 138   LinearLeastSquareFit* _major_collection_estimator;
 139 
 140   // These record the most recent collection times.  They
 141   // are available as an alternative to using the averages
 142   // for making ergonomic decisions.
 143   double _latest_minor_mutator_interval_seconds;
 144 
 145   // Allowed difference between major and minor gc times, used
 146   // for computing tenuring_threshold.
 147   const double _threshold_tolerance_percent;
 148 
 149   const double _gc_pause_goal_sec; // goal for maximum gc pause
 150 
 151   // Flag indicating that the adaptive policy is ready to use
 152   bool _young_gen_policy_is_ready;
 153 
 154   // decrease/increase the young generation for minor pause time
 155   int _change_young_gen_for_min_pauses;
 156 
 157   // decrease/increase the old generation for major pause time
 158   int _change_old_gen_for_maj_pauses;
 159 
 160   //   change old geneneration for throughput
 161   int _change_old_gen_for_throughput;
 162 
 163   //   change young generation for throughput
 164   int _change_young_gen_for_throughput;
 165 
 166   // Flag indicating that the policy would
 167   //   increase the tenuring threshold because of the total major gc cost
 168   //   is greater than the total minor gc cost
 169   bool _increment_tenuring_threshold_for_gc_cost;
 170   //   decrease the tenuring threshold because of the the total minor gc
 171   //   cost is greater than the total major gc cost
 172   bool _decrement_tenuring_threshold_for_gc_cost;
 173   //   decrease due to survivor size limit
 174   bool _decrement_tenuring_threshold_for_survivor_limit;
 175 
 176   //   decrease generation sizes for footprint
 177   int _decrease_for_footprint;
 178 
 179   // Set if the ergonomic decisions were made at a full GC.
 180   int _decide_at_full_gc;
 181 
 182   // Changing the generation sizing depends on the data that is
 183   // gathered about the effects of changes on the pause times and
 184   // throughput.  These variable count the number of data points
 185   // gathered.  The policy may use these counters as a threshhold
 186   // for reliable data.
 187   julong _young_gen_change_for_minor_throughput;
 188   julong _old_gen_change_for_major_throughput;
 189 
 190   static const uint GCWorkersPerJavaThread  = 2;
 191 
 192   // Accessors
 193 
 194   double gc_pause_goal_sec() const { return _gc_pause_goal_sec; }
 195   // The value returned is unitless:  it's the proportion of time
 196   // spent in a particular collection type.
 197   // An interval time will be 0.0 if a collection type hasn't occurred yet.
 198   // The 1.4.2 implementation put a floor on the values of major_gc_cost
 199   // and minor_gc_cost.  This was useful because of the way major_gc_cost
 200   // and minor_gc_cost was used in calculating the sizes of the generations.
 201   // Do not use a floor in this implementation because any finite value
 202   // will put a limit on the throughput that can be achieved and any
 203   // throughput goal above that limit will drive the generations sizes
 204   // to extremes.
 205   double major_gc_cost() const {


 208 
 209   // The value returned is unitless:  it's the proportion of time
 210   // spent in a particular collection type.
 211   // An interval time will be 0.0 if a collection type hasn't occurred yet.
 212   // The 1.4.2 implementation put a floor on the values of major_gc_cost
 213   // and minor_gc_cost.  This was useful because of the way major_gc_cost
 214   // and minor_gc_cost was used in calculating the sizes of the generations.
 215   // Do not use a floor in this implementation because any finite value
 216   // will put a limit on the throughput that can be achieved and any
 217   // throughput goal above that limit will drive the generations sizes
 218   // to extremes.
 219 
 220   double minor_gc_cost() const {
 221     return MAX2(0.0F, _avg_minor_gc_cost->average());
 222   }
 223 
 224   // Because we're dealing with averages, gc_cost() can be
 225   // larger than 1.0 if just the sum of the minor cost the
 226   // the major cost is used.  Worse than that is the
 227   // fact that the minor cost and the major cost each
 228   // tend toward 1.0 in the extreme of high gc costs.
 229   // Limit the value of gc_cost to 1.0 so that the mutator
 230   // cost stays non-negative.
 231   virtual double gc_cost() const {
 232     double result = MIN2(1.0, minor_gc_cost() + major_gc_cost());
 233     assert(result >= 0.0, "Both minor and major costs are non-negative");
 234     return result;
 235   }
 236 
 237   // Elapsed time since the last major collection.
 238   virtual double time_since_major_gc() const;
 239 
 240   // Average interval between major collections to be used
 241   // in calculating the decaying major gc cost.  An overestimate
 242   // of this time would be a conservative estimate because
 243   // this time is used to decide if the major GC cost
 244   // should be decayed (i.e., if the time since the last
 245   // major gc is long compared to the time returned here,
 246   // then the major GC cost will be decayed).  See the
 247   // implementations for the specifics.
 248   virtual double major_gc_interval_average_for_decay() const {
 249     return _avg_major_interval->average();
 250   }
 251 
 252   // Return the cost of the GC where the major gc cost
 253   // has been decayed based on the time since the last
 254   // major collection.
 255   double decaying_gc_cost() const;
 256 
 257   // Decay the major gc cost.  Use this only for decisions on
 258   // whether to adjust, not to determine by how much to adjust.
 259   // This approximation is crude and may not be good enough for the
 260   // latter.
 261   double decaying_major_gc_cost() const;
 262 
 263   // Return the mutator cost using the decayed
 264   // GC cost.
 265   double adjusted_mutator_cost() const {
 266     double result = 1.0 - decaying_gc_cost();
 267     assert(result >= 0.0, "adjusted mutator cost calculation is incorrect");
 268     return result;
 269   }
 270 
 271   virtual double mutator_cost() const {
 272     double result = 1.0 - gc_cost();
 273     assert(result >= 0.0, "mutator cost calculation is incorrect");
 274     return result;
 275   }
 276 
 277 




  57 
  58     increase_old_gen_for_min_pauses_true = -5,
  59     decrease_old_gen_for_min_pauses_true = -4,
  60     decrease_young_gen_for_maj_pauses_true = -3,
  61     increase_young_gen_for_min_pauses_true = -2,
  62     increase_old_gen_for_maj_pauses_true = -1,
  63 
  64     decrease_young_gen_for_min_pauses_true = 1,
  65     decrease_old_gen_for_maj_pauses_true = 2,
  66     increase_young_gen_for_maj_pauses_true = 3,
  67 
  68     increase_old_gen_for_throughput_true = 4,
  69     increase_young_gen_for_througput_true = 5,
  70 
  71     decrease_young_gen_for_footprint_true = 6,
  72     decrease_old_gen_for_footprint_true = 7,
  73     decide_at_full_gc_true = 8
  74   };
  75 
  76   // Goal for the fraction of the total time during which application
  77   // threads run
  78   const double _throughput_goal;
  79 
  80   // Last calculated sizes, in bytes, and aligned
  81   size_t _eden_size;        // calculated eden free space in bytes
  82   size_t _promo_size;       // calculated cms gen free space in bytes
  83 
  84   size_t _survivor_size;    // calculated survivor size in bytes
  85 
  86   // This is a hint for the heap:  we've detected that GC times
  87   // are taking longer than GCTimeLimit allows.
  88   bool _gc_overhead_limit_exceeded;
  89   // Use for diagnostics only.  If UseGCOverheadLimit is false,
  90   // this variable is still set.
  91   bool _print_gc_overhead_limit_would_be_exceeded;
  92   // Count of consecutive GC that have exceeded the
  93   // GC time limit criterion
  94   uint _gc_overhead_limit_count;
  95   // This flag signals that GCTimeLimit is being exceeded
  96   // but may not have done so for the required number of consecutive
  97   // collections
  98 
  99   // Minor collection timers used to determine both
 100   // pause and interval times for collections
 101   static elapsedTimer _minor_timer;
 102 
 103   // Major collection timers, used to determine both
 104   // pause and interval times for collections
 105   static elapsedTimer _major_timer;
 106 
 107   // Time statistics
 108   AdaptivePaddedAverage*   _avg_minor_pause;
 109   AdaptiveWeightedAverage* _avg_minor_interval;
 110   AdaptiveWeightedAverage* _avg_minor_gc_cost;
 111 
 112   AdaptiveWeightedAverage* _avg_major_interval;
 113   AdaptiveWeightedAverage* _avg_major_gc_cost;
 114 
 115   // Footprint statistics
 116   AdaptiveWeightedAverage* _avg_young_live;
 117   AdaptiveWeightedAverage* _avg_eden_live;
 118   AdaptiveWeightedAverage* _avg_old_live;
 119 
 120   // Statistics for survivor space calculation for young generation
 121   AdaptivePaddedAverage*   _avg_survived;
 122 
 123   // Objects that have been directly allocated in the old generation
 124   AdaptivePaddedNoZeroDevAverage*   _avg_pretenured;
 125 
 126   // Variable for estimating the major and minor pause times.
 127   // These variables represent linear least-squares fits of
 128   // the data.
 129   //   minor pause time vs. old gen size
 130   LinearLeastSquareFit* _minor_pause_old_estimator;
 131   //   minor pause time vs. young gen size
 132   LinearLeastSquareFit* _minor_pause_young_estimator;
 133 
 134   // Variables for estimating the major and minor collection costs
 135   //   minor collection time vs. young gen size
 136   LinearLeastSquareFit* _minor_collection_estimator;
 137   //   major collection time vs. cms gen size
 138   LinearLeastSquareFit* _major_collection_estimator;
 139 
 140   // These record the most recent collection times.  They
 141   // are available as an alternative to using the averages
 142   // for making ergonomic decisions.
 143   double _latest_minor_mutator_interval_seconds;
 144 
 145   // Allowed difference between major and minor GC times, used
 146   // for computing tenuring_threshold
 147   const double _threshold_tolerance_percent;
 148 
 149   const double _gc_pause_goal_sec; // Goal for maximum GC pause
 150 
 151   // Flag indicating that the adaptive policy is ready to use
 152   bool _young_gen_policy_is_ready;
 153 
 154   // Decrease/increase the young generation for minor pause time
 155   int _change_young_gen_for_min_pauses;
 156 
 157   // Decrease/increase the old generation for major pause time
 158   int _change_old_gen_for_maj_pauses;
 159 
 160   //   change old generation for throughput
 161   int _change_old_gen_for_throughput;
 162 
 163   //   change young generation for throughput
 164   int _change_young_gen_for_throughput;
 165 
 166   // Flag indicating that the policy would
 167   //   increase the tenuring threshold because of the total major GC cost
 168   //   is greater than the total minor GC cost
 169   bool _increment_tenuring_threshold_for_gc_cost;
 170   //   decrease the tenuring threshold because of the the total minor GC
 171   //   cost is greater than the total major GC cost
 172   bool _decrement_tenuring_threshold_for_gc_cost;
 173   //   decrease due to survivor size limit
 174   bool _decrement_tenuring_threshold_for_survivor_limit;
 175 
 176   //   decrease generation sizes for footprint
 177   int _decrease_for_footprint;
 178 
 179   // Set if the ergonomic decisions were made at a full GC.
 180   int _decide_at_full_gc;
 181 
 182   // Changing the generation sizing depends on the data that is
 183   // gathered about the effects of changes on the pause times and
 184   // throughput.  These variable count the number of data points
 185   // gathered.  The policy may use these counters as a threshold
 186   // for reliable data.
 187   julong _young_gen_change_for_minor_throughput;
 188   julong _old_gen_change_for_major_throughput;
 189 
 190   static const uint GCWorkersPerJavaThread  = 2;
 191 
 192   // Accessors
 193 
 194   double gc_pause_goal_sec() const { return _gc_pause_goal_sec; }
 195   // The value returned is unitless:  it's the proportion of time
 196   // spent in a particular collection type.
 197   // An interval time will be 0.0 if a collection type hasn't occurred yet.
 198   // The 1.4.2 implementation put a floor on the values of major_gc_cost
 199   // and minor_gc_cost.  This was useful because of the way major_gc_cost
 200   // and minor_gc_cost was used in calculating the sizes of the generations.
 201   // Do not use a floor in this implementation because any finite value
 202   // will put a limit on the throughput that can be achieved and any
 203   // throughput goal above that limit will drive the generations sizes
 204   // to extremes.
 205   double major_gc_cost() const {


 208 
 209   // The value returned is unitless:  it's the proportion of time
 210   // spent in a particular collection type.
 211   // An interval time will be 0.0 if a collection type hasn't occurred yet.
 212   // The 1.4.2 implementation put a floor on the values of major_gc_cost
 213   // and minor_gc_cost.  This was useful because of the way major_gc_cost
 214   // and minor_gc_cost was used in calculating the sizes of the generations.
 215   // Do not use a floor in this implementation because any finite value
 216   // will put a limit on the throughput that can be achieved and any
 217   // throughput goal above that limit will drive the generations sizes
 218   // to extremes.
 219 
 220   double minor_gc_cost() const {
 221     return MAX2(0.0F, _avg_minor_gc_cost->average());
 222   }
 223 
 224   // Because we're dealing with averages, gc_cost() can be
 225   // larger than 1.0 if just the sum of the minor cost the
 226   // the major cost is used.  Worse than that is the
 227   // fact that the minor cost and the major cost each
 228   // tend toward 1.0 in the extreme of high GC costs.
 229   // Limit the value of gc_cost to 1.0 so that the mutator
 230   // cost stays non-negative.
 231   virtual double gc_cost() const {
 232     double result = MIN2(1.0, minor_gc_cost() + major_gc_cost());
 233     assert(result >= 0.0, "Both minor and major costs are non-negative");
 234     return result;
 235   }
 236 
 237   // Elapsed time since the last major collection.
 238   virtual double time_since_major_gc() const;
 239 
 240   // Average interval between major collections to be used
 241   // in calculating the decaying major GC cost.  An overestimate
 242   // of this time would be a conservative estimate because
 243   // this time is used to decide if the major GC cost
 244   // should be decayed (i.e., if the time since the last
 245   // major GC is long compared to the time returned here,
 246   // then the major GC cost will be decayed).  See the
 247   // implementations for the specifics.
 248   virtual double major_gc_interval_average_for_decay() const {
 249     return _avg_major_interval->average();
 250   }
 251 
 252   // Return the cost of the GC where the major GC cost
 253   // has been decayed based on the time since the last
 254   // major collection.
 255   double decaying_gc_cost() const;
 256 
 257   // Decay the major GC cost.  Use this only for decisions on
 258   // whether to adjust, not to determine by how much to adjust.
 259   // This approximation is crude and may not be good enough for the
 260   // latter.
 261   double decaying_major_gc_cost() const;
 262 
 263   // Return the mutator cost using the decayed
 264   // GC cost.
 265   double adjusted_mutator_cost() const {
 266     double result = 1.0 - decaying_gc_cost();
 267     assert(result >= 0.0, "adjusted mutator cost calculation is incorrect");
 268     return result;
 269   }
 270 
 271   virtual double mutator_cost() const {
 272     double result = 1.0 - gc_cost();
 273     assert(result >= 0.0, "mutator cost calculation is incorrect");
 274     return result;
 275   }
 276 
 277 


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