Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/coreclr/jit/fgprofilesynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/fgprofilesynthesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ProfileSynthesis
{
}

static constexpr weight_t exceptionScale = 0.001;
static constexpr weight_t exceptionWeight = 0.00001;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit surprised to see this fixed weight is smaller than the scale factor it's replacing. Did you get this number through trial and error, or?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing magic here. Just wanted a value that is small enough to ignore in an absolute sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see -- so close to zero, but it won't mark the block with BBF_RUN_RARELY.

static constexpr weight_t initialBlendFactor = 0.05;
static constexpr weight_t blendFactorGrowthRate = 3;
static constexpr weight_t cappedLikelihood = 0.999;
Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,18 +719,15 @@ CONFIG_INTEGER(JitRandomlyCollect64BitCounts, W("JitRandomlyCollect64BitCounts")
// 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"))

// Devirtualize virtual calls with getExactClasses (NativeAOT only for now)
RELEASE_CONFIG_INTEGER(JitEnableExactDevirtualization, W("JitEnableExactDevirtualization"), 1)
Expand Down