From bdfe05b595d86c62f7dad78549023a3426423679 Mon Sep 17 00:00:00 2001 From: Man Cao Date: Mon, 22 Sep 2025 18:05:48 +0000 Subject: [PATCH] 8368071: Compilation throughput regressed 2X-8X after JDK-8355003 Reviewed-by: iveresov, shade --- src/hotspot/share/compiler/compilationPolicy.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/compiler/compilationPolicy.cpp b/src/hotspot/share/compiler/compilationPolicy.cpp index 36b597b6e37..c91d299510d 100644 --- a/src/hotspot/share/compiler/compilationPolicy.cpp +++ b/src/hotspot/share/compiler/compilationPolicy.cpp @@ -1350,17 +1350,24 @@ CompLevel CompilationPolicy::standard_transition(const methodHandle& method, Com return next_level; } +template static inline bool apply_predicate(const methodHandle& method, CompLevel cur_level, int i, int b, bool delay_profiling, double delay_profiling_scale) { + if (delay_profiling) { + return Predicate::apply_scaled(method, cur_level, i, b, delay_profiling_scale); + } else { + return Predicate::apply(method, cur_level, i, b); + } +} + template CompLevel CompilationPolicy::transition_from_none(const methodHandle& method, CompLevel cur_level, bool delay_profiling, bool disable_feedback) { precond(cur_level == CompLevel_none); CompLevel next_level = cur_level; int i = method->invocation_count(); int b = method->backedge_count(); - double scale = delay_profiling ? Tier0ProfileDelayFactor : 1.0; // If we were at full profile level, would we switch to full opt? if (transition_from_full_profile(method, CompLevel_full_profile) == CompLevel_full_optimization) { next_level = CompLevel_full_optimization; - } else if (!CompilationModeFlag::disable_intermediate() && Predicate::apply_scaled(method, cur_level, i, b, scale)) { + } else if (!CompilationModeFlag::disable_intermediate() && apply_predicate(method, cur_level, i, b, delay_profiling, Tier0ProfileDelayFactor)) { // C1-generated fully profiled code is about 30% slower than the limited profile // code that has only invocation and backedge counters. The observation is that // if C2 queue is large enough we can spend too much time in the fully profiled code @@ -1402,13 +1409,12 @@ CompLevel CompilationPolicy::transition_from_limited_profile(const methodHandle& CompLevel next_level = cur_level; int i = method->invocation_count(); int b = method->backedge_count(); - double scale = delay_profiling ? Tier2ProfileDelayFactor : 1.0; MethodData* mdo = method->method_data(); if (mdo != nullptr) { if (mdo->would_profile()) { if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <= Tier3DelayOff * compiler_count(CompLevel_full_optimization) && - Predicate::apply_scaled(method, cur_level, i, b, scale))) { + apply_predicate(method, cur_level, i, b, delay_profiling, Tier2ProfileDelayFactor))) { next_level = CompLevel_full_profile; } } else { @@ -1418,7 +1424,7 @@ CompLevel CompilationPolicy::transition_from_limited_profile(const methodHandle& // If there is no MDO we need to profile if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <= Tier3DelayOff * compiler_count(CompLevel_full_optimization) && - Predicate::apply_scaled(method, cur_level, i, b, scale))) { + apply_predicate(method, cur_level, i, b, delay_profiling, Tier2ProfileDelayFactor))) { next_level = CompLevel_full_profile; } }