Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp @ 1111:44f61c24ddab
6862387: tune concurrent refinement further
Summary: Reworked the concurrent refinement: threads activation, feedback-based threshold adjustment, other miscellaneous fixes.
Reviewed-by: apetrusenko, tonyp
author | iveresov |
---|---|
date | Wed, 16 Dec 2009 15:12:51 -0800 |
parents | 035d2e036a9b |
children | deada8912c54 |
comparison
equal
deleted
inserted
replaced
1104:27f9477e879b | 1111:44f61c24ddab |
---|---|
40 _hot_cache(NULL), | 40 _hot_cache(NULL), |
41 _def_use_cache(false), _use_cache(false), | 41 _def_use_cache(false), _use_cache(false), |
42 _n_periods(0), | 42 _n_periods(0), |
43 _threads(NULL), _n_threads(0) | 43 _threads(NULL), _n_threads(0) |
44 { | 44 { |
45 if (G1ConcRefine) { | 45 |
46 _n_threads = (int)thread_num(); | 46 // Ergomonically select initial concurrent refinement parameters |
47 if (_n_threads > 0) { | 47 if (FLAG_IS_DEFAULT(G1ConcRefineGreenZone)) { |
48 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads); | 48 FLAG_SET_DEFAULT(G1ConcRefineGreenZone, MAX2<int>(ParallelGCThreads, 1)); |
49 int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids(); | 49 } |
50 ConcurrentG1RefineThread *next = NULL; | 50 set_green_zone(G1ConcRefineGreenZone); |
51 for (int i = _n_threads - 1; i >= 0; i--) { | 51 |
52 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i); | 52 if (FLAG_IS_DEFAULT(G1ConcRefineYellowZone)) { |
53 assert(t != NULL, "Conc refine should have been created"); | 53 FLAG_SET_DEFAULT(G1ConcRefineYellowZone, green_zone() * 3); |
54 assert(t->cg1r() == this, "Conc refine thread should refer to this"); | 54 } |
55 _threads[i] = t; | 55 set_yellow_zone(MAX2<int>(G1ConcRefineYellowZone, green_zone())); |
56 next = t; | 56 |
57 } | 57 if (FLAG_IS_DEFAULT(G1ConcRefineRedZone)) { |
58 } | 58 FLAG_SET_DEFAULT(G1ConcRefineRedZone, yellow_zone() * 2); |
59 } | 59 } |
60 } | 60 set_red_zone(MAX2<int>(G1ConcRefineRedZone, yellow_zone())); |
61 | 61 _n_worker_threads = thread_num(); |
62 size_t ConcurrentG1Refine::thread_num() { | 62 // We need one extra thread to do the young gen rset size sampling. |
63 if (G1ConcRefine) { | 63 _n_threads = _n_worker_threads + 1; |
64 return (G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads; | 64 reset_threshold_step(); |
65 } | 65 |
66 return 0; | 66 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads); |
67 int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids(); | |
68 ConcurrentG1RefineThread *next = NULL; | |
69 for (int i = _n_threads - 1; i >= 0; i--) { | |
70 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i); | |
71 assert(t != NULL, "Conc refine should have been created"); | |
72 assert(t->cg1r() == this, "Conc refine thread should refer to this"); | |
73 _threads[i] = t; | |
74 next = t; | |
75 } | |
76 } | |
77 | |
78 void ConcurrentG1Refine::reset_threshold_step() { | |
79 if (FLAG_IS_DEFAULT(G1ConcRefineThresholdStep)) { | |
80 _thread_threshold_step = (yellow_zone() - green_zone()) / (worker_thread_num() + 1); | |
81 } else { | |
82 _thread_threshold_step = G1ConcRefineThresholdStep; | |
83 } | |
84 } | |
85 | |
86 int ConcurrentG1Refine::thread_num() { | |
87 return MAX2<int>((G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads, 1); | |
67 } | 88 } |
68 | 89 |
69 void ConcurrentG1Refine::init() { | 90 void ConcurrentG1Refine::init() { |
70 if (G1ConcRSLogCacheSize > 0) { | 91 if (G1ConcRSLogCacheSize > 0) { |
71 _g1h = G1CollectedHeap::heap(); | 92 _g1h = G1CollectedHeap::heap(); |
117 | 138 |
118 void ConcurrentG1Refine::stop() { | 139 void ConcurrentG1Refine::stop() { |
119 if (_threads != NULL) { | 140 if (_threads != NULL) { |
120 for (int i = 0; i < _n_threads; i++) { | 141 for (int i = 0; i < _n_threads; i++) { |
121 _threads[i]->stop(); | 142 _threads[i]->stop(); |
143 } | |
144 } | |
145 } | |
146 | |
147 void ConcurrentG1Refine::reinitialize_threads() { | |
148 reset_threshold_step(); | |
149 if (_threads != NULL) { | |
150 for (int i = 0; i < _n_threads; i++) { | |
151 _threads[i]->initialize(); | |
122 } | 152 } |
123 } | 153 } |
124 } | 154 } |
125 | 155 |
126 ConcurrentG1Refine::~ConcurrentG1Refine() { | 156 ConcurrentG1Refine::~ConcurrentG1Refine() { |
382 for (int i = 0; i < _n_threads; ++i) { | 412 for (int i = 0; i < _n_threads; ++i) { |
383 _threads[i]->print_on(st); | 413 _threads[i]->print_on(st); |
384 st->cr(); | 414 st->cr(); |
385 } | 415 } |
386 } | 416 } |
387 |