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

Do not check for shadowing repeatedly in inlining passes. #4396

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

kfcripps
Copy link
Contributor

@kfcripps kfcripps commented Feb 5, 2024

We found that checking shadowing in ResolveReferences was a big bottleneck for one of our apps, and it is done each time an inlining pass is repeated. We turned this off and added a new ResolveReferences pass to check shadowing after all inlining is completed. This greatly helped to speed up these passes, which were taking the longest.

Compilation times for one of our apps without these changes:

real    22m7.669s
user    21m55.887s
sys     0m14.823s

and with them:

real    16m36.850s
user    16m24.559s
sys     0m15.304s

@kfcripps
Copy link
Contributor Author

kfcripps commented Feb 5, 2024

tagging @asl @fruffy

@fruffy fruffy requested review from grg and hanw February 5, 2024 23:14
@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Feb 5, 2024
@@ -51,9 +51,7 @@ class ActionsInliner : public AbstractInliner<ActionsInlineList, AInlineWorkList
std::map<const IR::MethodCallStatement *, const IR::P4Action *> *replMap;

public:
explicit ActionsInliner(bool isv1) : refMap(new P4::ReferenceMap()), replMap(nullptr) {
refMap->setIsV1(isv1);
Copy link
Collaborator

@fruffy fruffy Feb 7, 2024

Choose a reason for hiding this comment

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

Any reason why you are removing the isv1 check here and in other places? I think we should deprecated that strange feature eventually but it seems like you may change some semantics here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is because the ReferenceMap being passed in already has the isv1 flag set appropriately.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yeah, makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's correct.

Copy link
Collaborator

@fruffy fruffy left a comment

Choose a reason for hiding this comment

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

@grg Any concerns on this PR?

@kfcripps kfcripps enabled auto-merge (squash) February 12, 2024 00:31
@kfcripps kfcripps merged commit 02f89f7 into p4lang:main Feb 12, 2024
16 checks passed
@kfcripps kfcripps added the compiler-performance Topics on improving the performance of the compiler core. label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-performance Topics on improving the performance of the compiler core. core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants