Skip to content

Commit

Permalink
8137022: Concurrent refinement thread adjustment and (de-)activation …
Browse files Browse the repository at this point in the history
…suboptimal

8155996: Improve concurrent refinement green zone control
8134303: Introduce -XX:-G1UseConcRefinement

Reviewed-by: sjohanss, tschatzl, iwalulya, ayang
  • Loading branch information
Kim Barrett committed Oct 20, 2022
1 parent faa6b66 commit 028e8b3
Show file tree
Hide file tree
Showing 24 changed files with 948 additions and 942 deletions.
11 changes: 10 additions & 1 deletion src/hotspot/share/gc/g1/g1Analytics.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -82,6 +82,7 @@ G1Analytics::G1Analytics(const G1Predictions* predictor) :
_mixed_rs_length_diff_seq(new TruncatedSeq(TruncatedSeqLength)),
_concurrent_refine_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
_dirtied_cards_rate_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
_dirtied_cards_in_thread_buffers_seq(new TruncatedSeq(TruncatedSeqLength)),
_young_card_scan_to_merge_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
_mixed_card_scan_to_merge_ratio_seq(new TruncatedSeq(TruncatedSeqLength)),
_young_cost_per_card_scan_ms_seq(new TruncatedSeq(TruncatedSeqLength)),
Expand Down Expand Up @@ -172,6 +173,10 @@ void G1Analytics::report_dirtied_cards_rate_ms(double cards_per_ms) {
_dirtied_cards_rate_ms_seq->add(cards_per_ms);
}

void G1Analytics::report_dirtied_cards_in_thread_buffers(size_t cards) {
_dirtied_cards_in_thread_buffers_seq->add(double(cards));
}

void G1Analytics::report_cost_per_card_scan_ms(double cost_per_card_ms, bool for_young_only_phase) {
if (for_young_only_phase) {
_young_cost_per_card_scan_ms_seq->add(cost_per_card_ms);
Expand Down Expand Up @@ -256,6 +261,10 @@ double G1Analytics::predict_dirtied_cards_rate_ms() const {
return predict_zero_bounded(_dirtied_cards_rate_ms_seq);
}

size_t G1Analytics::predict_dirtied_cards_in_thread_buffers() const {
return predict_size(_dirtied_cards_in_thread_buffers_seq);
}

size_t G1Analytics::predict_scan_card_num(size_t rs_length, bool for_young_only_phase) const {
if (for_young_only_phase || !enough_samples_available(_mixed_card_scan_to_merge_ratio_seq)) {
return (size_t)(rs_length * predict_in_unit_interval(_young_card_scan_to_merge_ratio_seq));
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/gc/g1/g1Analytics.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -49,6 +49,7 @@ class G1Analytics: public CHeapObj<mtGC> {
TruncatedSeq* _mixed_rs_length_diff_seq;
TruncatedSeq* _concurrent_refine_rate_ms_seq;
TruncatedSeq* _dirtied_cards_rate_ms_seq;
TruncatedSeq* _dirtied_cards_in_thread_buffers_seq;
// The ratio between the number of scanned cards and actually merged cards, for
// young-only and mixed gcs.
TruncatedSeq* _young_card_scan_to_merge_ratio_seq;
Expand Down Expand Up @@ -126,6 +127,7 @@ class G1Analytics: public CHeapObj<mtGC> {
void report_alloc_rate_ms(double alloc_rate);
void report_concurrent_refine_rate_ms(double cards_per_ms);
void report_dirtied_cards_rate_ms(double cards_per_ms);
void report_dirtied_cards_in_thread_buffers(size_t num_cards);
void report_cost_per_card_scan_ms(double cost_per_remset_card_ms, bool for_young_only_phase);
void report_cost_per_card_merge_ms(double cost_per_card_ms, bool for_young_only_phase);
void report_card_scan_to_merge_ratio(double cards_per_entry_ratio, bool for_young_only_phase);
Expand All @@ -142,6 +144,7 @@ class G1Analytics: public CHeapObj<mtGC> {

double predict_concurrent_refine_rate_ms() const;
double predict_dirtied_cards_rate_ms() const;
size_t predict_dirtied_cards_in_thread_buffers() const;

// Predict how many of the given remembered set of length rs_length will add to
// the number of total cards scanned.
Expand Down
10 changes: 8 additions & 2 deletions src/hotspot/share/gc/g1/g1Arguments.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -177,7 +177,13 @@ void G1Arguments::initialize() {
FLAG_SET_ERGO(ParallelGCThreads, 1);
}

if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) {
if (!G1UseConcRefinement) {
if (!FLAG_IS_DEFAULT(G1ConcRefinementThreads)) {
log_warning(gc, ergo)("Ignoring -XX:G1ConcRefinementThreads "
"because of -XX:-G1UseConcRefinement");
}
FLAG_SET_DEFAULT(G1ConcRefinementThreads, 0);
} else if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) {
FLAG_SET_ERGO(G1ConcRefinementThreads, ParallelGCThreads);
}

Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ G1RegionToSpaceMapper* G1CollectedHeap::create_aux_memory_mapper(const char* des

jint G1CollectedHeap::initialize_concurrent_refinement() {
jint ecode = JNI_OK;
_cr = G1ConcurrentRefine::create(&ecode);
_cr = G1ConcurrentRefine::create(policy(), &ecode);
return ecode;
}

Expand Down Expand Up @@ -1713,9 +1713,6 @@ jint G1CollectedHeap::initialize() {
return ecode;
}

// Initialize and schedule sampling task on service thread.
_rem_set->initialize_sampling_task(service_thread());

// Create and schedule the periodic gc task on the service thread.
_periodic_gc_task = new G1PeriodicGCTask("Periodic GC Task");
_service_thread->register_task(_periodic_gc_task);
Expand Down
Loading

1 comment on commit 028e8b3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.