1 /* |
1 /* |
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "gc/g1/g1BarrierSet.hpp" |
26 #include "gc/g1/g1BarrierSet.hpp" |
27 #include "gc/g1/g1ConcurrentRefine.hpp" |
27 #include "gc/g1/g1ConcurrentRefine.hpp" |
28 #include "gc/g1/g1ConcurrentRefineThread.hpp" |
28 #include "gc/g1/g1ConcurrentRefineThread.hpp" |
|
29 #include "gc/g1/g1DirtyCardQueue.hpp" |
29 #include "logging/log.hpp" |
30 #include "logging/log.hpp" |
30 #include "memory/allocation.inline.hpp" |
31 #include "memory/allocation.inline.hpp" |
31 #include "runtime/java.hpp" |
32 #include "runtime/java.hpp" |
32 #include "runtime/thread.hpp" |
33 #include "runtime/thread.hpp" |
33 #include "utilities/debug.hpp" |
34 #include "utilities/debug.hpp" |
376 } |
377 } |
377 |
378 |
378 void G1ConcurrentRefine::adjust(double update_rs_time, |
379 void G1ConcurrentRefine::adjust(double update_rs_time, |
379 size_t update_rs_processed_buffers, |
380 size_t update_rs_processed_buffers, |
380 double goal_ms) { |
381 double goal_ms) { |
381 DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
382 G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
382 |
383 |
383 if (G1UseAdaptiveConcRefinement) { |
384 if (G1UseAdaptiveConcRefinement) { |
384 update_zones(update_rs_time, update_rs_processed_buffers, goal_ms); |
385 update_zones(update_rs_time, update_rs_processed_buffers, goal_ms); |
385 |
386 |
386 // Change the barrier params |
387 // Change the barrier params |
387 if (max_num_threads() == 0) { |
388 if (max_num_threads() == 0) { |
388 // Disable dcqs notification when there are no threads to notify. |
389 // Disable dcqs notification when there are no threads to notify. |
389 dcqs.set_process_completed_buffers_threshold(DirtyCardQueueSet::ProcessCompletedBuffersThresholdNever); |
390 dcqs.set_process_completed_buffers_threshold(G1DirtyCardQueueSet::ProcessCompletedBuffersThresholdNever); |
390 } else { |
391 } else { |
391 // Worker 0 is the primary; wakeup is via dcqs notification. |
392 // Worker 0 is the primary; wakeup is via dcqs notification. |
392 STATIC_ASSERT(max_yellow_zone <= INT_MAX); |
393 STATIC_ASSERT(max_yellow_zone <= INT_MAX); |
393 size_t activate = activation_threshold(0); |
394 size_t activate = activation_threshold(0); |
394 dcqs.set_process_completed_buffers_threshold(activate); |
395 dcqs.set_process_completed_buffers_threshold(activate); |
415 Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, worker_id); |
416 Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, worker_id); |
416 return deactivation_level(thresholds); |
417 return deactivation_level(thresholds); |
417 } |
418 } |
418 |
419 |
419 uint G1ConcurrentRefine::worker_id_offset() { |
420 uint G1ConcurrentRefine::worker_id_offset() { |
420 return DirtyCardQueueSet::num_par_ids(); |
421 return G1DirtyCardQueueSet::num_par_ids(); |
421 } |
422 } |
422 |
423 |
423 void G1ConcurrentRefine::maybe_activate_more_threads(uint worker_id, size_t num_cur_buffers) { |
424 void G1ConcurrentRefine::maybe_activate_more_threads(uint worker_id, size_t num_cur_buffers) { |
424 if (num_cur_buffers > activation_threshold(worker_id + 1)) { |
425 if (num_cur_buffers > activation_threshold(worker_id + 1)) { |
425 _thread_control.maybe_activate_next(worker_id); |
426 _thread_control.maybe_activate_next(worker_id); |
426 } |
427 } |
427 } |
428 } |
428 |
429 |
429 bool G1ConcurrentRefine::do_refinement_step(uint worker_id) { |
430 bool G1ConcurrentRefine::do_refinement_step(uint worker_id) { |
430 DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
431 G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
431 |
432 |
432 size_t curr_buffer_num = dcqs.completed_buffers_num(); |
433 size_t curr_buffer_num = dcqs.completed_buffers_num(); |
433 // If the number of the buffers falls down into the yellow zone, |
434 // If the number of the buffers falls down into the yellow zone, |
434 // that means that the transition period after the evacuation pause has ended. |
435 // that means that the transition period after the evacuation pause has ended. |
435 // Since the value written to the DCQS is the same for all threads, there is no |
436 // Since the value written to the DCQS is the same for all threads, there is no |