Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: don't report profile for methods with insufficient samples during prejitting #55096

Merged
merged 2 commits into from
Jul 5, 2021
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
23 changes: 18 additions & 5 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19061,17 +19061,30 @@ void Compiler::impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, I

// If the call site has profile data, report the relative frequency of the site.
//
if ((pInlineInfo != nullptr) && pInlineInfo->iciBlock->hasProfileWeight())
if ((pInlineInfo != nullptr) && rootCompiler->fgHaveProfileData() && pInlineInfo->iciBlock->hasProfileWeight())
{
double callSiteWeight = (double)pInlineInfo->iciBlock->bbWeight;
double entryWeight = (double)impInlineRoot()->fgFirstBB->bbWeight;
BasicBlock::weight_t callSiteWeight = pInlineInfo->iciBlock->bbWeight;
BasicBlock::weight_t entryWeight = rootCompiler->fgFirstBB->bbWeight;
BasicBlock::weight_t profileFreq = entryWeight == 0.0f ? 0.0f : callSiteWeight / entryWeight;

assert(callSiteWeight >= 0);
assert(entryWeight >= 0);

BasicBlock::weight_t sufficientSamples = 1000.0f;

if (!rootCompiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) ||
((callSiteWeight + entryWeight) > sufficientSamples))
{
// Let's not report profiles for methods with insufficient samples during prejitting.
inlineResult->NoteBool(InlineObservation::CALLSITE_HAS_PROFILE, true);
inlineResult->NoteDouble(InlineObservation::CALLSITE_PROFILE_FREQUENCY, profileFreq);
}
}
else if ((pInlineInfo == nullptr) && rootCompiler->fgHaveProfileData())
{
// Simulate a hot callsite for PrejitRoot mode.
inlineResult->NoteBool(InlineObservation::CALLSITE_HAS_PROFILE, true);
double frequency = entryWeight == 0.0 ? 0.0 : callSiteWeight / entryWeight;
inlineResult->NoteDouble(InlineObservation::CALLSITE_PROFILE_FREQUENCY, frequency);
inlineResult->NoteDouble(InlineObservation::CALLSITE_PROFILE_FREQUENCY, 1.0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ CONFIG_STRING(JitInlineReplayFile, W("JitInlineReplayFile"))
CONFIG_INTEGER(JitExtDefaultPolicy, W("JitExtDefaultPolicy"), 1)
CONFIG_INTEGER(JitExtDefaultPolicyMaxIL, W("JitExtDefaultPolicyMaxIL"), 0x64)
CONFIG_INTEGER(JitExtDefaultPolicyMaxBB, W("JitExtDefaultPolicyMaxBB"), 7)
CONFIG_INTEGER(JitExtDefaultPolicyProfScale, W("JitExtDefaultPolicyProfScale"), 0x22)
CONFIG_INTEGER(JitExtDefaultPolicyProfScale, W("JitExtDefaultPolicyProfScale"), 0x2A)
CONFIG_INTEGER(JitExtDefaultPolicyProfTrust, W("JitExtDefaultPolicyProfTrust"), 0x7)

CONFIG_INTEGER(JitInlinePolicyModel, W("JitInlinePolicyModel"), 0)
Expand Down