6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/concurrentG1Refine.hpp"
27 #include "gc/g1/concurrentG1RefineThread.hpp"
28 #include "gc/g1/g1YoungRemSetSamplingThread.hpp"
29 #include "logging/log.hpp"
30 #include "runtime/java.hpp"
31 #include "runtime/thread.hpp"
32 #include "utilities/debug.hpp"
33 #include "utilities/globalDefinitions.hpp"
34 #include "utilities/pair.hpp"
35 #include <math.h>
36
37 // Arbitrary but large limits, to simplify some of the zone calculations.
38 // The general idea is to allow expressions like
39 // MIN2(x OP y, max_XXX_zone)
40 // without needing to check for overflow in "x OP y", because the
41 // ranges for x and y have been restricted.
42 STATIC_ASSERT(sizeof(LP64_ONLY(jint) NOT_LP64(jshort)) <= (sizeof(size_t)/2));
43 const size_t max_yellow_zone = LP64_ONLY(max_jint) NOT_LP64(max_jshort);
44 const size_t max_green_zone = max_yellow_zone / 2;
45 const size_t max_red_zone = INT_MAX; // For dcqs.set_max_completed_queue.
326 goal_ms);
327
328 _green_zone = calc_new_green_zone(_green_zone,
329 update_rs_time,
330 update_rs_processed_buffers,
331 goal_ms);
332 _yellow_zone = calc_new_yellow_zone(_green_zone, _min_yellow_zone_size);
333 _red_zone = calc_new_red_zone(_green_zone, _yellow_zone);
334
335 assert_zone_constraints_gyr(_green_zone, _yellow_zone, _red_zone);
336 LOG_ZONES("Updated Refinement Zones: "
337 "green: " SIZE_FORMAT ", "
338 "yellow: " SIZE_FORMAT ", "
339 "red: " SIZE_FORMAT,
340 _green_zone, _yellow_zone, _red_zone);
341 }
342
343 void ConcurrentG1Refine::adjust(double update_rs_time,
344 size_t update_rs_processed_buffers,
345 double goal_ms) {
346 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
347
348 if (G1UseAdaptiveConcRefinement) {
349 update_zones(update_rs_time, update_rs_processed_buffers, goal_ms);
350 update_thread_thresholds();
351
352 // Change the barrier params
353 if (_n_worker_threads == 0) {
354 // Disable dcqs notification when there are no threads to notify.
355 dcqs.set_process_completed_threshold(INT_MAX);
356 } else {
357 // Worker 0 is the primary; wakeup is via dcqs notification.
358 STATIC_ASSERT(max_yellow_zone <= INT_MAX);
359 size_t activate = _threads[0]->activation_threshold();
360 dcqs.set_process_completed_threshold((int)activate);
361 }
362 dcqs.set_max_completed_queue((int)red_zone());
363 }
364
365 size_t curr_queue_size = dcqs.completed_buffers_num();
366 if (curr_queue_size >= yellow_zone()) {
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/g1BarrierSet.hpp"
27 #include "gc/g1/concurrentG1Refine.hpp"
28 #include "gc/g1/concurrentG1RefineThread.hpp"
29 #include "gc/g1/g1YoungRemSetSamplingThread.hpp"
30 #include "logging/log.hpp"
31 #include "runtime/java.hpp"
32 #include "runtime/thread.hpp"
33 #include "utilities/debug.hpp"
34 #include "utilities/globalDefinitions.hpp"
35 #include "utilities/pair.hpp"
36 #include <math.h>
37
38 // Arbitrary but large limits, to simplify some of the zone calculations.
39 // The general idea is to allow expressions like
40 // MIN2(x OP y, max_XXX_zone)
41 // without needing to check for overflow in "x OP y", because the
42 // ranges for x and y have been restricted.
43 STATIC_ASSERT(sizeof(LP64_ONLY(jint) NOT_LP64(jshort)) <= (sizeof(size_t)/2));
44 const size_t max_yellow_zone = LP64_ONLY(max_jint) NOT_LP64(max_jshort);
45 const size_t max_green_zone = max_yellow_zone / 2;
46 const size_t max_red_zone = INT_MAX; // For dcqs.set_max_completed_queue.
327 goal_ms);
328
329 _green_zone = calc_new_green_zone(_green_zone,
330 update_rs_time,
331 update_rs_processed_buffers,
332 goal_ms);
333 _yellow_zone = calc_new_yellow_zone(_green_zone, _min_yellow_zone_size);
334 _red_zone = calc_new_red_zone(_green_zone, _yellow_zone);
335
336 assert_zone_constraints_gyr(_green_zone, _yellow_zone, _red_zone);
337 LOG_ZONES("Updated Refinement Zones: "
338 "green: " SIZE_FORMAT ", "
339 "yellow: " SIZE_FORMAT ", "
340 "red: " SIZE_FORMAT,
341 _green_zone, _yellow_zone, _red_zone);
342 }
343
344 void ConcurrentG1Refine::adjust(double update_rs_time,
345 size_t update_rs_processed_buffers,
346 double goal_ms) {
347 DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set();
348
349 if (G1UseAdaptiveConcRefinement) {
350 update_zones(update_rs_time, update_rs_processed_buffers, goal_ms);
351 update_thread_thresholds();
352
353 // Change the barrier params
354 if (_n_worker_threads == 0) {
355 // Disable dcqs notification when there are no threads to notify.
356 dcqs.set_process_completed_threshold(INT_MAX);
357 } else {
358 // Worker 0 is the primary; wakeup is via dcqs notification.
359 STATIC_ASSERT(max_yellow_zone <= INT_MAX);
360 size_t activate = _threads[0]->activation_threshold();
361 dcqs.set_process_completed_threshold((int)activate);
362 }
363 dcqs.set_max_completed_queue((int)red_zone());
364 }
365
366 size_t curr_queue_size = dcqs.completed_buffers_num();
367 if (curr_queue_size >= yellow_zone()) {
|