src/hotspot/share/gc/shared/adaptiveSizePolicy.hpp
changeset 54085 ab87b06dfdc0
parent 53244 9807daeb47c4
child 59053 ba6c248cae19
equal deleted inserted replaced
54084:84f10bbf993f 54085:ab87b06dfdc0
    24 
    24 
    25 #ifndef SHARE_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
    25 #ifndef SHARE_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
    26 #define SHARE_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
    26 #define SHARE_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
    27 
    27 
    28 #include "gc/shared/gcCause.hpp"
    28 #include "gc/shared/gcCause.hpp"
       
    29 #include "gc/shared/gcOverheadChecker.hpp"
    29 #include "gc/shared/gcUtil.hpp"
    30 #include "gc/shared/gcUtil.hpp"
    30 #include "memory/allocation.hpp"
    31 #include "memory/allocation.hpp"
    31 
    32 
    32 // This class keeps statistical information and computes the
    33 // This class keeps statistical information and computes the
    33 // size of the heap.
    34 // size of the heap.
    34 
    35 
    35 // Forward decls
    36 // Forward decls
    36 class elapsedTimer;
    37 class elapsedTimer;
    37 class SoftRefPolicy;
       
    38 
    38 
    39 class AdaptiveSizePolicy : public CHeapObj<mtGC> {
    39 class AdaptiveSizePolicy : public CHeapObj<mtGC> {
    40  friend class GCAdaptivePolicyCounters;
    40  friend class GCAdaptivePolicyCounters;
    41  friend class PSGCAdaptivePolicyCounters;
    41  friend class PSGCAdaptivePolicyCounters;
    42  friend class CMSGCAdaptivePolicyCounters;
    42  friend class CMSGCAdaptivePolicyCounters;
    79   size_t _eden_size;        // calculated eden free space in bytes
    79   size_t _eden_size;        // calculated eden free space in bytes
    80   size_t _promo_size;       // calculated cms gen free space in bytes
    80   size_t _promo_size;       // calculated cms gen free space in bytes
    81 
    81 
    82   size_t _survivor_size;    // calculated survivor size in bytes
    82   size_t _survivor_size;    // calculated survivor size in bytes
    83 
    83 
    84   // This is a hint for the heap:  we've detected that GC times
    84   // Support for UseGCOverheadLimit
    85   // are taking longer than GCTimeLimit allows.
    85   GCOverheadChecker _overhead_checker;
    86   bool _gc_overhead_limit_exceeded;
       
    87   // Use for diagnostics only.  If UseGCOverheadLimit is false,
       
    88   // this variable is still set.
       
    89   bool _print_gc_overhead_limit_would_be_exceeded;
       
    90   // Count of consecutive GC that have exceeded the
       
    91   // GC time limit criterion
       
    92   uint _gc_overhead_limit_count;
       
    93   // This flag signals that GCTimeLimit is being exceeded
       
    94   // but may not have done so for the required number of consecutive
       
    95   // collections
       
    96 
    86 
    97   // Minor collection timers used to determine both
    87   // Minor collection timers used to determine both
    98   // pause and interval times for collections
    88   // pause and interval times for collections
    99   static elapsedTimer _minor_timer;
    89   static elapsedTimer _minor_timer;
   100 
    90 
   410 
   400 
   411   size_t calculated_survivor_size_in_bytes() const {
   401   size_t calculated_survivor_size_in_bytes() const {
   412     return _survivor_size;
   402     return _survivor_size;
   413   }
   403   }
   414 
   404 
   415   // This is a hint for the heap:  we've detected that gc times
       
   416   // are taking longer than GCTimeLimit allows.
       
   417   // Most heaps will choose to throw an OutOfMemoryError when
       
   418   // this occurs but it is up to the heap to request this information
       
   419   // of the policy
       
   420   bool gc_overhead_limit_exceeded() {
   405   bool gc_overhead_limit_exceeded() {
   421     return _gc_overhead_limit_exceeded;
   406     return _overhead_checker.gc_overhead_limit_exceeded();
   422   }
   407   }
   423   void set_gc_overhead_limit_exceeded(bool v) {
   408   void set_gc_overhead_limit_exceeded(bool v) {
   424     _gc_overhead_limit_exceeded = v;
   409     _overhead_checker.set_gc_overhead_limit_exceeded(v);
   425   }
   410   }
   426 
   411 
   427   // Tests conditions indicate the GC overhead limit is being approached.
       
   428   bool gc_overhead_limit_near() {
   412   bool gc_overhead_limit_near() {
   429     return gc_overhead_limit_count() >=
   413     return _overhead_checker.gc_overhead_limit_near();
   430         (AdaptiveSizePolicyGCTimeLimitThreshold - 1);
   414   }
   431   }
   415 
   432   uint gc_overhead_limit_count() { return _gc_overhead_limit_count; }
   416   void reset_gc_overhead_limit_count() {
   433   void reset_gc_overhead_limit_count() { _gc_overhead_limit_count = 0; }
   417     _overhead_checker.reset_gc_overhead_limit_count();
   434   void inc_gc_overhead_limit_count() { _gc_overhead_limit_count++; }
   418   }
   435   // accessors for flags recording the decisions to resize the
   419   // accessors for flags recording the decisions to resize the
   436   // generations to meet the pause goal.
   420   // generations to meet the pause goal.
   437 
   421 
   438   int change_young_gen_for_min_pauses() const {
   422   int change_young_gen_for_min_pauses() const {
   439     return _change_young_gen_for_min_pauses;
   423     return _change_young_gen_for_min_pauses;
   446   int decide_at_full_gc() { return _decide_at_full_gc; }
   430   int decide_at_full_gc() { return _decide_at_full_gc; }
   447   void set_decide_at_full_gc(int v) { _decide_at_full_gc = v; }
   431   void set_decide_at_full_gc(int v) { _decide_at_full_gc = v; }
   448 
   432 
   449   // Check the conditions for an out-of-memory due to excessive GC time.
   433   // Check the conditions for an out-of-memory due to excessive GC time.
   450   // Set _gc_overhead_limit_exceeded if all the conditions have been met.
   434   // Set _gc_overhead_limit_exceeded if all the conditions have been met.
   451   void check_gc_overhead_limit(size_t young_live,
   435   void check_gc_overhead_limit(size_t eden_live,
   452                                size_t eden_live,
       
   453                                size_t max_old_gen_size,
   436                                size_t max_old_gen_size,
   454                                size_t max_eden_size,
   437                                size_t max_eden_size,
   455                                bool   is_full_gc,
   438                                bool   is_full_gc,
   456                                GCCause::Cause gc_cause,
   439                                GCCause::Cause gc_cause,
   457                                SoftRefPolicy* soft_ref_policy);
   440                                SoftRefPolicy* soft_ref_policy);