181 assert(azc_gyr_yellow <= azc_gyr_red, \
182 "yellow (" SIZE_FORMAT ") exceeds red (" SIZE_FORMAT ")", \
183 azc_gyr_yellow, azc_gyr_red); \
184 } while (0)
185
186 // Logging tag sequence for refinement control updates.
187 #define CTRL_TAGS gc, ergo, refine
188
189 // For logging zone values, ensuring consistency of level and tags.
190 #define LOG_ZONES(...) log_debug( CTRL_TAGS )(__VA_ARGS__)
191
192 // Package for pair of refinement thread activation and deactivation
193 // thresholds. The activation and deactivation levels are resp. the first
194 // and second values of the pair.
195 typedef Pair<size_t, size_t> Thresholds;
196 inline size_t activation_level(const Thresholds& t) { return t.first; }
197 inline size_t deactivation_level(const Thresholds& t) { return t.second; }
198
199 static Thresholds calc_thresholds(size_t green_zone,
200 size_t yellow_zone,
201 uint worker_i) {
202 double yellow_size = yellow_zone - green_zone;
203 double step = yellow_size / G1ConcurrentRefine::max_num_threads();
204 if (worker_i == 0) {
205 // Potentially activate worker 0 more aggressively, to keep
206 // available buffers near green_zone value. When yellow_size is
207 // large we don't want to allow a full step to accumulate before
208 // doing any processing, as that might lead to significantly more
209 // than green_zone buffers to be processed during scanning.
210 step = MIN2(step, ParallelGCThreads / 2.0);
211 }
212 size_t activate_offset = static_cast<size_t>(ceil(step * (worker_i + 1)));
213 size_t deactivate_offset = static_cast<size_t>(floor(step * worker_i));
214 return Thresholds(green_zone + activate_offset,
215 green_zone + deactivate_offset);
216 }
217
218 G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone,
219 size_t yellow_zone,
220 size_t red_zone,
221 size_t min_yellow_zone_size) :
222 _thread_control(),
223 _green_zone(green_zone),
224 _yellow_zone(yellow_zone),
225 _red_zone(red_zone),
226 _min_yellow_zone_size(min_yellow_zone_size)
227 {
228 assert_zone_constraints_gyr(green_zone, yellow_zone, red_zone);
229 }
230
231 jint G1ConcurrentRefine::initialize() {
232 return _thread_control.initialize(this, max_num_threads());
233 }
|
181 assert(azc_gyr_yellow <= azc_gyr_red, \
182 "yellow (" SIZE_FORMAT ") exceeds red (" SIZE_FORMAT ")", \
183 azc_gyr_yellow, azc_gyr_red); \
184 } while (0)
185
186 // Logging tag sequence for refinement control updates.
187 #define CTRL_TAGS gc, ergo, refine
188
189 // For logging zone values, ensuring consistency of level and tags.
190 #define LOG_ZONES(...) log_debug( CTRL_TAGS )(__VA_ARGS__)
191
192 // Package for pair of refinement thread activation and deactivation
193 // thresholds. The activation and deactivation levels are resp. the first
194 // and second values of the pair.
195 typedef Pair<size_t, size_t> Thresholds;
196 inline size_t activation_level(const Thresholds& t) { return t.first; }
197 inline size_t deactivation_level(const Thresholds& t) { return t.second; }
198
199 static Thresholds calc_thresholds(size_t green_zone,
200 size_t yellow_zone,
201 uint worker_id) {
202 double yellow_size = yellow_zone - green_zone;
203 double step = yellow_size / G1ConcurrentRefine::max_num_threads();
204 if (worker_id == 0) {
205 // Potentially activate worker 0 more aggressively, to keep
206 // available buffers near green_zone value. When yellow_size is
207 // large we don't want to allow a full step to accumulate before
208 // doing any processing, as that might lead to significantly more
209 // than green_zone buffers to be processed during scanning.
210 step = MIN2(step, ParallelGCThreads / 2.0);
211 }
212 size_t activate_offset = static_cast<size_t>(ceil(step * (worker_id + 1)));
213 size_t deactivate_offset = static_cast<size_t>(floor(step * worker_id));
214 return Thresholds(green_zone + activate_offset,
215 green_zone + deactivate_offset);
216 }
217
218 G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone,
219 size_t yellow_zone,
220 size_t red_zone,
221 size_t min_yellow_zone_size) :
222 _thread_control(),
223 _green_zone(green_zone),
224 _yellow_zone(yellow_zone),
225 _red_zone(red_zone),
226 _min_yellow_zone_size(min_yellow_zone_size)
227 {
228 assert_zone_constraints_gyr(green_zone, yellow_zone, red_zone);
229 }
230
231 jint G1ConcurrentRefine::initialize() {
232 return _thread_control.initialize(this, max_num_threads());
233 }
|