Skip to content

Commit

Permalink
8294842: Pass actual pending cards to G1Policy::update_young_length_b…
Browse files Browse the repository at this point in the history
…ounds during young gen revise

Reviewed-by: kbarrett, ayang
  • Loading branch information
Thomas Schatzl committed Oct 14, 2022
1 parent 7133fc9 commit f31c80d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1Analytics.hpp
Expand Up @@ -140,8 +140,8 @@ class G1Analytics: public CHeapObj<mtGC> {
double predict_concurrent_refine_rate_ms() const;
double predict_dirtied_cards_rate_ms() const;

// Predict how many cards in a remembered set of length rs_length will need to
// be scanned in addition to the pending log buffer cards.
// Predict how many of the given remembered set of length rs_length will add to
// the number of total cards scanned.
size_t predict_scan_card_num(size_t rs_length, bool for_young_gc) const;

double predict_card_merge_time_ms(size_t card_num, bool for_young_gc) const;
Expand Down
18 changes: 11 additions & 7 deletions src/hotspot/share/gc/g1/g1Policy.cpp
Expand Up @@ -194,11 +194,12 @@ uint G1Policy::calculate_desired_eden_length_by_mmu() const {
}

void G1Policy::update_young_length_bounds() {
update_young_length_bounds(_analytics->predict_rs_length());
update_young_length_bounds(_analytics->predict_pending_cards(),
_analytics->predict_rs_length());
}

void G1Policy::update_young_length_bounds(size_t rs_length) {
_young_list_desired_length = calculate_young_desired_length(rs_length);
void G1Policy::update_young_length_bounds(size_t pending_cards, size_t rs_length) {
_young_list_desired_length = calculate_young_desired_length(pending_cards, rs_length);
_young_list_target_length = calculate_young_target_length(_young_list_desired_length);
_young_list_max_length = calculate_young_max_length(_young_list_target_length);

Expand All @@ -221,7 +222,7 @@ void G1Policy::update_young_length_bounds(size_t rs_length) {
// The main reason is revising young length, with or without the GCLocker being
// active.
//
uint G1Policy::calculate_young_desired_length(size_t rs_length) const {
uint G1Policy::calculate_young_desired_length(size_t pending_cards, size_t rs_length) const {
uint min_young_length_by_sizer = _young_gen_sizer.min_desired_young_length();
uint max_young_length_by_sizer = _young_gen_sizer.max_desired_young_length();

Expand Down Expand Up @@ -256,7 +257,6 @@ uint G1Policy::calculate_young_desired_length(size_t rs_length) const {
if (use_adaptive_young_list_length()) {
desired_eden_length_by_mmu = calculate_desired_eden_length_by_mmu();

const size_t pending_cards = _analytics->predict_pending_cards();
double base_time_ms = predict_base_time_ms(pending_cards, rs_length);

desired_eden_length_by_pause =
Expand Down Expand Up @@ -523,7 +523,11 @@ void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_length) {
// add 10% to avoid having to recalculate often
size_t rs_length_prediction = rs_length * 1100 / 1000;
update_rs_length_prediction(rs_length_prediction);
update_young_length_bounds(rs_length_prediction);

G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set();
// We have no measure of the number of cards in the thread log buffers, assume
// these are very few compared to the sum of the two other sources.
update_young_length_bounds(dcqs.num_cards(), rs_length_prediction);
}
}

Expand Down Expand Up @@ -914,7 +918,7 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar
} else {
// Any garbage collection triggered as periodic collection resets the time-to-mixed
// measurement. Periodic collection typically means that the application is "inactive", i.e.
// the marking threads may have received an uncharacterisic amount of cpu time
// the marking threads may have received an uncharacteristic amount of cpu time
// for completing the marking, i.e. are faster than expected.
// This skews the predicted marking length towards smaller values which might cause
// the mark start being too late.
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/gc/g1/g1Policy.hpp
Expand Up @@ -194,10 +194,10 @@ class G1Policy: public CHeapObj<mtGC> {
double _mark_cleanup_start_sec;

// Updates the internal young gen maximum and target and desired lengths.
// If no rs_length parameter is passed, predict the RS length using the
// prediction model, otherwise use the given rs_length as the prediction.
// If no parameters are passed, predict pending cards and the RS length using
// the prediction model.
void update_young_length_bounds();
void update_young_length_bounds(size_t rs_length);
void update_young_length_bounds(size_t pending_cards, size_t rs_length);

// Calculate and return the minimum desired eden length based on the MMU target.
uint calculate_desired_eden_length_by_mmu() const;
Expand Down Expand Up @@ -225,7 +225,7 @@ class G1Policy: public CHeapObj<mtGC> {

// Calculate desired young length based on current situation without taking actually
// available free regions into account.
uint calculate_young_desired_length(size_t rs_length) const;
uint calculate_young_desired_length(size_t pending_cards, size_t rs_length) const;
// Limit the given desired young length to available free regions.
uint calculate_young_target_length(uint desired_young_length) const;
// The GCLocker might cause us to need more regions than the target. Calculate
Expand Down

0 comments on commit f31c80d

Please sign in to comment.