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

Use a more exact base class for considerGuardedDevirtualization #108497

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Oct 2, 2024

An attempt to address #108471 (comment)

@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 Oct 2, 2024
Copy link
Contributor

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

@EgorBo

This comment was marked as resolved.

This comment was marked as resolved.

@EgorBo
Copy link
Member Author

EgorBo commented Oct 3, 2024

/azp run runtime-nativeaot-outerloop, runtime-coreclr pgo, runtime-coreclr libraries-pgo, runtime-coreclr pgostress

Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@EgorBo
Copy link
Member Author

EgorBo commented Oct 3, 2024

@MihuBot

@MichalStrehovsky
Copy link
Member

I ran a rt-sz run on this: MichalStrehovsky/rt-sz#74 (comment)

This is a size regression but for good reasons. You can grab the before/after binaries from here: https://github.com/MichalStrehovsky/rt-sz/actions/runs/11158038241

I fed the webapiaot to Ghidra and then exported the analysis to BinDiff format and ran BinDiff on it to spot check the diffs. They are in the expected two categories - no longer devirtualizing things that were apparently impossible, and newly devirtualizing things that weren't.

The newly devirtualized cases look interesting. For example, I'm looking at a devirtualized IDisposable.Dispose. Previously if RyuJIT was asking who implements IDisposable.Dispose, it would get tons of answers to the point it's not useful. However if we restrict this to some known type, this seems to work better.

If you want to have a look, I'm putting the binexport files here:

baseline.zip
compare.zip

You shouldn't need Ghidra for this, just download the latest BinDiff and these two binexport files and create a new diff from them.

@EgorBo
Copy link
Member Author

EgorBo commented Oct 3, 2024

@MichalStrehovsky thanks for looking into diffs! took a quick look at the diffs in BinDiff (TIL) 🙂

I was not able to detect any impact on CoreCLR as expected (presumably) since PGO tells us exactly what to choose and we never omit GDV checks for CoreCLR.

PTAL @AndyAyersMS @dotnet/jit-contrib

@EgorBo EgorBo marked this pull request as ready for review October 3, 2024 18:21
@@ -8175,7 +8175,13 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
return;
}

considerGuardedDevirtualization(call, ilOffset, isInterface, baseMethod, baseClass, pContextHandle);
CORINFO_CLASS_HANDLE moreExactBaseClass = baseClass;
if (objClass != NO_CLASS_HANDLE)
Copy link
Member

Choose a reason for hiding this comment

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

Don't we already know objClass is not null here?

Copy link
Member Author

@EgorBo EgorBo Oct 4, 2024

Choose a reason for hiding this comment

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

Don't we already know objClass is not null here?

Yep, you're correct, removed the condition. Looks like it's not needed to do isMoreSpecific here (and it won't work for the Michal's case since one of the classes doesn't exist in fact).

@AndyAyersMS
Copy link
Member

PGO stress failures look like #108360

@JulieLeeMSFT JulieLeeMSFT added this to the 10.0.0 milestone Oct 4, 2024
@JulieLeeMSFT
Copy link
Member

Do we need to backport this?

@AndyAyersMS
Copy link
Member

Do we need to backport this?

It is a missed optimization, so I would guess doesn't meet the bar.

@EgorBo EgorBo merged commit 6f4add8 into dotnet:main Oct 8, 2024
106 of 108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

4 participants