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

changeset 3714
f7a8920427a6
parent 3713
720b6a76dd9d
child 3731
8a2e5a6a19a4
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Apr 18 07:21:15 2012 -0400
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Apr 18 13:39:55 2012 -0400
     1.3 @@ -192,11 +192,6 @@
     1.4    _in_marking_window(false),
     1.5    _in_marking_window_im(false),
     1.6  
     1.7 -  _known_garbage_ratio(0.0),
     1.8 -  _known_garbage_bytes(0),
     1.9 -
    1.10 -  _young_gc_eff_seq(new TruncatedSeq(TruncatedSeqLength)),
    1.11 -
    1.12    _recent_prev_end_times_for_all_gcs_sec(
    1.13                                  new TruncatedSeq(NumPrevPausesForHeuristics)),
    1.14  
    1.15 @@ -868,8 +863,6 @@
    1.16    _last_young_gc = false;
    1.17    clear_initiate_conc_mark_if_possible();
    1.18    clear_during_initial_mark_pause();
    1.19 -  _known_garbage_bytes = 0;
    1.20 -  _known_garbage_ratio = 0.0;
    1.21    _in_marking_window = false;
    1.22    _in_marking_window_im = false;
    1.23  
    1.24 @@ -882,7 +875,7 @@
    1.25    // Reset survivors SurvRateGroup.
    1.26    _survivor_surv_rate_group->reset();
    1.27    update_young_list_target_length();
    1.28 -  _collectionSetChooser->clearMarkedHeapRegions();
    1.29 +  _collectionSetChooser->clear();
    1.30  }
    1.31  
    1.32  void G1CollectorPolicy::record_stop_world_start() {
    1.33 @@ -1456,16 +1449,6 @@
    1.34      }
    1.35    }
    1.36  
    1.37 -  // Update the efficiency-since-mark vars.
    1.38 -  double proc_ms = elapsed_ms * (double) _parallel_gc_threads;
    1.39 -  if (elapsed_ms < MIN_TIMER_GRANULARITY) {
    1.40 -    // This usually happens due to the timer not having the required
    1.41 -    // granularity. Some Linuxes are the usual culprits.
    1.42 -    // We'll just set it to something (arbitrarily) small.
    1.43 -    proc_ms = 1.0;
    1.44 -  }
    1.45 -  double cur_efficiency = (double) freed_bytes / proc_ms;
    1.46 -
    1.47    bool new_in_marking_window = _in_marking_window;
    1.48    bool new_in_marking_window_im = false;
    1.49    if (during_initial_mark_pause()) {
    1.50 @@ -1500,10 +1483,6 @@
    1.51      }
    1.52    }
    1.53  
    1.54 -  if (_last_gc_was_young && !_during_marking) {
    1.55 -    _young_gc_eff_seq->add(cur_efficiency);
    1.56 -  }
    1.57 -
    1.58    _short_lived_surv_rate_group->start_adding_regions();
    1.59    // do that for any other surv rate groupsx
    1.60  
    1.61 @@ -1618,7 +1597,7 @@
    1.62    double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
    1.63    adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms);
    1.64  
    1.65 -  assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end.");
    1.66 +  _collectionSetChooser->verify();
    1.67  }
    1.68  
    1.69  #define EXT_SIZE_FORMAT "%d%s"
    1.70 @@ -2065,28 +2044,6 @@
    1.71          HeapRegion::GrainWords * _max_survivor_regions);
    1.72  }
    1.73  
    1.74 -#ifndef PRODUCT
    1.75 -class HRSortIndexIsOKClosure: public HeapRegionClosure {
    1.76 -  CollectionSetChooser* _chooser;
    1.77 -public:
    1.78 -  HRSortIndexIsOKClosure(CollectionSetChooser* chooser) :
    1.79 -    _chooser(chooser) {}
    1.80 -
    1.81 -  bool doHeapRegion(HeapRegion* r) {
    1.82 -    if (!r->continuesHumongous()) {
    1.83 -      assert(_chooser->regionProperlyOrdered(r), "Ought to be.");
    1.84 -    }
    1.85 -    return false;
    1.86 -  }
    1.87 -};
    1.88 -
    1.89 -bool G1CollectorPolicy::assertMarkedBytesDataOK() {
    1.90 -  HRSortIndexIsOKClosure cl(_collectionSetChooser);
    1.91 -  _g1->heap_region_iterate(&cl);
    1.92 -  return true;
    1.93 -}
    1.94 -#endif
    1.95 -
    1.96  bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(
    1.97                                                       GCCause::Cause gc_cause) {
    1.98    bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
    1.99 @@ -2184,8 +2141,8 @@
   1.100        // We will skip any region that's currently used as an old GC
   1.101        // alloc region (we should not consider those for collection
   1.102        // before we fill them up).
   1.103 -      if (_hrSorted->shouldAdd(r) && !_g1h->is_old_gc_alloc_region(r)) {
   1.104 -        _hrSorted->addMarkedHeapRegion(r);
   1.105 +      if (_hrSorted->should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
   1.106 +        _hrSorted->add_region(r);
   1.107        }
   1.108      }
   1.109      return false;
   1.110 @@ -2195,16 +2152,14 @@
   1.111  class ParKnownGarbageHRClosure: public HeapRegionClosure {
   1.112    G1CollectedHeap* _g1h;
   1.113    CollectionSetChooser* _hrSorted;
   1.114 -  jint _marked_regions_added;
   1.115 +  uint _marked_regions_added;
   1.116    size_t _reclaimable_bytes_added;
   1.117 -  jint _chunk_size;
   1.118 -  jint _cur_chunk_idx;
   1.119 -  jint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end)
   1.120 -  int _worker;
   1.121 -  int _invokes;
   1.122 +  uint _chunk_size;
   1.123 +  uint _cur_chunk_idx;
   1.124 +  uint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end)
   1.125  
   1.126    void get_new_chunk() {
   1.127 -    _cur_chunk_idx = _hrSorted->getParMarkedHeapRegionChunk(_chunk_size);
   1.128 +    _cur_chunk_idx = _hrSorted->claim_array_chunk(_chunk_size);
   1.129      _cur_chunk_end = _cur_chunk_idx + _chunk_size;
   1.130    }
   1.131    void add_region(HeapRegion* r) {
   1.132 @@ -2212,7 +2167,7 @@
   1.133        get_new_chunk();
   1.134      }
   1.135      assert(_cur_chunk_idx < _cur_chunk_end, "postcondition");
   1.136 -    _hrSorted->setMarkedHeapRegion(_cur_chunk_idx, r);
   1.137 +    _hrSorted->set_region(_cur_chunk_idx, r);
   1.138      _marked_regions_added++;
   1.139      _reclaimable_bytes_added += r->reclaimable_bytes();
   1.140      _cur_chunk_idx++;
   1.141 @@ -2220,78 +2175,55 @@
   1.142  
   1.143  public:
   1.144    ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted,
   1.145 -                           jint chunk_size,
   1.146 -                           int worker) :
   1.147 +                           uint chunk_size) :
   1.148        _g1h(G1CollectedHeap::heap()),
   1.149 -      _hrSorted(hrSorted), _chunk_size(chunk_size), _worker(worker),
   1.150 +      _hrSorted(hrSorted), _chunk_size(chunk_size),
   1.151        _marked_regions_added(0), _reclaimable_bytes_added(0),
   1.152 -      _cur_chunk_idx(0), _cur_chunk_end(0), _invokes(0) { }
   1.153 +      _cur_chunk_idx(0), _cur_chunk_end(0) { }
   1.154  
   1.155    bool doHeapRegion(HeapRegion* r) {
   1.156 -    // We only include humongous regions in collection
   1.157 -    // sets when concurrent mark shows that their contained object is
   1.158 -    // unreachable.
   1.159 -    _invokes++;
   1.160 -
   1.161      // Do we have any marking information for this region?
   1.162      if (r->is_marked()) {
   1.163        // We will skip any region that's currently used as an old GC
   1.164        // alloc region (we should not consider those for collection
   1.165        // before we fill them up).
   1.166 -      if (_hrSorted->shouldAdd(r) && !_g1h->is_old_gc_alloc_region(r)) {
   1.167 +      if (_hrSorted->should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
   1.168          add_region(r);
   1.169        }
   1.170      }
   1.171      return false;
   1.172    }
   1.173 -  jint marked_regions_added() { return _marked_regions_added; }
   1.174 +  uint marked_regions_added() { return _marked_regions_added; }
   1.175    size_t reclaimable_bytes_added() { return _reclaimable_bytes_added; }
   1.176 -  int invokes() { return _invokes; }
   1.177  };
   1.178  
   1.179  class ParKnownGarbageTask: public AbstractGangTask {
   1.180    CollectionSetChooser* _hrSorted;
   1.181 -  jint _chunk_size;
   1.182 +  uint _chunk_size;
   1.183    G1CollectedHeap* _g1;
   1.184  public:
   1.185 -  ParKnownGarbageTask(CollectionSetChooser* hrSorted, jint chunk_size) :
   1.186 +  ParKnownGarbageTask(CollectionSetChooser* hrSorted, uint chunk_size) :
   1.187      AbstractGangTask("ParKnownGarbageTask"),
   1.188      _hrSorted(hrSorted), _chunk_size(chunk_size),
   1.189      _g1(G1CollectedHeap::heap()) { }
   1.190  
   1.191    void work(uint worker_id) {
   1.192 -    ParKnownGarbageHRClosure parKnownGarbageCl(_hrSorted,
   1.193 -                                               _chunk_size,
   1.194 -                                               worker_id);
   1.195 +    ParKnownGarbageHRClosure parKnownGarbageCl(_hrSorted, _chunk_size);
   1.196 +
   1.197      // Back to zero for the claim value.
   1.198      _g1->heap_region_par_iterate_chunked(&parKnownGarbageCl, worker_id,
   1.199                                           _g1->workers()->active_workers(),
   1.200                                           HeapRegion::InitialClaimValue);
   1.201 -    jint regions_added = parKnownGarbageCl.marked_regions_added();
   1.202 +    uint regions_added = parKnownGarbageCl.marked_regions_added();
   1.203      size_t reclaimable_bytes_added =
   1.204                                     parKnownGarbageCl.reclaimable_bytes_added();
   1.205 -    _hrSorted->updateTotals(regions_added, reclaimable_bytes_added);
   1.206 -    if (G1PrintParCleanupStats) {
   1.207 -      gclog_or_tty->print_cr("     Thread %d called %d times, added %d regions to list.",
   1.208 -                 worker_id, parKnownGarbageCl.invokes(), regions_added);
   1.209 -    }
   1.210 +    _hrSorted->update_totals(regions_added, reclaimable_bytes_added);
   1.211    }
   1.212  };
   1.213  
   1.214  void
   1.215  G1CollectorPolicy::record_concurrent_mark_cleanup_end(int no_of_gc_threads) {
   1.216 -  double start_sec;
   1.217 -  if (G1PrintParCleanupStats) {
   1.218 -    start_sec = os::elapsedTime();
   1.219 -  }
   1.220 -
   1.221 -  _collectionSetChooser->clearMarkedHeapRegions();
   1.222 -  double clear_marked_end_sec;
   1.223 -  if (G1PrintParCleanupStats) {
   1.224 -    clear_marked_end_sec = os::elapsedTime();
   1.225 -    gclog_or_tty->print_cr("  clear marked regions: %8.3f ms.",
   1.226 -                           (clear_marked_end_sec - start_sec) * 1000.0);
   1.227 -  }
   1.228 +  _collectionSetChooser->clear();
   1.229  
   1.230    uint region_num = _g1->n_regions();
   1.231    if (G1CollectedHeap::use_parallel_gc_threads()) {
   1.232 @@ -2314,8 +2246,8 @@
   1.233          MAX2(region_num / (uint) (ParallelGCThreads * OverpartitionFactor),
   1.234               MinWorkUnit);
   1.235      }
   1.236 -    _collectionSetChooser->prepareForAddMarkedHeapRegionsPar(_g1->n_regions(),
   1.237 -                                                             WorkUnit);
   1.238 +    _collectionSetChooser->prepare_for_par_region_addition(_g1->n_regions(),
   1.239 +                                                           WorkUnit);
   1.240      ParKnownGarbageTask parKnownGarbageTask(_collectionSetChooser,
   1.241                                              (int) WorkUnit);
   1.242      _g1->workers()->run_task(&parKnownGarbageTask);
   1.243 @@ -2326,20 +2258,10 @@
   1.244      KnownGarbageClosure knownGarbagecl(_collectionSetChooser);
   1.245      _g1->heap_region_iterate(&knownGarbagecl);
   1.246    }
   1.247 -  double known_garbage_end_sec;
   1.248 -  if (G1PrintParCleanupStats) {
   1.249 -    known_garbage_end_sec = os::elapsedTime();
   1.250 -    gclog_or_tty->print_cr("  compute known garbage: %8.3f ms.",
   1.251 -                      (known_garbage_end_sec - clear_marked_end_sec) * 1000.0);
   1.252 -  }
   1.253  
   1.254 -  _collectionSetChooser->sortMarkedHeapRegions();
   1.255 +  _collectionSetChooser->sort_regions();
   1.256 +
   1.257    double end_sec = os::elapsedTime();
   1.258 -  if (G1PrintParCleanupStats) {
   1.259 -    gclog_or_tty->print_cr("  sorting: %8.3f ms.",
   1.260 -                           (end_sec - known_garbage_end_sec) * 1000.0);
   1.261 -  }
   1.262 -
   1.263    double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
   1.264    _concurrent_mark_cleanup_times_ms->add(elapsed_time_ms);
   1.265    _cur_mark_stop_world_time_ms += elapsed_time_ms;
   1.266 @@ -2555,13 +2477,13 @@
   1.267  bool G1CollectorPolicy::next_gc_should_be_mixed(const char* true_action_str,
   1.268                                                  const char* false_action_str) {
   1.269    CollectionSetChooser* cset_chooser = _collectionSetChooser;
   1.270 -  if (cset_chooser->isEmpty()) {
   1.271 +  if (cset_chooser->is_empty()) {
   1.272      ergo_verbose0(ErgoMixedGCs,
   1.273                    false_action_str,
   1.274                    ergo_format_reason("candidate old regions not available"));
   1.275      return false;
   1.276    }
   1.277 -  size_t reclaimable_bytes = cset_chooser->remainingReclaimableBytes();
   1.278 +  size_t reclaimable_bytes = cset_chooser->remaining_reclaimable_bytes();
   1.279    size_t capacity_bytes = _g1->capacity();
   1.280    double perc = (double) reclaimable_bytes * 100.0 / (double) capacity_bytes;
   1.281    double threshold = (double) G1HeapWastePercent;
   1.282 @@ -2572,7 +2494,7 @@
   1.283                ergo_format_region("candidate old regions")
   1.284                ergo_format_byte_perc("reclaimable")
   1.285                ergo_format_perc("threshold"),
   1.286 -              cset_chooser->remainingRegions(),
   1.287 +              cset_chooser->remaining_regions(),
   1.288                reclaimable_bytes, perc, threshold);
   1.289      return false;
   1.290    }
   1.291 @@ -2583,7 +2505,7 @@
   1.292                  ergo_format_region("candidate old regions")
   1.293                  ergo_format_byte_perc("reclaimable")
   1.294                  ergo_format_perc("threshold"),
   1.295 -                cset_chooser->remainingRegions(),
   1.296 +                cset_chooser->remaining_regions(),
   1.297                  reclaimable_bytes, perc, threshold);
   1.298    return true;
   1.299  }
   1.300 @@ -2666,9 +2588,9 @@
   1.301  
   1.302    if (!gcs_are_young()) {
   1.303      CollectionSetChooser* cset_chooser = _collectionSetChooser;
   1.304 -    assert(cset_chooser->verify(), "CSet Chooser verification - pre");
   1.305 -    const uint min_old_cset_length = cset_chooser->calcMinOldCSetLength();
   1.306 -    const uint max_old_cset_length = cset_chooser->calcMaxOldCSetLength();
   1.307 +    cset_chooser->verify();
   1.308 +    const uint min_old_cset_length = cset_chooser->calc_min_old_cset_length();
   1.309 +    const uint max_old_cset_length = cset_chooser->calc_max_old_cset_length();
   1.310  
   1.311      uint expensive_region_num = 0;
   1.312      bool check_time_remaining = adaptive_young_list_length();
   1.313 @@ -2755,7 +2677,7 @@
   1.314                      time_remaining_ms);
   1.315      }
   1.316  
   1.317 -    assert(cset_chooser->verify(), "CSet Chooser verification - post");
   1.318 +    cset_chooser->verify();
   1.319    }
   1.320  
   1.321    stop_incremental_cset_building();

mercurial