Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Performance: Remove pragma[noopt]#549

Merged
smowton merged 1 commit intogithub:mainfrom
edoardopirovano:change-pragma
Jun 22, 2021
Merged

Performance: Remove pragma[noopt]#549
smowton merged 1 commit intogithub:mainfrom
edoardopirovano:change-pragma

Conversation

@edoardopirovano
Copy link
Copy Markdown
Contributor

As @adityasharad pointed out on Slack, my solution of adding pragma[noopt] on #547 was perhaps a bit too drastic a way to get the right join order. This changes to use pragma[only_bind_into] instead, which means that other potential optimisations that the compiler might want to do will not be inhibited, and we still get the desired join order with the new optimiser.

cc. @github/codeql-core

expr = nd.asExpr() and
this.checks(expr, branch) and
exists(boolean branch |
this.checks(nd.asExpr(), branch) and
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You previously factored this out in the noopt version. Do you need the pragma for the first argument of checks here, or does it perform fine without?

Copy link
Copy Markdown
Contributor Author

@edoardopirovano edoardopirovano Jun 22, 2021

Choose a reason for hiding this comment

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

The factoring out was to get the QL to compile as when using pragma[noopt] you have to fully specify the join order. It was not important for performance and, therefore, if we don't use that pragma and aren't required to do it we can use the neater QL where it is inlined.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah! Got it. Indeed noopt cannot handle the inline expressions. Thanks for the explanation :)

Comment on lines +1180 to +1181
p.checkOn(pragma[only_bind_into](check), outcome, resNode) and
guard.ensures(pragma[only_bind_into](check), outcome)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you observe a performance problem without these last two pragmas? The previous change you made didn't touch the checkOn and ensures calls.
Attaching the pragma to both uses of a variable (here check) looks off to me, because the way I think of it, at least one place must be allowed to bind check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I might be misunderstanding the direction the pragma applies in, but isn't it the case that check is still being bound, but we aren't getting binding information out of check? In any case, I've done some profiling and it looks like the pragma on checkOn isn't essential for performance. The one on ensures, however, is - without it the evaluation time for this predicate jumps from 12.9s to 18.3s.

@smowton smowton merged commit cd1e14e into github:main Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants