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

optimize "manager wide" constant rewriting #159

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

paulcacheux
Copy link
Contributor

What does this PR do?

Most constant editors are actually "manager wide", meaning that they target all programs under a given manager. Currently when rewriting this kind of constants we iterator over all constant entries, then for each program we create an editor that does the edition. The issue is that creating an editor iterates over all instructions searching for "references", and thus we do a lot of repetitive work (and it's starting to show up in profiles, especially in test profiles were we continuously restart the manager).

To improve this situation this PR reverses the order of iteration for "manager wide" constants by creating an editor only once per program.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Describe how to test your changes

Write here in detail how you have tested your changes and instructions on how this should be tested.

@paulcacheux paulcacheux requested a review from a team as a code owner November 6, 2023 21:30

// Apply to all programs if no section was provided
for section, prog := range m.collectionSpec.Programs {
edit := newEditor(&prog.Instructions)
Copy link
Member

Choose a reason for hiding this comment

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

Should we wait to allocate this until we know there are constant editors that apply to all programs?

Copy link
Member

Choose a reason for hiding this comment

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

I think lazy-allocation would be sufficient, waiting until both continue statements have been passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, should be good in the latest commit

@paulcacheux paulcacheux merged commit 28b5743 into main Nov 8, 2023
3 checks passed
@paulcacheux paulcacheux deleted the paulcacheux/speedup-constant-editors branch November 8, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants