hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
changeset 2344 f2e09ba7ceab
parent 2154 72a9b7284ccf
child 2881 74a1337e4acc
equal deleted inserted replaced
2261:a93be5632119 2344:f2e09ba7ceab
    45   NumberSeq* get_##name##_seq() {                                             \
    45   NumberSeq* get_##name##_seq() {                                             \
    46     return &_all_##name##_times_ms;                                           \
    46     return &_all_##name##_times_ms;                                           \
    47   }
    47   }
    48 
    48 
    49 class MainBodySummary;
    49 class MainBodySummary;
    50 class PopPreambleSummary;
       
    51 
    50 
    52 class PauseSummary: public CHeapObj {
    51 class PauseSummary: public CHeapObj {
    53   define_num_seq(total)
    52   define_num_seq(total)
    54     define_num_seq(other)
    53     define_num_seq(other)
    55 
    54 
    56 public:
    55 public:
    57   virtual MainBodySummary*    main_body_summary()    { return NULL; }
    56   virtual MainBodySummary*    main_body_summary()    { return NULL; }
    58   virtual PopPreambleSummary* pop_preamble_summary() { return NULL; }
       
    59 };
    57 };
    60 
    58 
    61 class MainBodySummary: public CHeapObj {
    59 class MainBodySummary: public CHeapObj {
    62   define_num_seq(satb_drain) // optional
    60   define_num_seq(satb_drain) // optional
    63   define_num_seq(parallel) // parallel only
    61   define_num_seq(parallel) // parallel only
    73     define_num_seq(parallel_other) // parallel only
    71     define_num_seq(parallel_other) // parallel only
    74   define_num_seq(mark_closure)
    72   define_num_seq(mark_closure)
    75   define_num_seq(clear_ct)  // parallel only
    73   define_num_seq(clear_ct)  // parallel only
    76 };
    74 };
    77 
    75 
    78 class PopPreambleSummary: public CHeapObj {
    76 class Summary: public PauseSummary,
    79   define_num_seq(pop_preamble)
    77                public MainBodySummary {
    80     define_num_seq(pop_update_rs)
       
    81     define_num_seq(pop_scan_rs)
       
    82     define_num_seq(pop_closure_app)
       
    83     define_num_seq(pop_evacuation)
       
    84     define_num_seq(pop_other)
       
    85 };
       
    86 
       
    87 class NonPopSummary: public PauseSummary,
       
    88                      public MainBodySummary {
       
    89 public:
    78 public:
    90   virtual MainBodySummary*    main_body_summary()    { return this; }
    79   virtual MainBodySummary*    main_body_summary()    { return this; }
    91 };
    80 };
    92 
    81 
    93 class PopSummary: public PauseSummary,
    82 class AbandonedSummary: public PauseSummary {
    94                   public MainBodySummary,
       
    95                   public PopPreambleSummary {
       
    96 public:
       
    97   virtual MainBodySummary*    main_body_summary()    { return this; }
       
    98   virtual PopPreambleSummary* pop_preamble_summary() { return this; }
       
    99 };
       
   100 
       
   101 class NonPopAbandonedSummary: public PauseSummary {
       
   102 };
       
   103 
       
   104 class PopAbandonedSummary: public PauseSummary,
       
   105                            public PopPreambleSummary {
       
   106 public:
       
   107   virtual PopPreambleSummary* pop_preamble_summary() { return this; }
       
   108 };
    83 };
   109 
    84 
   110 class G1CollectorPolicy: public CollectorPolicy {
    85 class G1CollectorPolicy: public CollectorPolicy {
   111 protected:
    86 protected:
   112   // The number of pauses during the execution.
    87   // The number of pauses during the execution.
   144   size_t _prev_collection_pause_used_at_end_bytes;
   119   size_t _prev_collection_pause_used_at_end_bytes;
   145   double _cur_collection_par_time_ms;
   120   double _cur_collection_par_time_ms;
   146   double _cur_satb_drain_time_ms;
   121   double _cur_satb_drain_time_ms;
   147   double _cur_clear_ct_time_ms;
   122   double _cur_clear_ct_time_ms;
   148   bool   _satb_drain_time_set;
   123   bool   _satb_drain_time_set;
   149   double _cur_popular_preamble_start_ms;
       
   150   double _cur_popular_preamble_time_ms;
       
   151   double _cur_popular_compute_rc_time_ms;
       
   152   double _cur_popular_evac_time_ms;
       
   153 
   124 
   154   double _cur_CH_strong_roots_end_sec;
   125   double _cur_CH_strong_roots_end_sec;
   155   double _cur_CH_strong_roots_dur_ms;
   126   double _cur_CH_strong_roots_dur_ms;
   156   double _cur_G1_strong_roots_end_sec;
   127   double _cur_G1_strong_roots_end_sec;
   157   double _cur_G1_strong_roots_dur_ms;
   128   double _cur_G1_strong_roots_dur_ms;
   171 
   142 
   172   TruncatedSeq* _concurrent_mark_init_times_ms;
   143   TruncatedSeq* _concurrent_mark_init_times_ms;
   173   TruncatedSeq* _concurrent_mark_remark_times_ms;
   144   TruncatedSeq* _concurrent_mark_remark_times_ms;
   174   TruncatedSeq* _concurrent_mark_cleanup_times_ms;
   145   TruncatedSeq* _concurrent_mark_cleanup_times_ms;
   175 
   146 
   176   NonPopSummary*           _non_pop_summary;
   147   Summary*           _summary;
   177   PopSummary*              _pop_summary;
   148   AbandonedSummary*  _abandoned_summary;
   178   NonPopAbandonedSummary*  _non_pop_abandoned_summary;
       
   179   PopAbandonedSummary*     _pop_abandoned_summary;
       
   180 
   149 
   181   NumberSeq* _all_pause_times_ms;
   150   NumberSeq* _all_pause_times_ms;
   182   NumberSeq* _all_full_gc_times_ms;
   151   NumberSeq* _all_full_gc_times_ms;
   183   double _stop_world_start;
   152   double _stop_world_start;
   184   NumberSeq* _all_stop_world_times_ms;
   153   NumberSeq* _all_stop_world_times_ms;
   208   double* _par_last_scan_rs_times_ms;
   177   double* _par_last_scan_rs_times_ms;
   209   double* _par_last_scan_new_refs_times_ms;
   178   double* _par_last_scan_new_refs_times_ms;
   210   double* _par_last_obj_copy_times_ms;
   179   double* _par_last_obj_copy_times_ms;
   211   double* _par_last_termination_times_ms;
   180   double* _par_last_termination_times_ms;
   212 
   181 
   213   // there are two pases during popular pauses, so we need to store
       
   214   // somewhere the results of the first pass
       
   215   double* _pop_par_last_update_rs_start_times_ms;
       
   216   double* _pop_par_last_update_rs_times_ms;
       
   217   double* _pop_par_last_update_rs_processed_buffers;
       
   218   double* _pop_par_last_scan_rs_start_times_ms;
       
   219   double* _pop_par_last_scan_rs_times_ms;
       
   220   double* _pop_par_last_closure_app_times_ms;
       
   221 
       
   222   double _pop_compute_rc_start;
       
   223   double _pop_evac_start;
       
   224 
       
   225   // indicates that we are in young GC mode
   182   // indicates that we are in young GC mode
   226   bool _in_young_gc_mode;
   183   bool _in_young_gc_mode;
   227 
   184 
   228   // indicates whether we are in full young or partially young GC mode
   185   // indicates whether we are in full young or partially young GC mode
   229   bool _full_young_gcs;
   186   bool _full_young_gcs;
   632   void check_other_times(int level,
   589   void check_other_times(int level,
   633                          NumberSeq* other_times_ms,
   590                          NumberSeq* other_times_ms,
   634                          NumberSeq* calc_other_times_ms) const;
   591                          NumberSeq* calc_other_times_ms) const;
   635 
   592 
   636   void print_summary (PauseSummary* stats) const;
   593   void print_summary (PauseSummary* stats) const;
   637   void print_abandoned_summary(PauseSummary* non_pop_summary,
   594   void print_abandoned_summary(PauseSummary* summary) const;
   638                                PauseSummary* pop_summary) const;
       
   639 
   595 
   640   void print_summary (int level, const char* str, NumberSeq* seq) const;
   596   void print_summary (int level, const char* str, NumberSeq* seq) const;
   641   void print_summary_sd (int level, const char* str, NumberSeq* seq) const;
   597   void print_summary_sd (int level, const char* str, NumberSeq* seq) const;
   642 
   598 
   643   double avg_value (double* data);
   599   double avg_value (double* data);
   854   virtual void record_stop_world_start();
   810   virtual void record_stop_world_start();
   855 
   811 
   856   virtual void record_collection_pause_start(double start_time_sec,
   812   virtual void record_collection_pause_start(double start_time_sec,
   857                                              size_t start_used);
   813                                              size_t start_used);
   858 
   814 
   859   virtual void record_popular_pause_preamble_start();
       
   860   virtual void record_popular_pause_preamble_end();
       
   861 
       
   862   // Must currently be called while the world is stopped.
   815   // Must currently be called while the world is stopped.
   863   virtual void record_concurrent_mark_init_start();
   816   virtual void record_concurrent_mark_init_start();
   864   virtual void record_concurrent_mark_init_end();
   817   virtual void record_concurrent_mark_init_end();
   865   void record_concurrent_mark_init_end_pre(double
   818   void record_concurrent_mark_init_end_pre(double
   866                                            mark_init_elapsed_time_ms);
   819                                            mark_init_elapsed_time_ms);
   879   virtual void record_concurrent_pause_end();
   832   virtual void record_concurrent_pause_end();
   880 
   833 
   881   virtual void record_collection_pause_end_CH_strong_roots();
   834   virtual void record_collection_pause_end_CH_strong_roots();
   882   virtual void record_collection_pause_end_G1_strong_roots();
   835   virtual void record_collection_pause_end_G1_strong_roots();
   883 
   836 
   884   virtual void record_collection_pause_end(bool popular, bool abandoned);
   837   virtual void record_collection_pause_end(bool abandoned);
   885 
   838 
   886   // Record the fact that a full collection occurred.
   839   // Record the fact that a full collection occurred.
   887   virtual void record_full_collection_start();
   840   virtual void record_full_collection_start();
   888   virtual void record_full_collection_end();
   841   virtual void record_full_collection_end();
   889 
   842 
   988     double ms = os::elapsedTime() * 1000.0 - _cur_aux_start_times_ms[i];
   941     double ms = os::elapsedTime() * 1000.0 - _cur_aux_start_times_ms[i];
   989     _cur_aux_times_set[i] = true;
   942     _cur_aux_times_set[i] = true;
   990     _cur_aux_times_ms[i] += ms;
   943     _cur_aux_times_ms[i] += ms;
   991   }
   944   }
   992 
   945 
   993   void record_pop_compute_rc_start();
       
   994   void record_pop_compute_rc_end();
       
   995 
       
   996   void record_pop_evac_start();
       
   997   void record_pop_evac_end();
       
   998 
       
   999   // Record the fact that "bytes" bytes allocated in a region.
   946   // Record the fact that "bytes" bytes allocated in a region.
  1000   void record_before_bytes(size_t bytes);
   947   void record_before_bytes(size_t bytes);
  1001   void record_after_bytes(size_t bytes);
   948   void record_after_bytes(size_t bytes);
  1002 
   949 
  1003   // Returns "true" if this is a good time to do a collection pause.
   950   // Returns "true" if this is a good time to do a collection pause.
  1006   virtual bool should_do_collection_pause(size_t word_size) = 0;
   953   virtual bool should_do_collection_pause(size_t word_size) = 0;
  1007 
   954 
  1008   // Choose a new collection set.  Marks the chosen regions as being
   955   // Choose a new collection set.  Marks the chosen regions as being
  1009   // "in_collection_set", and links them together.  The head and number of
   956   // "in_collection_set", and links them together.  The head and number of
  1010   // the collection set are available via access methods.
   957   // the collection set are available via access methods.
  1011   // If "pop_region" is non-NULL, it is a popular region that has already
   958   virtual void choose_collection_set() = 0;
  1012   // been added to the collection set.
       
  1013   virtual void choose_collection_set(HeapRegion* pop_region = NULL) = 0;
       
  1014 
   959 
  1015   void clear_collection_set() { _collection_set = NULL; }
   960   void clear_collection_set() { _collection_set = NULL; }
  1016 
   961 
  1017   // The head of the list (via "next_in_collection_set()") representing the
   962   // The head of the list (via "next_in_collection_set()") representing the
  1018   // current collection set.
   963   // current collection set.
  1019   HeapRegion* collection_set() { return _collection_set; }
   964   HeapRegion* collection_set() { return _collection_set; }
  1020 
       
  1021   // Sets the collection set to the given single region.
       
  1022   virtual void set_single_region_collection_set(HeapRegion* hr);
       
  1023 
   965 
  1024   // The number of elements in the current collection set.
   966   // The number of elements in the current collection set.
  1025   size_t collection_set_size() { return _collection_set_size; }
   967   size_t collection_set_size() { return _collection_set_size; }
  1026 
   968 
  1027   // Add "hr" to the CS.
   969   // Add "hr" to the CS.
  1201 class G1CollectorPolicy_BestRegionsFirst: public G1CollectorPolicy {
  1143 class G1CollectorPolicy_BestRegionsFirst: public G1CollectorPolicy {
  1202   CollectionSetChooser* _collectionSetChooser;
  1144   CollectionSetChooser* _collectionSetChooser;
  1203   // If the estimated is less then desirable, resize if possible.
  1145   // If the estimated is less then desirable, resize if possible.
  1204   void expand_if_possible(size_t numRegions);
  1146   void expand_if_possible(size_t numRegions);
  1205 
  1147 
  1206   virtual void choose_collection_set(HeapRegion* pop_region = NULL);
  1148   virtual void choose_collection_set();
  1207   virtual void record_collection_pause_start(double start_time_sec,
  1149   virtual void record_collection_pause_start(double start_time_sec,
  1208                                              size_t start_used);
  1150                                              size_t start_used);
  1209   virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes,
  1151   virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes,
  1210                                                   size_t max_live_bytes);
  1152                                                   size_t max_live_bytes);
  1211   virtual void record_full_collection_end();
  1153   virtual void record_full_collection_end();
  1212 
  1154 
  1213 public:
  1155 public:
  1214   G1CollectorPolicy_BestRegionsFirst() {
  1156   G1CollectorPolicy_BestRegionsFirst() {
  1215     _collectionSetChooser = new CollectionSetChooser();
  1157     _collectionSetChooser = new CollectionSetChooser();
  1216   }
  1158   }
  1217   void record_collection_pause_end(bool popular, bool abandoned);
  1159   void record_collection_pause_end(bool abandoned);
  1218   bool should_do_collection_pause(size_t word_size);
  1160   bool should_do_collection_pause(size_t word_size);
  1219   virtual void set_single_region_collection_set(HeapRegion* hr);
       
  1220   // This is not needed any more, after the CSet choosing code was
  1161   // This is not needed any more, after the CSet choosing code was
  1221   // changed to use the pause prediction work. But let's leave the
  1162   // changed to use the pause prediction work. But let's leave the
  1222   // hook in just in case.
  1163   // hook in just in case.
  1223   void note_change_in_marked_bytes(HeapRegion* r) { }
  1164   void note_change_in_marked_bytes(HeapRegion* r) { }
  1224 #ifndef PRODUCT
  1165 #ifndef PRODUCT