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: allow inlinee profile scale-up #48280

Merged
merged 1 commit into from
Feb 16, 2021
Merged
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
21 changes: 13 additions & 8 deletions src/coreclr/jit/fgprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,27 @@ void Compiler::fgComputeProfileScale()
return;
}

// Note when/if we do normalization this may need to change.
// Note when/if we early do normalization this may need to change.
//
BasicBlock::weight_t calleeWeight = fgFirstBB->bbWeight;
BasicBlock::weight_t const calleeWeight = fgFirstBB->bbWeight;

// We should generally be able to assume calleeWeight >= callSiteWeight.
// If this isn't so, perhaps something is wrong with the profile data
// collection or retrieval.
// If profile data reflects a complete single run we can expect
// calleeWeight >= callSiteWeight.
//
if (calleeWeight < callSiteWeight)
// However if our profile is just a subset of execution we may
// not see this.
//
// So, we are willing to scale the callee counts down or up as
// needed to match the call site.
//
if (calleeWeight == BB_ZERO_WEIGHT)
{
JITDUMP(" ... callee entry count %f is less than call site count %f\n", calleeWeight, callSiteWeight);
JITDUMP(" ... callee entry count is zero\n");
impInlineInfo->profileScaleState = InlineInfo::ProfileScaleState::UNAVAILABLE;
return;
}

// Hence, scale is always in the range (0.0...1.0] -- we are always scaling down callee counts.
// Hence, scale can be somewhat arbitrary...
//
const double scale = ((double)callSiteWeight) / calleeWeight;
impInlineInfo->profileScaleFactor = scale;
Expand Down