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

changeset 1829
1316cec51b4d
parent 1794
23b1b27ac76c
child 1907
c18cbe5936b8
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Mon Apr 19 05:40:21 2010 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Thu Apr 22 10:02:38 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 2001-2010 Sun Microsystems, Inc.  All Rights Reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -61,7 +61,6 @@
    1.11    define_num_seq(parallel) // parallel only
    1.12      define_num_seq(ext_root_scan)
    1.13      define_num_seq(mark_stack_scan)
    1.14 -    define_num_seq(scan_only)
    1.15      define_num_seq(update_rs)
    1.16      define_num_seq(scan_rs)
    1.17      define_num_seq(scan_new_refs) // Only for temp use; added to
    1.18 @@ -174,8 +173,6 @@
    1.19  
    1.20    double* _par_last_ext_root_scan_times_ms;
    1.21    double* _par_last_mark_stack_scan_times_ms;
    1.22 -  double* _par_last_scan_only_times_ms;
    1.23 -  double* _par_last_scan_only_regions_scanned;
    1.24    double* _par_last_update_rs_start_times_ms;
    1.25    double* _par_last_update_rs_times_ms;
    1.26    double* _par_last_update_rs_processed_buffers;
    1.27 @@ -196,7 +193,6 @@
    1.28    bool _adaptive_young_list_length;
    1.29    size_t _young_list_min_length;
    1.30    size_t _young_list_target_length;
    1.31 -  size_t _young_list_so_prefix_length;
    1.32    size_t _young_list_fixed_length;
    1.33  
    1.34    size_t _young_cset_length;
    1.35 @@ -234,7 +230,6 @@
    1.36    TruncatedSeq* _pending_card_diff_seq;
    1.37    TruncatedSeq* _rs_length_diff_seq;
    1.38    TruncatedSeq* _cost_per_card_ms_seq;
    1.39 -  TruncatedSeq* _cost_per_scan_only_region_ms_seq;
    1.40    TruncatedSeq* _fully_young_cards_per_entry_ratio_seq;
    1.41    TruncatedSeq* _partially_young_cards_per_entry_ratio_seq;
    1.42    TruncatedSeq* _cost_per_entry_ms_seq;
    1.43 @@ -249,19 +244,16 @@
    1.44    TruncatedSeq* _rs_lengths_seq;
    1.45  
    1.46    TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
    1.47 -  TruncatedSeq* _cost_per_scan_only_region_ms_during_cm_seq;
    1.48  
    1.49    TruncatedSeq* _young_gc_eff_seq;
    1.50  
    1.51    TruncatedSeq* _max_conc_overhead_seq;
    1.52  
    1.53    size_t _recorded_young_regions;
    1.54 -  size_t _recorded_scan_only_regions;
    1.55    size_t _recorded_non_young_regions;
    1.56    size_t _recorded_region_num;
    1.57  
    1.58    size_t _free_regions_at_end_of_collection;
    1.59 -  size_t _scan_only_regions_at_end_of_collection;
    1.60  
    1.61    size_t _recorded_rs_lengths;
    1.62    size_t _max_rs_lengths;
    1.63 @@ -277,7 +269,6 @@
    1.64    double _predicted_survival_ratio;
    1.65    double _predicted_rs_update_time_ms;
    1.66    double _predicted_rs_scan_time_ms;
    1.67 -  double _predicted_scan_only_scan_time_ms;
    1.68    double _predicted_object_copy_time_ms;
    1.69    double _predicted_constant_other_time_ms;
    1.70    double _predicted_young_other_time_ms;
    1.71 @@ -344,8 +335,6 @@
    1.72    bool verify_young_ages();
    1.73  #endif // PRODUCT
    1.74  
    1.75 -  void tag_scan_only(size_t short_lived_scan_only_length);
    1.76 -
    1.77    double get_new_prediction(TruncatedSeq* seq) {
    1.78      return MAX2(seq->davg() + sigma() * seq->dsd(),
    1.79                  seq->davg() * confidence_factor(seq->num()));
    1.80 @@ -431,23 +420,6 @@
    1.81          get_new_prediction(_partially_young_cost_per_entry_ms_seq);
    1.82    }
    1.83  
    1.84 -  double predict_scan_only_time_ms_during_cm(size_t scan_only_region_num) {
    1.85 -    if (_cost_per_scan_only_region_ms_during_cm_seq->num() < 3)
    1.86 -      return 1.5 * (double) scan_only_region_num *
    1.87 -        get_new_prediction(_cost_per_scan_only_region_ms_seq);
    1.88 -    else
    1.89 -      return (double) scan_only_region_num *
    1.90 -        get_new_prediction(_cost_per_scan_only_region_ms_during_cm_seq);
    1.91 -  }
    1.92 -
    1.93 -  double predict_scan_only_time_ms(size_t scan_only_region_num) {
    1.94 -    if (_in_marking_window_im)
    1.95 -      return predict_scan_only_time_ms_during_cm(scan_only_region_num);
    1.96 -    else
    1.97 -      return (double) scan_only_region_num *
    1.98 -        get_new_prediction(_cost_per_scan_only_region_ms_seq);
    1.99 -  }
   1.100 -
   1.101    double predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) {
   1.102      if (_cost_per_byte_ms_during_cm_seq->num() < 3)
   1.103        return 1.1 * (double) bytes_to_copy *
   1.104 @@ -490,24 +462,21 @@
   1.105    size_t predict_bytes_to_copy(HeapRegion* hr);
   1.106    double predict_region_elapsed_time_ms(HeapRegion* hr, bool young);
   1.107  
   1.108 -  // for use by: calculate_optimal_so_length(length)
   1.109 -  void predict_gc_eff(size_t young_region_num,
   1.110 -                      size_t so_length,
   1.111 -                      double base_time_ms,
   1.112 -                      double *gc_eff,
   1.113 -                      double *pause_time_ms);
   1.114 -
   1.115 -  // for use by: calculate_young_list_target_config(rs_length)
   1.116 -  bool predict_gc_eff(size_t young_region_num,
   1.117 -                      size_t so_length,
   1.118 -                      double base_time_with_so_ms,
   1.119 -                      size_t init_free_regions,
   1.120 -                      double target_pause_time_ms,
   1.121 -                      double* gc_eff);
   1.122 +    // for use by: calculate_young_list_target_length(rs_length)
   1.123 +  bool predict_will_fit(size_t young_region_num,
   1.124 +                        double base_time_ms,
   1.125 +                        size_t init_free_regions,
   1.126 +                        double target_pause_time_ms);
   1.127  
   1.128    void start_recording_regions();
   1.129 -  void record_cset_region(HeapRegion* hr, bool young);
   1.130 -  void record_scan_only_regions(size_t scan_only_length);
   1.131 +  void record_cset_region_info(HeapRegion* hr, bool young);
   1.132 +  void record_non_young_cset_region(HeapRegion* hr);
   1.133 +
   1.134 +  void set_recorded_young_regions(size_t n_regions);
   1.135 +  void set_recorded_young_bytes(size_t bytes);
   1.136 +  void set_recorded_rs_lengths(size_t rs_lengths);
   1.137 +  void set_predicted_bytes_to_copy(size_t bytes);
   1.138 +
   1.139    void end_recording_regions();
   1.140  
   1.141    void record_vtime_diff_ms(double vtime_diff_ms) {
   1.142 @@ -638,11 +607,74 @@
   1.143    void update_recent_gc_times(double end_time_sec, double elapsed_ms);
   1.144  
   1.145    // The head of the list (via "next_in_collection_set()") representing the
   1.146 -  // current collection set.
   1.147 +  // current collection set. Set from the incrementally built collection
   1.148 +  // set at the start of the pause.
   1.149    HeapRegion* _collection_set;
   1.150 +
   1.151 +  // The number of regions in the collection set. Set from the incrementally
   1.152 +  // built collection set at the start of an evacuation pause.
   1.153    size_t _collection_set_size;
   1.154 +
   1.155 +  // The number of bytes in the collection set before the pause. Set from
   1.156 +  // the incrementally built collection set at the start of an evacuation
   1.157 +  // pause.
   1.158    size_t _collection_set_bytes_used_before;
   1.159  
   1.160 +  // The associated information that is maintained while the incremental
   1.161 +  // collection set is being built with young regions. Used to populate
   1.162 +  // the recorded info for the evacuation pause.
   1.163 +
   1.164 +  enum CSetBuildType {
   1.165 +    Active,             // We are actively building the collection set
   1.166 +    Inactive            // We are not actively building the collection set
   1.167 +  };
   1.168 +
   1.169 +  CSetBuildType _inc_cset_build_state;
   1.170 +
   1.171 +  // The head of the incrementally built collection set.
   1.172 +  HeapRegion* _inc_cset_head;
   1.173 +
   1.174 +  // The tail of the incrementally built collection set.
   1.175 +  HeapRegion* _inc_cset_tail;
   1.176 +
   1.177 +  // The number of regions in the incrementally built collection set.
   1.178 +  // Used to set _collection_set_size at the start of an evacuation
   1.179 +  // pause.
   1.180 +  size_t _inc_cset_size;
   1.181 +
   1.182 +  // Used as the index in the surving young words structure
   1.183 +  // which tracks the amount of space, for each young region,
   1.184 +  // that survives the pause.
   1.185 +  size_t _inc_cset_young_index;
   1.186 +
   1.187 +  // The number of bytes in the incrementally built collection set.
   1.188 +  // Used to set _collection_set_bytes_used_before at the start of
   1.189 +  // an evacuation pause.
   1.190 +  size_t _inc_cset_bytes_used_before;
   1.191 +
   1.192 +  // Used to record the highest end of heap region in collection set
   1.193 +  HeapWord* _inc_cset_max_finger;
   1.194 +
   1.195 +  // The number of recorded used bytes in the young regions
   1.196 +  // of the collection set. This is the sum of the used() bytes
   1.197 +  // of retired young regions in the collection set.
   1.198 +  size_t _inc_cset_recorded_young_bytes;
   1.199 +
   1.200 +  // The RSet lengths recorded for regions in the collection set
   1.201 +  // (updated by the periodic sampling of the regions in the
   1.202 +  // young list/collection set).
   1.203 +  size_t _inc_cset_recorded_rs_lengths;
   1.204 +
   1.205 +  // The predicted elapsed time it will take to collect the regions
   1.206 +  // in the collection set (updated by the periodic sampling of the
   1.207 +  // regions in the young list/collection set).
   1.208 +  double _inc_cset_predicted_elapsed_time_ms;
   1.209 +
   1.210 +  // The predicted bytes to copy for the regions in the collection
   1.211 +  // set (updated by the periodic sampling of the regions in the
   1.212 +  // young list/collection set).
   1.213 +  size_t _inc_cset_predicted_bytes_to_copy;
   1.214 +
   1.215    // Info about marking.
   1.216    int _n_marks; // Sticky at 2, so we know when we've done at least 2.
   1.217  
   1.218 @@ -761,9 +793,8 @@
   1.219    double _mark_closure_time_ms;
   1.220  
   1.221    void   calculate_young_list_min_length();
   1.222 -  void   calculate_young_list_target_config();
   1.223 -  void   calculate_young_list_target_config(size_t rs_lengths);
   1.224 -  size_t calculate_optimal_so_length(size_t young_list_length);
   1.225 +  void   calculate_young_list_target_length();
   1.226 +  void   calculate_young_list_target_length(size_t rs_lengths);
   1.227  
   1.228  public:
   1.229  
   1.230 @@ -868,11 +899,6 @@
   1.231      _par_last_mark_stack_scan_times_ms[worker_i] = ms;
   1.232    }
   1.233  
   1.234 -  void record_scan_only_time(int worker_i, double ms, int n) {
   1.235 -    _par_last_scan_only_times_ms[worker_i] = ms;
   1.236 -    _par_last_scan_only_regions_scanned[worker_i] = (double) n;
   1.237 -  }
   1.238 -
   1.239    void record_satb_drain_time(double ms) {
   1.240      _cur_satb_drain_time_ms = ms;
   1.241      _satb_drain_time_set    = true;
   1.242 @@ -987,20 +1013,67 @@
   1.243    // Choose a new collection set.  Marks the chosen regions as being
   1.244    // "in_collection_set", and links them together.  The head and number of
   1.245    // the collection set are available via access methods.
   1.246 -  virtual void choose_collection_set() = 0;
   1.247 -
   1.248 -  void clear_collection_set() { _collection_set = NULL; }
   1.249 +  virtual bool choose_collection_set() = 0;
   1.250  
   1.251    // The head of the list (via "next_in_collection_set()") representing the
   1.252    // current collection set.
   1.253    HeapRegion* collection_set() { return _collection_set; }
   1.254  
   1.255 +  void clear_collection_set() { _collection_set = NULL; }
   1.256 +
   1.257    // The number of elements in the current collection set.
   1.258    size_t collection_set_size() { return _collection_set_size; }
   1.259  
   1.260    // Add "hr" to the CS.
   1.261    void add_to_collection_set(HeapRegion* hr);
   1.262  
   1.263 +  // Incremental CSet Support
   1.264 +
   1.265 +  // The head of the incrementally built collection set.
   1.266 +  HeapRegion* inc_cset_head() { return _inc_cset_head; }
   1.267 +
   1.268 +  // The tail of the incrementally built collection set.
   1.269 +  HeapRegion* inc_set_tail() { return _inc_cset_tail; }
   1.270 +
   1.271 +  // The number of elements in the incrementally built collection set.
   1.272 +  size_t inc_cset_size() { return _inc_cset_size; }
   1.273 +
   1.274 +  // Initialize incremental collection set info.
   1.275 +  void start_incremental_cset_building();
   1.276 +
   1.277 +  void clear_incremental_cset() {
   1.278 +    _inc_cset_head = NULL;
   1.279 +    _inc_cset_tail = NULL;
   1.280 +  }
   1.281 +
   1.282 +  // Stop adding regions to the incremental collection set
   1.283 +  void stop_incremental_cset_building() { _inc_cset_build_state = Inactive; }
   1.284 +
   1.285 +  // Add/remove information about hr to the aggregated information
   1.286 +  // for the incrementally built collection set.
   1.287 +  void add_to_incremental_cset_info(HeapRegion* hr, size_t rs_length);
   1.288 +  void remove_from_incremental_cset_info(HeapRegion* hr);
   1.289 +
   1.290 +  // Update information about hr in the aggregated information for
   1.291 +  // the incrementally built collection set.
   1.292 +  void update_incremental_cset_info(HeapRegion* hr, size_t new_rs_length);
   1.293 +
   1.294 +private:
   1.295 +  // Update the incremental cset information when adding a region
   1.296 +  // (should not be called directly).
   1.297 +  void add_region_to_incremental_cset_common(HeapRegion* hr);
   1.298 +
   1.299 +public:
   1.300 +  // Add hr to the LHS of the incremental collection set.
   1.301 +  void add_region_to_incremental_cset_lhs(HeapRegion* hr);
   1.302 +
   1.303 +  // Add hr to the RHS of the incremental collection set.
   1.304 +  void add_region_to_incremental_cset_rhs(HeapRegion* hr);
   1.305 +
   1.306 +#ifndef PRODUCT
   1.307 +  void print_collection_set(HeapRegion* list_head, outputStream* st);
   1.308 +#endif // !PRODUCT
   1.309 +
   1.310    bool initiate_conc_mark_if_possible()       { return _initiate_conc_mark_if_possible;  }
   1.311    void set_initiate_conc_mark_if_possible()   { _initiate_conc_mark_if_possible = true;  }
   1.312    void clear_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = false; }
   1.313 @@ -1191,7 +1264,7 @@
   1.314    // If the estimated is less then desirable, resize if possible.
   1.315    void expand_if_possible(size_t numRegions);
   1.316  
   1.317 -  virtual void choose_collection_set();
   1.318 +  virtual bool choose_collection_set();
   1.319    virtual void record_collection_pause_start(double start_time_sec,
   1.320                                               size_t start_used);
   1.321    virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes,

mercurial