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: Optimize aggregate info iteration in physical promotion #87997

Merged

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Jun 24, 2023

In several places we have to iterate over all promoted aggregates. This was less efficient than it has to be because we stored aggregate information in a flat array indexed by local number, and the vast majority of locals are not physically promoted. This change introduces an AggregateInfoMap that stores just the promoted aggregates, and additionally stores an array mapping locals to the promoted aggregates.

This does mean that we need a two level lookup to map a local number back to its aggregate information, but that still seems better for throughput than the previous behavior.

A few minor diffs expected since this means new induced promotions are added at the end of the list, which can cause different ordering when writebacks for them are inserted.

In several places we have to iterate over all promoted aggregates. This
was less efficient than it has to be because we stored aggregate
information in a flat array indexed by local number, and the vast
majority of locals are not physically promoted. This change introduces
an AggregateInfoMap that stores just the promoted aggregates, and
additionally stores an array mapping locals to the promoted aggregates.

This does mean that we need a two level lookup to map a local number
back to its aggregate information, but that still seems better for
throughput than the previous behavior.
@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 Jun 24, 2023
@ghost ghost assigned jakobbotsch Jun 24, 2023
@ghost
Copy link

ghost commented Jun 24, 2023

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

Issue Details

In several places we have to iterate over all promoted aggregates. This was less efficient than it has to be because we stored aggregate information in a flat array indexed by local number, and the vast majority of locals are not physically promoted. This change introduces an AggregateInfoMap that stores just the promoted aggregates, and additionally stores an array mapping locals to the promoted aggregates.

This does mean that we need a two level lookup to map a local number back to its aggregate information, but that still seems better for throughput than the previous behavior.

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

Comment on lines -85 to -86
// TODO: We need a scalability limit on these, we cannot always track
// the remainder and all fields.
Copy link
Member Author

Choose a reason for hiding this comment

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

This was fixed in #87729 by limiting the total number of promotions we make.

Comment on lines +430 to -372
access->Count++;
access->CountWtd += weight;
INDEBUG(access->Count++);
Copy link
Member Author

Choose a reason for hiding this comment

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

Missed this one in #87969. It would cause checked/release diffs.

@jakobbotsch jakobbotsch marked this pull request as ready for review June 24, 2023 18:05
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @EgorBo

Diffs with physical promotion. ASM diffs due to what I mentioned above, where we now insert some readbacks/writebacks in a different order. Other than that just some decent TP improvements.

@jakobbotsch jakobbotsch requested a review from EgorBo June 26, 2023 12:29
// Pointer to the aggregate information, or nullptr if the local is not
// physically promoted.
//
AggregateInfo* AggregateInfoMap::Lookup(unsigned lclNum)
Copy link
Member

Choose a reason for hiding this comment

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

When I saw Lookup I thought that your map of aggregates is a hash set 🙂

Copy link
Member

@EgorBo EgorBo left a comment

Choose a reason for hiding this comment

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

nice tp wins!

@jakobbotsch jakobbotsch merged commit 5ab0b7c into dotnet:main Jun 27, 2023
@jakobbotsch jakobbotsch deleted the physical-promotion-aggregate-access-tp branch June 27, 2023 14:06
@ghost ghost locked as resolved and limited conversation to collaborators Jul 27, 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