From ad8b7e730adcb2577bc0ea542e45bb222c542e09 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 10 Apr 2024 19:51:58 -0700 Subject: [PATCH] JIT: revise how synthesis treats handler regions Instead of giving hander regions a fraction of the entry weight, give them a small fixed weight. This is intended to combat the lack of profile propagation out of handler regions, where there are currently sometimes weight discontinuities large enough to cause profile check asserts. Contributes to #93020. --- src/coreclr/jit/fgprofilesynthesis.cpp | 19 +++++++++---------- src/coreclr/jit/fgprofilesynthesis.h | 2 +- src/coreclr/jit/jitconfigvalues.h | 6 ++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/coreclr/jit/fgprofilesynthesis.cpp b/src/coreclr/jit/fgprofilesynthesis.cpp index 4c1d6a72c2bd37..9ab3cf0001f90e 100644 --- a/src/coreclr/jit/fgprofilesynthesis.cpp +++ b/src/coreclr/jit/fgprofilesynthesis.cpp @@ -1039,29 +1039,28 @@ void ProfileSynthesis::AssignInputWeights(ProfileSynthesisOption option) // Determine input weight for EH regions, if any. // - weight_t exceptionScaleFactor = exceptionScale; + weight_t ehWeight = exceptionWeight; #ifdef DEBUG - if (JitConfig.JitSynthesisExceptionScale() != nullptr) + if (JitConfig.JitSynthesisExceptionWeight() != nullptr) { - ConfigDoubleArray JitSynthesisExceptionScaleArray; - JitSynthesisExceptionScaleArray.EnsureInit(JitConfig.JitSynthesisExceptionScale()); - weight_t newFactor = JitSynthesisExceptionScaleArray.GetData()[0]; + ConfigDoubleArray JitSynthesisExceptionWeightArray; + JitSynthesisExceptionWeightArray.EnsureInit(JitConfig.JitSynthesisExceptionWeight()); + weight_t newFactor = JitSynthesisExceptionWeightArray.GetData()[0]; if ((newFactor >= 0) && (newFactor <= 1.0)) { - exceptionScaleFactor = newFactor; + ehWeight = newFactor; } } #endif - JITDUMP("Synthesis: exception scale factor " FMT_WT "\n", exceptionScaleFactor); - const weight_t ehWeight = entryWeight * exceptionScaleFactor; + JITDUMP("Synthesis: exception weight " FMT_WT "\n", ehWeight); if (ehWeight != 0) { - // We can't inline methods with EH, also inlinees share the parent - // EH tab, so we can't rely on this being empty. + // We can't inline methods with EH. Inlinees share the parent + // EH tab, so we can't rely on the EH table being empty. // if (!m_comp->compIsForInlining()) { diff --git a/src/coreclr/jit/fgprofilesynthesis.h b/src/coreclr/jit/fgprofilesynthesis.h index 533c8fab2c007d..e704f291802e24 100644 --- a/src/coreclr/jit/fgprofilesynthesis.h +++ b/src/coreclr/jit/fgprofilesynthesis.h @@ -45,7 +45,7 @@ class ProfileSynthesis { } - static constexpr weight_t exceptionScale = 0.001; + static constexpr weight_t exceptionWeight = 0.00001; static constexpr weight_t initialBlendFactor = 0.05; static constexpr weight_t blendFactorGrowthRate = 3; static constexpr weight_t cappedLikelihood = 0.999; diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index 067d685cf7fa2c..e25295728fe9bc 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -682,15 +682,13 @@ CONFIG_INTEGER(JitRandomlyCollect64BitCounts, W("JitRandomlyCollect64BitCounts") // 2: profile synthesis for root methods w/o PGO data // 3: profile synthesis for root methods, blend with existing PGO data CONFIG_INTEGER(JitSynthesizeCounts, W("JitSynthesizeCounts"), 0) -// Check if synthesis left consistent counts -CONFIG_INTEGER(JitCheckSynthesizedCounts, W("JitCheckSynthesizedCounts"), 0) // If instrumenting the method, run synthesis and save the synthesis results // as edge or block profile data. Do not actually instrument. CONFIG_INTEGER(JitPropagateSynthesizedCountsToProfileData, W("JitPropagateSynthesizedCountsToProfileData"), 0) // Use general (gauss-seidel) solver CONFIG_INTEGER(JitSynthesisUseSolver, W("JitSynthesisUseSolver"), 1) -// Relative likelihood of exceptions for synthesis -CONFIG_STRING(JitSynthesisExceptionScale, W("JitSynthesisExceptionScale")) +// Weight for exception regions for synthesis +CONFIG_STRING(JitSynthesisExceptionWeight, W("JitSynthesisExceptionWeight")) #endif // Devirtualize virtual calls with getExactClasses (NativeAOT only for now)