Skip to content

Fix bad joins on function names and unnecessarily large relation on integer constant macros #933

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

MichaelRFairhurst
Copy link
Contributor

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) where f1 and f2 had different names and found no matches.

Change request type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules with added or modified queries

  • No rules added
  • Queries have been added for the following rules:
    • rule number here
  • Queries have been modified for the following rules:
    • RULE-7-5, RULE-8-4, DCL40-C

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
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.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

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

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

@Copilot Copilot AI review requested due to automatic review settings July 16, 2025 04:00
Copy link
Contributor

@Copilot Copilot AI left a 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 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 bindingset annotation 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`.
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.

@MichaelRFairhurst
Copy link
Contributor Author

/test-performance

Copy link

🏁 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.

💡 If you do not hear back from me please check my status! I will report even if I fail!

@MichaelRFairhurst
Copy link
Contributor Author

@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.

@lcartey lcartey merged commit 84a0ed5 into codeql/upgrade-to-2.20.7 Jul 16, 2025
@lcartey lcartey deleted the michaelrfairhurst/performance-fixes-upgrading-to-2.20.7 branch July 16, 2025 16:27
@lcartey
Copy link
Collaborator

lcartey commented Jul 16, 2025

Thanks! We can test performance on the dist upgrade branch.

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