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: Use fgCalledCount in inlinee weight computation #112499

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

amanasifkhalid
Copy link
Member

I noticed that tweaking the computation of the entry weight for OSR methods (in service of #111915) incurred large inlining diffs. This is due to the fact that we use the entry block's weight to compute the normalized weight of a call site. This means we will get the wrong normalized weight for call sites when the entry block's weight diverges from the method's call count. This is currently possible only when the entry block is part of a loop, or when we compute a weight for the OSR entry fixup block that differs from fgCalledCount (which we almost always do). The correct thing to do is to use the root method's call count to normalize the call site's weight.

@Copilot Copilot bot review requested due to automatic review settings February 12, 2025 20:40

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

Files not reviewed (1)
  • src/coreclr/jit/importer.cpp: Language not supported
@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 Feb 12, 2025
Copy link
Contributor

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

@amanasifkhalid
Copy link
Member Author

@dotnet/jit-contrib PTAL. Diffs seem to be only in OSR methods. In the cases where we're now doing less inlining, the OSR loop's execution count is less than 100x the method call count; the opposite is true for cases where we're doing more inlining. With this change, we're doing fewer inlines overall. Thanks!

@amanasifkhalid
Copy link
Member Author

@AndyAyersMS could you PTAL? Thanks!

@amanasifkhalid
Copy link
Member Author

ping @AndyAyersMS

@amanasifkhalid amanasifkhalid merged commit c37cfcc into dotnet:main Feb 18, 2025
112 checks passed
@amanasifkhalid amanasifkhalid deleted the fix-inlinee-weight-comp branch February 18, 2025 17:26
amanasifkhalid added a commit that referenced this pull request Feb 19, 2025
Follow-up to #112499. By ensuring OSR method entry blocks' weights match fgCalledCount during entry canonicalization, we can guarantee that later runs of profile synthesis won't modify fgCalledCount. This should unblock #111915 (comment).
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.

2 participants