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

Fix inline decision reporting + noinline propagation #87115

Merged
merged 3 commits into from
Jun 8, 2023

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jun 4, 2023

In #86551 I broke reporting of inline decisions, it led to two problems:

  1. Less informative JitDump for inline decisions
  2. We stopped marking methods with "noinline" attribute if we fail to inline them for various reasons.

The 2nd led to interesting effects - lots of benchmarks improved: #86902 (comment) (some regressed).

so I am fixing this back but also - extending the "allow list" in PropagateNeverToRuntime to not to propagate some specific inline decisions if they might depend on a call-site to avoid regressing other call-sites where context is different.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 4, 2023
@ghost ghost assigned EgorBo Jun 4, 2023
@ghost
Copy link

ghost commented Jun 4, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

In #86551 I broke reporting of inline decisions, it led to two problems:

  1. Less informative JitDump for inline decisions
  2. We stopped marking methods with "noinline" attribute if we fail to inline them for various reasons.

The 2nd led to interesting effects - lots of benchmarks improved: #86902 (comment) (some regressed).

so I am fixing this back but also - extending the "allow list" in PropagateNeverToRuntime to not to propagate some specific inline decisions if they might depend on a call-site to avoid regressing other call-sites where context is different.

Author: EgorBo
Assignees: EgorBo
Labels:

area-CodeGen-coreclr

Milestone: -

@EgorBo EgorBo marked this pull request as ready for review June 5, 2023 10:32
@EgorBo EgorBo requested a review from AndyAyersMS June 5, 2023 10:32
@EgorBo
Copy link
Member Author

EgorBo commented Jun 5, 2023

@AndyAyersMS PTAL, we talked about this last week
cc @dotnet/jit-contrib

@@ -6280,12 +6280,6 @@ void Compiler::impMarkInlineCandidate(GenTree* callNode,
{
if (!opts.OptEnabled(CLFLG_INLINING))
{
/* XXX Mon 8/18/2008
Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like the comment doesn't add a lot of value


// Do the actual evaluation
impMarkInlineCandidateHelper(call, candidateId, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo,
ilOffset, &inlineResult);
inlineResult.Report();
Copy link
Member Author

@EgorBo EgorBo Jun 5, 2023

Choose a reason for hiding this comment

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

Calls Report explicitly instead of relying on destructor

Copy link
Member

Choose a reason for hiding this comment

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

What went wrong with relying on the destructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted to destructor since it raised a question - I don't have a strong opinion about it

case InlineObservation::CALLEE_DOES_NOT_RETURN:
return false;

// These also depend on call-sites
case InlineObservation::CALLSITE_OVER_BUDGET:
case InlineObservation::CALLSITE_TOO_MANY_LOCALS:
Copy link
Member

Choose a reason for hiding this comment

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

CALLSITE observations shouldn't lead to "never" reports back to the VM.

Only CALLEE observations should have this effect.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, removed


// Do the actual evaluation
impMarkInlineCandidateHelper(call, candidateId, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo,
ilOffset, &inlineResult);
inlineResult.Report();
Copy link
Member

Choose a reason for hiding this comment

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

What went wrong with relying on the destructor?

impMarkInlineCandidateHelper(call, 0, exactContextHnd, exactContextNeedsRuntimeLookup, callInfo, ilOffset,
&inlineResult);
inlineResult.Report();
Copy link
Member

Choose a reason for hiding this comment

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

Ditto here -- does the destructor not work for some reason?

// These thresholds may depend on PGO data (we allow more blocks/bigger IL size
// for hot methods so we want to make sure we won't bake 'noinline' just because
// some semi-hot callsite didn't expand these thresholds).
case InlineObservation::CALLEE_TOO_MANY_BASIC_BLOCKS:
Copy link
Member

Choose a reason for hiding this comment

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

I think this will have a detrimental effect on TP as we now will repeatedly analyze even very large methods to see if they are good inline candidates. Surely there must be some size/complexity value that will disqualify a method from ever being inlined.

As an alternative, consider making the call to SetNever conditional on some higher threshold, for policies that handle these observations, eg see ProfilePolicy::NoteInt.

Copy link
Member Author

@EgorBo EgorBo Jun 7, 2023

Choose a reason for hiding this comment

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

I decided to revert these changes so I can study the TP impact separately

@EgorBo EgorBo merged commit d3ea4a9 into dotnet:main Jun 8, 2023
@EgorBo EgorBo deleted the fix-inline-report branch June 8, 2023 09:28
@ghost ghost locked as resolved and limited conversation to collaborators Jul 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants