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

changeset 1546
44f61c24ddab
parent 1454
035d2e036a9b
child 1681
deada8912c54
     1.1 --- a/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp	Fri Dec 11 09:30:48 2009 -0800
     1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp	Wed Dec 16 15:12:51 2009 -0800
     1.3 @@ -42,28 +42,49 @@
     1.4    _n_periods(0),
     1.5    _threads(NULL), _n_threads(0)
     1.6  {
     1.7 -  if (G1ConcRefine) {
     1.8 -    _n_threads = (int)thread_num();
     1.9 -    if (_n_threads > 0) {
    1.10 -      _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads);
    1.11 -      int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids();
    1.12 -      ConcurrentG1RefineThread *next = NULL;
    1.13 -      for (int i = _n_threads - 1; i >= 0; i--) {
    1.14 -        ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
    1.15 -        assert(t != NULL, "Conc refine should have been created");
    1.16 -        assert(t->cg1r() == this, "Conc refine thread should refer to this");
    1.17 -        _threads[i] = t;
    1.18 -        next = t;
    1.19 -      }
    1.20 -    }
    1.21 +
    1.22 +  // Ergomonically select initial concurrent refinement parameters
    1.23 +  if (FLAG_IS_DEFAULT(G1ConcRefineGreenZone)) {
    1.24 +    FLAG_SET_DEFAULT(G1ConcRefineGreenZone, MAX2<int>(ParallelGCThreads, 1));
    1.25 +  }
    1.26 +  set_green_zone(G1ConcRefineGreenZone);
    1.27 +
    1.28 +  if (FLAG_IS_DEFAULT(G1ConcRefineYellowZone)) {
    1.29 +    FLAG_SET_DEFAULT(G1ConcRefineYellowZone, green_zone() * 3);
    1.30 +  }
    1.31 +  set_yellow_zone(MAX2<int>(G1ConcRefineYellowZone, green_zone()));
    1.32 +
    1.33 +  if (FLAG_IS_DEFAULT(G1ConcRefineRedZone)) {
    1.34 +    FLAG_SET_DEFAULT(G1ConcRefineRedZone, yellow_zone() * 2);
    1.35 +  }
    1.36 +  set_red_zone(MAX2<int>(G1ConcRefineRedZone, yellow_zone()));
    1.37 +  _n_worker_threads = thread_num();
    1.38 +  // We need one extra thread to do the young gen rset size sampling.
    1.39 +  _n_threads = _n_worker_threads + 1;
    1.40 +  reset_threshold_step();
    1.41 +
    1.42 +  _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads);
    1.43 +  int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids();
    1.44 +  ConcurrentG1RefineThread *next = NULL;
    1.45 +  for (int i = _n_threads - 1; i >= 0; i--) {
    1.46 +    ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
    1.47 +    assert(t != NULL, "Conc refine should have been created");
    1.48 +    assert(t->cg1r() == this, "Conc refine thread should refer to this");
    1.49 +    _threads[i] = t;
    1.50 +    next = t;
    1.51    }
    1.52  }
    1.53  
    1.54 -size_t ConcurrentG1Refine::thread_num() {
    1.55 -  if (G1ConcRefine) {
    1.56 -    return (G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads;
    1.57 +void ConcurrentG1Refine::reset_threshold_step() {
    1.58 +  if (FLAG_IS_DEFAULT(G1ConcRefineThresholdStep)) {
    1.59 +    _thread_threshold_step = (yellow_zone() - green_zone()) / (worker_thread_num() + 1);
    1.60 +  } else {
    1.61 +    _thread_threshold_step = G1ConcRefineThresholdStep;
    1.62    }
    1.63 -  return 0;
    1.64 +}
    1.65 +
    1.66 +int ConcurrentG1Refine::thread_num() {
    1.67 +  return MAX2<int>((G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads, 1);
    1.68  }
    1.69  
    1.70  void ConcurrentG1Refine::init() {
    1.71 @@ -123,6 +144,15 @@
    1.72    }
    1.73  }
    1.74  
    1.75 +void ConcurrentG1Refine::reinitialize_threads() {
    1.76 +  reset_threshold_step();
    1.77 +  if (_threads != NULL) {
    1.78 +    for (int i = 0; i < _n_threads; i++) {
    1.79 +      _threads[i]->initialize();
    1.80 +    }
    1.81 +  }
    1.82 +}
    1.83 +
    1.84  ConcurrentG1Refine::~ConcurrentG1Refine() {
    1.85    if (G1ConcRSLogCacheSize > 0) {
    1.86      assert(_card_counts != NULL, "Logic");
    1.87 @@ -384,4 +414,3 @@
    1.88      st->cr();
    1.89    }
    1.90  }
    1.91 -

mercurial