-
Notifications
You must be signed in to change notification settings - Fork 67
Fix poor performance of sameSource predicate #907
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses performance issues in the sameSource
predicate by preventing premature inlining and constraining its bindings.
- Switches from
inline
toinline_late
to avoid heavy common-subexpression expansion - Adds a
bindingset[a, b]
directive to limit predicate instantiations
Comments suppressed due to low confidence (1)
cpp/common/src/codingstandards/cpp/rules/iofstreammissingpositioning/IOFstreamMissingPositioning.qll:54
- [nitpick] Consider adding a comment above this pragma to explain that
inline_late
is used to prevent early inlining and avoid expensive common-subexpression optimizations that degrade performance.
pragma[inline_late]
...on/src/codingstandards/cpp/rules/iofstreammissingpositioning/IOFstreamMissingPositioning.qll
Show resolved
Hide resolved
1d2a7f2
to
985a2d1
Compare
/test-performance |
🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute. |
🏁 Beep Boop! Performance testing complete! See below for performance of the last 3 runs vs your PR. Times are based on predicate performance. You can find full graphs and stats in the PR that was created for this test in the release engineering repo.
🏁 Below are the slowest predicates for the last 2 releases vs this PR.
|
Performance results appear reasonable to me. |
Thank you @smowton ! 🎉 🎉 🎉 |
Description
User at github/codeql#19633 observed that
sameSource
could be a potentially-large cost in running thecodeql/[email protected]
suite.I noticed that while the inline pragma made clear that the intent was never to materialise
sameSource
in its entirety but rather only to identify if two file-accesses referred to the same source once the two candidates had been otherwise constrained, in practice a common-subexpression pass was lifting the general square of all possibly-aliasing file accesses into a#shared
predicate.Switching to
inline_late
instead defeats this potential misoptimisation, and at least for the linked discussion makes the suite once again run on a practical timescale.Change request type
.ql
,.qll
,.qls
or unit tests)Rules with added or modified queries
FIO39-C
FIO50-CPP
A27-0-3
RULE-30-0-2
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.