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: pgo/devirt diagnostic improvements #53247

Merged
merged 3 commits into from
May 26, 2021

Conversation

AndyAyersMS
Copy link
Member

Several changes to help better diagnose PGO and devirtualization issues:

  • Report the source of the PGO data to the jit
  • Report the reason for a devirtualization failure to the jit
  • Add checking mode that compares result of devirtualzation to class profile
  • Add reporting mode to assess overall rates of devirtualization failure
    when the jit has exact type information.

Also fix a loophole where in some case we'd still devirtualize if not
optimizing.

Note crossgen2 does not yet set devirtualization failure reasons.

Several changes to help better diagnose PGO and devirtualization issues:
* Report the source of the PGO data to the jit
* Report the reason for a devirtualization failure to the jit
* Add checking mode that compares result of devirtualzation to class profile
* Add reporting mode to assess overall rates of devirtualization failure
  when the jit has exact type information.

Also fix a loophole where in some case we'd still devirtualize if not
optimizing.

Note crossgen2 does not yet set devirtualization failure reasons.
@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 May 25, 2021
@AndyAyersMS
Copy link
Member Author

cc @dotnet/jit-contrib @davidwrighton

A lot of files touched as I've modified 2 apis on the jit interface. No diffs (per PMI).

//
CORINFO_METHOD_HANDLE devirtualizedMethod;
bool requiresInstMethodTableArg;
CORINFO_CONTEXT_HANDLE exactContext;
const char* failureReason;
Copy link
Member

Choose a reason for hiding this comment

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

Please describe the memory behavior of this pointer. In particular, is it expected to be remain across multiple calls to resolveVirtulaMethod?

Also, superpmi is not currently storing/restoring this value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently it is only used immediately after the call.

I suppose it would be simpler to make it an enum. I made it a string because I anticipated there would be a lot of churn as we evolve this and didn't want to also have to rev the jit interface each time.

I don't expect actual behavior of the jit to depend on this -- it is just there for diagnostics -- so perhaps an enum with an understanding that a given jit build might see values outside its known enum range will work.

Copy link
Member

Choose a reason for hiding this comment

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

A string is a fine choice. I just want to document its memory behavior, and used directly after the call is a simple and fairly common behavior in the jit interface. The only concern is that handling of strings across the managed/native boundary needs to have some care taken around object lifetime, etc, and writing down the contract is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I went ahead and changed it over to an enum, it's simple for SPMI to deal with.

@AndyAyersMS
Copy link
Member Author

Running Pri1 tests with

set COMPlus_ReadyToRun=0
set COMPlus_TieredCompilation=0
set COMPlus_JitNoteFailedExactDevirtualization=1

gives the following exact class devirt failure breakdown:

reason count
object class could not be cast to interface class 2799
virtual method installed via explicit override 158
devirtualization crossed version bubble 36
interface method was default interface method 7
interface method could not be found 6

Many of the failures in of that first category are cases where we have a shared interface method.

@AndyAyersMS AndyAyersMS merged commit 7f090c3 into dotnet:main May 26, 2021
@AndyAyersMS AndyAyersMS deleted the DevirtPgoCrossValidate branch May 26, 2021 15:56
@AndyAyersMS AndyAyersMS mentioned this pull request Jun 1, 2021
54 tasks
@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2021
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