From c202a2f7b231152136bd8960c55e43bc96cf1eb9 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 25 Oct 2024 15:24:55 +0000 Subject: [PATCH] 8295269: G1: Improve slow startup due to predictor initialization Reviewed-by: iwalulya, sjohanss --- src/hotspot/share/gc/g1/g1AnalyticsSequences.hpp | 1 + src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/g1/g1AnalyticsSequences.hpp b/src/hotspot/share/gc/g1/g1AnalyticsSequences.hpp index 4593c8d934d..dbd13d29b78 100644 --- a/src/hotspot/share/gc/g1/g1AnalyticsSequences.hpp +++ b/src/hotspot/share/gc/g1/g1AnalyticsSequences.hpp @@ -35,6 +35,7 @@ class G1Predictions; // Container for TruncatedSeqs that need separate predictors by GC phase. class G1PhaseDependentSeq { TruncatedSeq _young_only_seq; + double _initial_value; TruncatedSeq _mixed_seq; NONCOPYABLE(G1PhaseDependentSeq); diff --git a/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp b/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp index d3520487caa..02a54e2a035 100644 --- a/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp +++ b/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp @@ -34,6 +34,7 @@ bool G1PhaseDependentSeq::enough_samples_to_use_mixed_seq() const { G1PhaseDependentSeq::G1PhaseDependentSeq(int length) : _young_only_seq(length), + _initial_value(0.0), _mixed_seq(length) { } @@ -42,7 +43,7 @@ TruncatedSeq* G1PhaseDependentSeq::seq_raw(bool use_young_only_phase_seq) { } void G1PhaseDependentSeq::set_initial(double value) { - _young_only_seq.add(value); + _initial_value = value; } void G1PhaseDependentSeq::add(double value, bool for_young_only_phase) { @@ -51,8 +52,12 @@ void G1PhaseDependentSeq::add(double value, bool for_young_only_phase) { double G1PhaseDependentSeq::predict(const G1Predictions* predictor, bool use_young_only_phase_seq) const { if (use_young_only_phase_seq || !enough_samples_to_use_mixed_seq()) { + if (_young_only_seq.num() == 0) { + return _initial_value; + } return predictor->predict(&_young_only_seq); } else { + assert(_mixed_seq.num() > 0, "must not ask this with no samples"); return predictor->predict(&_mixed_seq); } }