mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-17 14:38:55 +00:00
8239825: G1: Simplify threshold test for mutator refinement
Compute refinement threshold when values change, not on each use. Reviewed-by: tschatzl, sangheki
This commit is contained in:
parent
3aeb2d1a51
commit
6ead90568f
@ -451,10 +451,8 @@ bool G1ConcurrentRefine::do_refinement_step(uint worker_id,
|
||||
size_t curr_cards = dcqs.num_cards();
|
||||
// If the number of the cards falls down into the yellow zone,
|
||||
// that means that the transition period after the evacuation pause has ended.
|
||||
// Since the value written to the DCQS is the same for all threads, there is no
|
||||
// need to synchronize.
|
||||
if (dcqs.max_cards_padding() > 0 && curr_cards <= yellow_zone()) {
|
||||
dcqs.set_max_cards_padding(0);
|
||||
if (curr_cards <= yellow_zone()) {
|
||||
dcqs.discard_max_cards_padding();
|
||||
}
|
||||
|
||||
maybe_activate_more_threads(worker_id, curr_cards);
|
||||
|
||||
@ -77,7 +77,7 @@ G1DirtyCardQueueSet::G1DirtyCardQueueSet(BufferNode::Allocator* allocator) :
|
||||
_free_ids(par_ids_start(), num_par_ids()),
|
||||
_process_cards_threshold(ProcessCardsThresholdNever),
|
||||
_max_cards(MaxCardsUnlimited),
|
||||
_max_cards_padding(0),
|
||||
_padded_max_cards(MaxCardsUnlimited),
|
||||
_mutator_refined_cards_counters(NEW_C_HEAP_ARRAY(size_t, num_par_ids(), mtGC))
|
||||
{
|
||||
::memset(_mutator_refined_cards_counters, 0, num_par_ids() * sizeof(size_t));
|
||||
@ -566,10 +566,8 @@ bool G1DirtyCardQueueSet::process_or_enqueue_completed_buffer(BufferNode* node)
|
||||
if (Thread::current()->is_Java_thread()) {
|
||||
// If the number of buffers exceeds the limit, make this Java
|
||||
// thread do the processing itself. Calculation is racy but we
|
||||
// don't need precision here. The add of padding could overflow,
|
||||
// which is treated as unlimited.
|
||||
size_t limit = max_cards() + max_cards_padding();
|
||||
if ((num_cards() > limit) && (limit >= max_cards())) {
|
||||
// don't need precision here.
|
||||
if (num_cards() > Atomic::load(&_padded_max_cards)) {
|
||||
if (mut_process_buffer(node)) {
|
||||
return true;
|
||||
}
|
||||
@ -656,3 +654,28 @@ void G1DirtyCardQueueSet::concatenate_logs() {
|
||||
verify_num_cards();
|
||||
set_max_cards(old_limit);
|
||||
}
|
||||
|
||||
size_t G1DirtyCardQueueSet::max_cards() const {
|
||||
return _max_cards;
|
||||
}
|
||||
|
||||
void G1DirtyCardQueueSet::set_max_cards(size_t value) {
|
||||
_max_cards = value;
|
||||
Atomic::store(&_padded_max_cards, value);
|
||||
}
|
||||
|
||||
void G1DirtyCardQueueSet::set_max_cards_padding(size_t padding) {
|
||||
// Compute sum, clipping to max.
|
||||
size_t limit = _max_cards + padding;
|
||||
if (limit < padding) { // Check for overflow.
|
||||
limit = MaxCardsUnlimited;
|
||||
}
|
||||
Atomic::store(&_padded_max_cards, limit);
|
||||
}
|
||||
|
||||
void G1DirtyCardQueueSet::discard_max_cards_padding() {
|
||||
// Being racy here is okay, since all threads store the same value.
|
||||
if (_max_cards != Atomic::load(&_padded_max_cards)) {
|
||||
Atomic::store(&_padded_max_cards, _max_cards);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ class G1DirtyCardQueueSet: public PtrQueueSet {
|
||||
// If the queue contains more cards than configured here, the
|
||||
// mutator must start doing some of the concurrent refinement work.
|
||||
size_t _max_cards;
|
||||
size_t _max_cards_padding;
|
||||
volatile size_t _padded_max_cards;
|
||||
static const size_t MaxCardsUnlimited = SIZE_MAX;
|
||||
|
||||
// Array of cumulative dirty cards refined by mutator threads.
|
||||
@ -316,19 +316,18 @@ public:
|
||||
// If any threads have partial logs, add them to the global list of logs.
|
||||
void concatenate_logs();
|
||||
|
||||
void set_max_cards(size_t m) {
|
||||
_max_cards = m;
|
||||
}
|
||||
size_t max_cards() const {
|
||||
return _max_cards;
|
||||
}
|
||||
// Threshold for mutator threads to also do refinement when there
|
||||
// are concurrent refinement threads.
|
||||
size_t max_cards() const;
|
||||
|
||||
void set_max_cards_padding(size_t padding) {
|
||||
_max_cards_padding = padding;
|
||||
}
|
||||
size_t max_cards_padding() const {
|
||||
return _max_cards_padding;
|
||||
}
|
||||
// Set threshold for mutator threads to also do refinement.
|
||||
void set_max_cards(size_t value);
|
||||
|
||||
// Artificially increase mutator refinement threshold.
|
||||
void set_max_cards_padding(size_t padding);
|
||||
|
||||
// Discard artificial increase of mutator refinement threshold.
|
||||
void discard_max_cards_padding();
|
||||
|
||||
// Total dirty cards refined by mutator threads.
|
||||
size_t total_mutator_refined_cards() const;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user