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

PGO Inlining Policy #43914

Closed
AndyAyersMS opened this issue Oct 27, 2020 · 5 comments
Closed

PGO Inlining Policy #43914

AndyAyersMS opened this issue Oct 27, 2020 · 5 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@AndyAyersMS
Copy link
Member

Implement an inlining policy that takes PGO data more directly into account.

The general heuristic for an inline should be something like:

Cost = code size impact (may be negative)
Benefit = (global importance) * (local importance) * (per-call benefit)

Inline if:
   Cost <= 0                ;; inline is "free"
   Benefit/Cost > threshold ;; code size growth is justified by perf win

Global importance is somehow related to how often the root method is called. Perhaps non-linear, say 
  max(1, log10(#calls/10,000)) + 1

Local importance is the normalized execution count of the call site, that is
   call site count / method entry count

Per call benefit is related to the likelihood of callee specialization / caller benefit
   roughly how many cycles are saved per call by doing the inline

Suggest we start with the ModelPolicy which already has most of this structure, and amend/modify/clone it. Make the threshold adjustable and start to experiment.

We can use the size estimates that it produces as that seemed fairly accurate (in particular pretty good at predicting size-decreasing inlines).

Perhaps leave off global importance for now as we can't necessarily infer from TieredPGO how often a method is called, the value will depend in part on the rate of promotion to Tier1. So low method entry count may just mean the method got tiered up quickly (on the other hand, a high count does mean the method is called a lot).

@AndyAyersMS AndyAyersMS added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 27, 2020
@AndyAyersMS AndyAyersMS added this to the 6.0.0 milestone Oct 27, 2020
@AndyAyersMS AndyAyersMS self-assigned this Oct 27, 2020
@AndyAyersMS AndyAyersMS added this to Needs Triage in .NET Core CodeGen via automation Oct 27, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Oct 27, 2020
@AndyAyersMS AndyAyersMS moved this from Needs Triage to PGO in .NET Core CodeGen Oct 27, 2020
@AndyAyersMS AndyAyersMS moved this from PGO to In progress in .NET Core CodeGen Oct 27, 2020
@AndyAyersMS AndyAyersMS mentioned this issue Oct 27, 2020
54 tasks
@AndyAyersMS AndyAyersMS removed the untriaged New issue has not been triaged by the area owner label Oct 27, 2020
@AndyAyersMS
Copy link
Member Author

Prototyping on this branch.

@AndyAyersMS
Copy link
Member Author

Preliminary version added in #44427. Still needs a fair bit of work.

@AndyAyersMS
Copy link
Member Author

@EgorBo is going to work on inlining enhancements for PGO, so assigning this over to him.

@AndyAyersMS AndyAyersMS assigned EgorBo and unassigned AndyAyersMS Apr 8, 2021
@EgorBo
Copy link
Member

EgorBo commented Jul 12, 2021

I believe we can close it as we now take PGO data into account:
#52708
#53670
#55096
#55478

Or we can leave it open for future enhancements?

@AndyAyersMS
Copy link
Member Author

Inlining is never done, but yes I think we can close this.

.NET Core CodeGen automation moved this from In progress to Done Jul 12, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 11, 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
Archived in project
Development

No branches or pull requests

3 participants