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: Adjust physical promotion heuristics #86660

Merged
merged 3 commits into from
May 25, 2023

Conversation

jakobbotsch
Copy link
Member

Adjust the heuristics to take into account recent work on liveness and assignment decomposition. Stop phrasing things in terms of code size (multiplied by basic block weights, which does not make sense).

Adjust the heuristics to take into account recent work on liveness and
assignment decomposition.  Stop phrasing things in terms of code size
(multiplied by basic block weights, which does not make sense).
@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 23, 2023
@ghost ghost assigned jakobbotsch May 23, 2023
@ghost
Copy link

ghost commented May 23, 2023

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

Issue Details

Adjust the heuristics to take into account recent work on liveness and assignment decomposition. Stop phrasing things in terms of code size (multiplied by basic block weights, which does not make sense).

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS. First round of adjustments, might dial some of this in more later (specifically related to no costing for assignments with overlapped structs, I need to come up with a good way of costing).

Diffs with physical promotion

Diffs without old promotion. -6.6 MB on win-x64 over the old heuristics

// TODO-CQ: We can make much better guesses on what will and won't be contained.
costWithout += access.CountWtd * 6.5;
// We cost any normal access (which is a struct load or store) without promotion at 3 cycles.
costWithout += access.CountWtd * 3;
Copy link
Member

Choose a reason for hiding this comment

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

Consider making all these weight factors symbolic so later on we can vary them more readily.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, I was initially using the perfscore constants here but noticed some oddities (e.g. stack writes are cheaper on arm64 than stack reads but they are the same cost for xarch). I can add some names the next time around.

// fields we are promoting together, evaluating all of them at once in
// comparison with the covering struct uses. This will also allow us to
// give a bonus to promoting remainders that may not have scalar uses
// but will allow fully decomposing assignments away.
Copy link
Member

Choose a reason for hiding this comment

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

Sounds ambitious, but I like the idea of costing things as sets.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, hopefully I can approximate this in a simple/cheap way. But I think I will approach this by writing down an integer linear programming form of the problem and see if it gives me any insights.

@jakobbotsch jakobbotsch merged commit 177fd7f into dotnet:main May 25, 2023
@jakobbotsch jakobbotsch deleted the physical-promotion-heuristics branch May 25, 2023 09:08
@ghost ghost locked as resolved and limited conversation to collaborators Jun 24, 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