< prev index next >

src/hotspot/share/gc/g1/g1Policy.hpp

Print this page
rev 59991 : imported patch 8210462-fix-remaining-mentions-of-im


  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_GC_G1_G1POLICY_HPP
  26 #define SHARE_GC_G1_G1POLICY_HPP
  27 
  28 #include "gc/g1/g1CollectorState.hpp"
  29 #include "gc/g1/g1GCPhaseTimes.hpp"
  30 #include "gc/g1/g1HeapRegionAttr.hpp"
  31 #include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp"
  32 #include "gc/g1/g1MMUTracker.hpp"
  33 #include "gc/g1/g1OldGenAllocationTracker.hpp"
  34 #include "gc/g1/g1RemSetTrackingPolicy.hpp"
  35 #include "gc/g1/g1Predictions.hpp"
  36 #include "gc/g1/g1YoungGenSizer.hpp"
  37 #include "gc/shared/gcCause.hpp"
  38 #include "utilities/pair.hpp"
  39 
  40 // A G1Policy makes policy decisions that determine the
  41 // characteristics of the collector.  Examples include:
  42 //   * choice of collection set.
  43 //   * when to collect.
  44 
  45 class HeapRegion;
  46 class G1CollectionSet;
  47 class G1CollectionSetCandidates;
  48 class G1CollectionSetChooser;
  49 class G1IHOPControl;
  50 class G1Analytics;
  51 class G1SurvivorRegions;


  89 
  90   double _reserve_factor;
  91   // This will be set when the heap is expanded
  92   // for the first time during initialization.
  93   uint   _reserve_regions;
  94 
  95   G1YoungGenSizer* _young_gen_sizer;
  96 
  97   uint _free_regions_at_end_of_collection;
  98 
  99   size_t _rs_length;
 100 
 101   size_t _rs_length_prediction;
 102 
 103   size_t _pending_cards_at_gc_start;
 104 
 105   // Tracking the allocation in the old generation between
 106   // two GCs.
 107   G1OldGenAllocationTracker _old_gen_alloc_tracker;
 108 
 109   G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed;
 110 
 111   bool should_update_surv_rate_group_predictors() {
 112     return collector_state()->in_young_only_phase() && !collector_state()->mark_or_rebuild_in_progress();
 113   }
 114 
 115   double logged_cards_processing_time() const;
 116 public:
 117   const G1Predictions& predictor() const { return _predictor; }
 118   const G1Analytics* analytics()   const { return const_cast<const G1Analytics*>(_analytics); }
 119 
 120   G1RemSetTrackingPolicy* remset_tracker() { return &_remset_tracker; }
 121 
 122   G1OldGenAllocationTracker* old_gen_alloc_tracker() { return &_old_gen_alloc_tracker; }
 123 
 124   void set_region_eden(HeapRegion* hr) {
 125     hr->set_eden();
 126     hr->install_surv_rate_group(_eden_surv_rate_group);
 127   }
 128 
 129   void set_region_survivor(HeapRegion* hr) {


 251   uint calc_max_old_cset_length() const;
 252 
 253   // Returns the given amount of reclaimable bytes (that represents
 254   // the amount of reclaimable space still to be collected) as a
 255   // percentage of the current heap capacity.
 256   double reclaimable_bytes_percent(size_t reclaimable_bytes) const;
 257 
 258   jlong collection_pause_end_millis() { return _collection_pause_end_millis; }
 259 
 260 private:
 261   void clear_collection_set_candidates();
 262   // Sets up marking if proper conditions are met.
 263   void maybe_start_marking();
 264 
 265   // The kind of STW pause.
 266   enum PauseKind {
 267     FullGC,
 268     YoungOnlyGC,
 269     MixedGC,
 270     LastYoungGC,
 271     InitialMarkGC,
 272     Cleanup,
 273     Remark
 274   };
 275 



 276   // Calculate PauseKind from internal state.
 277   PauseKind young_gc_pause_kind() const;
 278   // Record the given STW pause with the given start and end times (in s).
 279   void record_pause(PauseKind kind, double start, double end);
 280   // Indicate that we aborted marking before doing any mixed GCs.
 281   void abort_time_to_mixed_tracking();
 282 
 283   // Record and log stats before not-full collection.
 284   void record_concurrent_refinement_stats();
 285 
 286 public:
 287 
 288   G1Policy(STWGCTimer* gc_timer);
 289 
 290   virtual ~G1Policy();
 291 
 292   static G1Policy* create_policy(STWGCTimer* gc_timer_stw);
 293 
 294   G1CollectorState* collector_state() const;
 295 


 341 
 342   // Calculate the number of optional regions from the given collection set candidates,
 343   // the remaining time and the maximum number of these regions and return the number
 344   // of actually selected regions in num_optional_regions.
 345   void calculate_optional_collection_set_regions(G1CollectionSetCandidates* candidates,
 346                                                  uint const max_optional_regions,
 347                                                  double time_remaining_ms,
 348                                                  uint& num_optional_regions);
 349 
 350 private:
 351   // Set the state to start a concurrent marking cycle and clear
 352   // _initiate_conc_mark_if_possible because it has now been
 353   // acted on.
 354   void initiate_conc_mark();
 355 
 356 public:
 357   // This sets the initiate_conc_mark_if_possible() flag to start a
 358   // new cycle, as long as we are not already in one. It's best if it
 359   // is called during a safepoint when the test whether a cycle is in
 360   // progress or not is stable.
 361   bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause);
 362 
 363   // This is called at the very beginning of an evacuation pause (it
 364   // has to be the first thing that the pause does). If
 365   // initiate_conc_mark_if_possible() is true, and the concurrent
 366   // marking thread has completed its work during the previous cycle,
 367   // it will set in_initial_mark_gc() to so that the pause does
 368   // the initial-mark work and start a marking cycle.
 369   void decide_on_conc_mark_initiation();
 370 
 371   uint young_list_desired_length() const { return _young_list_desired_length; }
 372   size_t young_list_target_length() const { return _young_list_target_length; }
 373 
 374   bool should_allocate_mutator_region() const;
 375 
 376   bool can_expand_young_list() const;
 377 
 378   uint young_list_max_length() const {
 379     return _young_list_max_length;
 380   }
 381 
 382   bool use_adaptive_young_list_length() const;
 383 
 384   void transfer_survivors_to_cset(const G1SurvivorRegions* survivors);
 385 
 386 private:
 387   //
 388   // Survivor regions policy.




  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_GC_G1_G1POLICY_HPP
  26 #define SHARE_GC_G1_G1POLICY_HPP
  27 
  28 #include "gc/g1/g1CollectorState.hpp"
  29 #include "gc/g1/g1GCPhaseTimes.hpp"
  30 #include "gc/g1/g1HeapRegionAttr.hpp"
  31 #include "gc/g1/g1ConcurrentStartToMixedTimeTracker.hpp"
  32 #include "gc/g1/g1MMUTracker.hpp"
  33 #include "gc/g1/g1OldGenAllocationTracker.hpp"
  34 #include "gc/g1/g1RemSetTrackingPolicy.hpp"
  35 #include "gc/g1/g1Predictions.hpp"
  36 #include "gc/g1/g1YoungGenSizer.hpp"
  37 #include "gc/shared/gcCause.hpp"
  38 #include "utilities/pair.hpp"
  39 
  40 // A G1Policy makes policy decisions that determine the
  41 // characteristics of the collector.  Examples include:
  42 //   * choice of collection set.
  43 //   * when to collect.
  44 
  45 class HeapRegion;
  46 class G1CollectionSet;
  47 class G1CollectionSetCandidates;
  48 class G1CollectionSetChooser;
  49 class G1IHOPControl;
  50 class G1Analytics;
  51 class G1SurvivorRegions;


  89 
  90   double _reserve_factor;
  91   // This will be set when the heap is expanded
  92   // for the first time during initialization.
  93   uint   _reserve_regions;
  94 
  95   G1YoungGenSizer* _young_gen_sizer;
  96 
  97   uint _free_regions_at_end_of_collection;
  98 
  99   size_t _rs_length;
 100 
 101   size_t _rs_length_prediction;
 102 
 103   size_t _pending_cards_at_gc_start;
 104 
 105   // Tracking the allocation in the old generation between
 106   // two GCs.
 107   G1OldGenAllocationTracker _old_gen_alloc_tracker;
 108 
 109   G1ConcurrentStartToMixedTimeTracker _concurrent_start_to_mixed;
 110 
 111   bool should_update_surv_rate_group_predictors() {
 112     return collector_state()->in_young_only_phase() && !collector_state()->mark_or_rebuild_in_progress();
 113   }
 114 
 115   double logged_cards_processing_time() const;
 116 public:
 117   const G1Predictions& predictor() const { return _predictor; }
 118   const G1Analytics* analytics()   const { return const_cast<const G1Analytics*>(_analytics); }
 119 
 120   G1RemSetTrackingPolicy* remset_tracker() { return &_remset_tracker; }
 121 
 122   G1OldGenAllocationTracker* old_gen_alloc_tracker() { return &_old_gen_alloc_tracker; }
 123 
 124   void set_region_eden(HeapRegion* hr) {
 125     hr->set_eden();
 126     hr->install_surv_rate_group(_eden_surv_rate_group);
 127   }
 128 
 129   void set_region_survivor(HeapRegion* hr) {


 251   uint calc_max_old_cset_length() const;
 252 
 253   // Returns the given amount of reclaimable bytes (that represents
 254   // the amount of reclaimable space still to be collected) as a
 255   // percentage of the current heap capacity.
 256   double reclaimable_bytes_percent(size_t reclaimable_bytes) const;
 257 
 258   jlong collection_pause_end_millis() { return _collection_pause_end_millis; }
 259 
 260 private:
 261   void clear_collection_set_candidates();
 262   // Sets up marking if proper conditions are met.
 263   void maybe_start_marking();
 264 
 265   // The kind of STW pause.
 266   enum PauseKind {
 267     FullGC,
 268     YoungOnlyGC,
 269     MixedGC,
 270     LastYoungGC,
 271     ConcurrentStartGC,
 272     Cleanup,
 273     Remark
 274   };
 275 
 276   static bool is_young_only_pause(PauseKind kind);
 277   static bool is_last_young_pause(PauseKind kind);
 278   static bool is_concurrent_start_pause(PauseKind kind);
 279   // Calculate PauseKind from internal state.
 280   PauseKind young_gc_pause_kind() const;
 281   // Record the given STW pause with the given start and end times (in s).
 282   void record_pause(PauseKind kind, double start, double end);
 283   // Indicate that we aborted marking before doing any mixed GCs.
 284   void abort_time_to_mixed_tracking();
 285 
 286   // Record and log stats before not-full collection.
 287   void record_concurrent_refinement_stats();
 288 
 289 public:
 290 
 291   G1Policy(STWGCTimer* gc_timer);
 292 
 293   virtual ~G1Policy();
 294 
 295   static G1Policy* create_policy(STWGCTimer* gc_timer_stw);
 296 
 297   G1CollectorState* collector_state() const;
 298 


 344 
 345   // Calculate the number of optional regions from the given collection set candidates,
 346   // the remaining time and the maximum number of these regions and return the number
 347   // of actually selected regions in num_optional_regions.
 348   void calculate_optional_collection_set_regions(G1CollectionSetCandidates* candidates,
 349                                                  uint const max_optional_regions,
 350                                                  double time_remaining_ms,
 351                                                  uint& num_optional_regions);
 352 
 353 private:
 354   // Set the state to start a concurrent marking cycle and clear
 355   // _initiate_conc_mark_if_possible because it has now been
 356   // acted on.
 357   void initiate_conc_mark();
 358 
 359 public:
 360   // This sets the initiate_conc_mark_if_possible() flag to start a
 361   // new cycle, as long as we are not already in one. It's best if it
 362   // is called during a safepoint when the test whether a cycle is in
 363   // progress or not is stable.
 364   bool force_concurrent_start_if_outside_cycle(GCCause::Cause gc_cause);
 365 
 366   // This is called at the very beginning of an evacuation pause (it
 367   // has to be the first thing that the pause does). If
 368   // initiate_conc_mark_if_possible() is true, and the concurrent
 369   // marking thread has completed its work during the previous cycle,
 370   // it will set in_concurrent_start_gc() to so that the pause does
 371   // the concurrent start work and start a marking cycle.
 372   void decide_on_conc_mark_initiation();
 373 
 374   uint young_list_desired_length() const { return _young_list_desired_length; }
 375   size_t young_list_target_length() const { return _young_list_target_length; }
 376 
 377   bool should_allocate_mutator_region() const;
 378 
 379   bool can_expand_young_list() const;
 380 
 381   uint young_list_max_length() const {
 382     return _young_list_max_length;
 383   }
 384 
 385   bool use_adaptive_young_list_length() const;
 386 
 387   void transfer_survivors_to_cset(const G1SurvivorRegions* survivors);
 388 
 389 private:
 390   //
 391   // Survivor regions policy.


< prev index next >