Fix bad joins on function names and unnecessarily large relation on integer constant macros#933
Conversation
…nteger constant macros
There was a problem hiding this comment.
Pull Request Overview
This PR fixes performance issues in CodeQL queries when upgrading to version 2.20.7 by optimizing join operations and reducing unnecessary constraints.
- Removes unnecessary name matching checks in function declaration comparisons that were affecting join order performance
- Adds a
bindingsetannotation to improve performance when checking integer constant macro sizes - Refactors query structure to use module aliases for better readability
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| change_notes/2025-7-15-fix-performance-issues-in-2.20.7.md | Documents the performance fixes for the three affected rules |
| c/misra/src/rules/RULE-8-4/CompatibleDeclarationFunctionDefined.ql | Removes name matching constraint and refactors to use module alias |
| c/misra/src/rules/RULE-7-5/IncorrectlySizedIntegerConstantMacroArgument.ql | Adds bindingset annotation to improve literal matching performance |
| c/cert/src/rules/DCL40-C/IncompatibleFunctionDeclarations.ql | Removes name matching constraint and refactors predicate structure |
| @@ -0,0 +1,4 @@ | |||
| - `DCL40-C`, `RULE-8-4`: `IncompatibleFunctionDeclarations.ql`, `CompatibleDeclarationFunctionDefined.ql`. | |||
There was a problem hiding this comment.
The file name format suggests a date of July 15, 2025 (2025-7-15), but the standard format should use two-digit months (2025-07-15).
|
/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. |
|
@lcartey Looks like our performance test infrastructure didn't like that this isn't merging into main, so we don't have performance results here. |
|
Thanks! We can test performance on the dist upgrade branch. |
Description
Performance fixes to upgrade to 2.20.7.
Note: I ran a check in the top 100 to find cases of
interestedInFunctions(f1, f2)wheref1andf2had different names and found no matches.Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-7-5,RULE-8-4,DCL40-CRelease 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.