< prev index next >

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

Print this page
rev 8910 : full patch for jfr
   1 /*
   2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  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/g1Allocator.hpp"
  30 #include "gc_implementation/g1/g1MMUTracker.hpp"

  31 #include "memory/collectorPolicy.hpp"
  32 
  33 // A G1CollectorPolicy makes policy decisions that determine the
  34 // characteristics of the collector.  Examples include:
  35 //   * choice of collection set.
  36 //   * when to collect.
  37 
  38 class HeapRegion;
  39 class CollectionSetChooser;
  40 class G1GCPhaseTimes;
  41 
  42 // TraceGen0Time collects data on _both_ young and mixed evacuation pauses
  43 // (the latter may contain non-young regions - i.e. regions that are
  44 // technically in Gen1) while TraceGen1Time collects data about full GCs.
  45 class TraceGen0TimeData : public CHeapObj<mtGC> {
  46  private:
  47   unsigned  _young_pause_num;
  48   unsigned  _mixed_pause_num;
  49 
  50   NumberSeq _all_stop_world_times_ms;


 144 public:
 145   G1YoungGenSizer();
 146   // Calculate the maximum length of the young gen given the number of regions
 147   // depending on the sizing algorithm.
 148   uint max_young_length(uint number_of_heap_regions);
 149 
 150   void heap_size_changed(uint new_number_of_heap_regions);
 151   uint min_desired_young_length() {
 152     return _min_desired_young_length;
 153   }
 154   uint max_desired_young_length() {
 155     return _max_desired_young_length;
 156   }
 157   bool adaptive_young_list_length() {
 158     return _adaptive_size;
 159   }
 160 };
 161 
 162 class G1CollectorPolicy: public CollectorPolicy {
 163 private:


 164   // either equal to the number of parallel threads, if ParallelGCThreads
 165   // has been set, or 1 otherwise
 166   int _parallel_gc_threads;
 167 
 168   // The number of GC threads currently active.
 169   uintx _no_of_gc_threads;
 170 
 171   enum SomePrivateConstants {
 172     NumPrevPausesForHeuristics = 10
 173   };
 174 
 175   G1MMUTracker* _mmu_tracker;

 176 
 177   void initialize_alignments();
 178   void initialize_flags();
 179 
 180   CollectionSetChooser* _collectionSetChooser;
 181 
 182   double _full_collection_start_sec;
 183   uint   _cur_collection_pause_used_regions_at_start;
 184 
 185   // These exclude marking times.
 186   TruncatedSeq* _recent_gc_times_ms;
 187 
 188   TruncatedSeq* _concurrent_mark_remark_times_ms;
 189   TruncatedSeq* _concurrent_mark_cleanup_times_ms;
 190 
 191   TraceGen0TimeData _trace_gen0_time_data;
 192   TraceGen1TimeData _trace_gen1_time_data;
 193 
 194   double _stop_world_start;
 195 


 619   // given free space (expressed by base_free_regions).  It is used by
 620   // calculate_young_list_target_length().
 621   bool predict_will_fit(uint young_length, double base_time_ms,
 622                         uint base_free_regions, double target_pause_time_ms);
 623 
 624   // Calculate the minimum number of old regions we'll add to the CSet
 625   // during a mixed GC.
 626   uint calc_min_old_cset_length();
 627 
 628   // Calculate the maximum number of old regions we'll add to the CSet
 629   // during a mixed GC.
 630   uint calc_max_old_cset_length();
 631 
 632   // Returns the given amount of uncollected reclaimable space
 633   // as a percentage of the current heap capacity.
 634   double reclaimable_bytes_perc(size_t reclaimable_bytes);
 635 
 636 public:
 637 
 638   G1CollectorPolicy();

 639 
 640   virtual G1CollectorPolicy* as_g1_policy() { return this; }
 641 
 642   virtual CollectorPolicy::Name kind() {
 643     return CollectorPolicy::G1CollectorPolicyKind;
 644   }
 645 
 646   G1GCPhaseTimes* phase_times() const { return _phase_times; }
 647 
 648   // Check the current value of the young list RSet lengths and
 649   // compare it against the last prediction. If the current value is
 650   // higher, recalculate the young list target length prediction.
 651   void revise_young_list_target_length_if_necessary();
 652 
 653   // This should be called after the heap is resized.
 654   void record_new_heap_size(uint new_number_of_regions);
 655 
 656   void init();
 657 
 658   // Create jstat counters for the policy.


   1 /*
   2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  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/g1Allocator.hpp"
  30 #include "gc_implementation/g1/g1MMUTracker.hpp"
  31 #include "gc_implementation/g1/g1IHOPControl.hpp"
  32 #include "memory/collectorPolicy.hpp"
  33 
  34 // A G1CollectorPolicy makes policy decisions that determine the
  35 // characteristics of the collector.  Examples include:
  36 //   * choice of collection set.
  37 //   * when to collect.
  38 
  39 class HeapRegion;
  40 class CollectionSetChooser;
  41 class G1GCPhaseTimes;
  42 
  43 // TraceGen0Time collects data on _both_ young and mixed evacuation pauses
  44 // (the latter may contain non-young regions - i.e. regions that are
  45 // technically in Gen1) while TraceGen1Time collects data about full GCs.
  46 class TraceGen0TimeData : public CHeapObj<mtGC> {
  47  private:
  48   unsigned  _young_pause_num;
  49   unsigned  _mixed_pause_num;
  50 
  51   NumberSeq _all_stop_world_times_ms;


 145 public:
 146   G1YoungGenSizer();
 147   // Calculate the maximum length of the young gen given the number of regions
 148   // depending on the sizing algorithm.
 149   uint max_young_length(uint number_of_heap_regions);
 150 
 151   void heap_size_changed(uint new_number_of_heap_regions);
 152   uint min_desired_young_length() {
 153     return _min_desired_young_length;
 154   }
 155   uint max_desired_young_length() {
 156     return _max_desired_young_length;
 157   }
 158   bool adaptive_young_list_length() {
 159     return _adaptive_size;
 160   }
 161 };
 162 
 163 class G1CollectorPolicy: public CollectorPolicy {
 164 private:
 165   static G1IHOPControl* create_ihop_control();
 166 
 167   // either equal to the number of parallel threads, if ParallelGCThreads
 168   // has been set, or 1 otherwise
 169   int _parallel_gc_threads;
 170 
 171   // The number of GC threads currently active.
 172   uintx _no_of_gc_threads;
 173 
 174   enum SomePrivateConstants {
 175     NumPrevPausesForHeuristics = 10
 176   };
 177 
 178   G1MMUTracker* _mmu_tracker;
 179   G1IHOPControl* _ihop_control;
 180 
 181   void initialize_alignments();
 182   void initialize_flags();
 183 
 184   CollectionSetChooser* _collectionSetChooser;
 185 
 186   double _full_collection_start_sec;
 187   uint   _cur_collection_pause_used_regions_at_start;
 188 
 189   // These exclude marking times.
 190   TruncatedSeq* _recent_gc_times_ms;
 191 
 192   TruncatedSeq* _concurrent_mark_remark_times_ms;
 193   TruncatedSeq* _concurrent_mark_cleanup_times_ms;
 194 
 195   TraceGen0TimeData _trace_gen0_time_data;
 196   TraceGen1TimeData _trace_gen1_time_data;
 197 
 198   double _stop_world_start;
 199 


 623   // given free space (expressed by base_free_regions).  It is used by
 624   // calculate_young_list_target_length().
 625   bool predict_will_fit(uint young_length, double base_time_ms,
 626                         uint base_free_regions, double target_pause_time_ms);
 627 
 628   // Calculate the minimum number of old regions we'll add to the CSet
 629   // during a mixed GC.
 630   uint calc_min_old_cset_length();
 631 
 632   // Calculate the maximum number of old regions we'll add to the CSet
 633   // during a mixed GC.
 634   uint calc_max_old_cset_length();
 635 
 636   // Returns the given amount of uncollected reclaimable space
 637   // as a percentage of the current heap capacity.
 638   double reclaimable_bytes_perc(size_t reclaimable_bytes);
 639 
 640 public:
 641 
 642   G1CollectorPolicy();
 643   virtual ~G1CollectorPolicy();
 644 
 645   virtual G1CollectorPolicy* as_g1_policy() { return this; }
 646 
 647   virtual CollectorPolicy::Name kind() {
 648     return CollectorPolicy::G1CollectorPolicyKind;
 649   }
 650 
 651   G1GCPhaseTimes* phase_times() const { return _phase_times; }
 652 
 653   // Check the current value of the young list RSet lengths and
 654   // compare it against the last prediction. If the current value is
 655   // higher, recalculate the young list target length prediction.
 656   void revise_young_list_target_length_if_necessary();
 657 
 658   // This should be called after the heap is resized.
 659   void record_new_heap_size(uint new_number_of_regions);
 660 
 661   void init();
 662 
 663   // Create jstat counters for the policy.


< prev index next >