Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lcartey merged 2 commits intogithub:mainfromsmowton:smowton/fix/same-source-perf
Jun 6, 2025

Conversation

smowton
Copy link
Contributor

@smowtonsmowton commentedJun 4, 2025
edited by lcartey
Loading

Description

User atgithub/codeql#19633 observed thatsameSource could be a potentially-large cost in running thecodeql/cert-c-coding-standards@2.45.0 suite.

I noticed that while the inline pragma made clear that the intent was never to materialisesameSource 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 toinline_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

  • 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:
    • 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:

  • 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 ofshared 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 thestyle 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 thestyle 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!)

@CopilotCopilotAI review requested due to automatic review settingsJune 4, 2025 11:26
Copy link
Contributor

@CopilotCopilotAI 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 addresses performance issues in thesameSource predicate by preventing premature inlining and constraining its bindings.

  • Switches frominline toinline_late to avoid heavy common-subexpression expansion
  • Adds abindingset[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 thatinline_late is used to prevent early inlining and avoid expensive common-subexpression optimizations that degrade performance.
pragma[inline_late]

@smowtonsmowtonforce-pushed thesmowton/fix/same-source-perf branch from1d2a7f2 to985a2d1CompareJune 4, 2025 11:28
@lcartey
Copy link
Collaborator

/test-performance

@github-actionsGitHub Actions
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!

@codeql-coding-standards-automationCodeQL Coding Standards Automation

🏁 Beep Boop! Performance testing complete! See below for performance of the last 3 runs vs your PR. Times are based on predicate performance. You canfind full graphs and stats in the PR that was created for this test in the release engineering repo.

Release                            : v2.44.0Platform                           : x86-linuxLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2569320Mean_Predicate_Execution_Time_Ms   : 47.18764348289225Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 623.3848493198769Total_Serialized_Execution_Time_s  : 2569.32Mean_Query_Execution_Time_s        : 0.0471876434828922Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 115.0Number_of_Predicates               : 54449Release                            : v2.44.0Platform                           : x86-linuxLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 2890004Mean_Predicate_Execution_Time_Ms   : 57.72042581237892Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 583.4436271796267Total_Serialized_Execution_Time_s  : 2890.004Mean_Query_Execution_Time_s        : 0.0577204258123789Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 148.0Number_of_Predicates               : 50069Release                            : v2.44.0Platform                           : x86-windowsLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2843064Mean_Predicate_Execution_Time_Ms   : 52.82443655822077Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 555.7550278554764Total_Serialized_Execution_Time_s  : 2843.064Mean_Query_Execution_Time_s        : 0.0528244365582207Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 157.0Number_of_Predicates               : 53821Release                            : v2.44.0Platform                           : x86-windowsLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 3041503Mean_Predicate_Execution_Time_Ms   : 60.87876301040833Median_Predicate_Execution_Time_Ms : 1.0Standard_Deviation_Ms              : 552.5159941493636Total_Serialized_Execution_Time_s  : 3041.503Mean_Query_Execution_Time_s        : 0.0608787630104083Median_Predicate_Execution_Time_s  : 0.001Percentile95_Ms                    : 182.04999999999563Number_of_Predicates               : 49960Release                            : v2.45.0Platform                           : x86-linuxLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2581075Mean_Predicate_Execution_Time_Ms   : 47.971805070255Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 620.328032025375Total_Serialized_Execution_Time_s  : 2581.075Mean_Query_Execution_Time_s        : 0.047971805070255Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 117.0Number_of_Predicates               : 53804Release                            : v2.45.0Platform                           : x86-linuxLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 2908122Mean_Predicate_Execution_Time_Ms   : 58.0788065186132Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 584.9817986910139Total_Serialized_Execution_Time_s  : 2908.122Mean_Query_Execution_Time_s        : 0.0580788065186132Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 152.0Number_of_Predicates               : 50072Release                            : v2.45.0Platform                           : x86-windowsLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2872385Mean_Predicate_Execution_Time_Ms   : 53.41785687718515Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 560.427241699905Total_Serialized_Execution_Time_s  : 2872.385Mean_Query_Execution_Time_s        : 0.0534178568771851Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 148.0Number_of_Predicates               : 53772Release                            : v2.45.0Platform                           : x86-windowsLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 3013661Mean_Predicate_Execution_Time_Ms   : 59.78062762834246Median_Predicate_Execution_Time_Ms : 1.0Standard_Deviation_Ms              : 532.4892044266705Total_Serialized_Execution_Time_s  : 3013.661Mean_Query_Execution_Time_s        : 0.0597806276283424Median_Predicate_Execution_Time_s  : 0.001Percentile95_Ms                    : 176.0Number_of_Predicates               : 50412Release                            : 907Platform                           : x86-linuxLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 2901541Mean_Predicate_Execution_Time_Ms   : 57.87340434019467Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 583.4013893033987Total_Serialized_Execution_Time_s  : 2901.541Mean_Query_Execution_Time_s        : 0.0578734043401946Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 148.0Number_of_Predicates               : 50136Release                            : 907Platform                           : x86-linuxLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2583105Mean_Predicate_Execution_Time_Ms   : 48.17158681908882Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 664.5607043823868Total_Serialized_Execution_Time_s  : 2583.105Mean_Query_Execution_Time_s        : 0.0481715868190888Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 112.0Number_of_Predicates               : 53623

🏁 Below are the slowest predicates for the last 2 releases vs this PR.

Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : UnusedVariables::maybeACompileTimeTemplateArgument/1#9ea118f0Execution_Time_Ms : 55520Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 44262Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236Execution_Time_Ms : 38541Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Call::FunctionCall#2b14a517_Call::FunctionCall.getTarget/0#dispred#935da4c5_Function::Function.getP__#antijoin_rhsExecution_Time_Ms : 27633Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4_Preproce__#antijoin_rhsExecution_Time_Ms : 55790Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4_Preproce__#antijoin_rhsExecution_Time_Ms : 49143Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236Execution_Time_Ms : 35851Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 39037Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : _Declaration::Declaration.getADeclarationEntry/0#dispred#c5d61b67_Declaration::DeclarationEntry.isDe__#antijoin_rhsExecution_Time_Ms : 23932Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : UnusedVariables::maybeACompileTimeTemplateArgument/1#9ea118f0Execution_Time_Ms : 66556Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _ExternalFlow::elementSpecMatchesSignature/6#c67d3446_Function::Function.getClassAndName/1#27b7404e___#sharedExecution_Time_Ms : 64202Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#sharedExecution_Time_Ms : 24718Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : _ExternalFlow::elementSpecMatchesSignature/6#c67d3446_Function::Function.getClassAndName/1#27b7404e___#sharedExecution_Time_Ms : 58913Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : _ExternalFlow::elementSpecMatchesSignature/6#c67d3446_Function::Function.getClassAndName/1#27b7404e___#sharedExecution_Time_Ms : 29274Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : #selectExecution_Time_Ms : 17217Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : FunctionEquivalence::typeSig/1#194ac728Execution_Time_Ms : 18465Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42Execution_Time_Ms : 33253Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : _ExternalFlow::elementSpecMatchesSignature/6#c67d3446_Function::Function.getClassAndName/1#27b7404e___#sharedExecution_Time_Ms : 27541Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9Execution_Time_Ms : 32664Release           : v2.45.0Run               : 2025-05-21_14-04-43Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : _Declaration::Declaration.getADeclarationEntry/0#dispred#c5d61b67_Declaration::DeclarationEntry.isDe__#antijoin_rhsExecution_Time_Ms : 31231Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : _Declaration::Declaration.getADeclarationEntry/0#dispred#c5d61b67_Declaration::DeclarationEntry.isDe__#antijoin_rhsExecution_Time_Ms : 32487Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : CheckedException::CheckedException#b0aa5ec8Execution_Time_Ms : 28314Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9Execution_Time_Ms : 30298Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42Execution_Time_Ms : 29719Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : UnusedVariables::maybeACompileTimeTemplateArgument/1#9ea118f0Execution_Time_Ms : 54479Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4_Preproce__#antijoin_rhsExecution_Time_Ms : 60969Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _ExternalFlow::elementSpecMatchesSignature/6#c67d3446_Function::Function.getClassAndName/1#27b7404e___#sharedExecution_Time_Ms : 59181Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 55842Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236Execution_Time_Ms : 38484Release           : 907Run               : 2025-06-04_11-36-33Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#sharedExecution_Time_Ms : 28937

@MichaelRFairhurst
Copy link
Contributor

Performance results appear reasonable to me.

@lcarteylcarteyenabled auto-mergeJune 6, 2025 09:52
@lcarteylcartey added this pull request to themerge queueJun 6, 2025
Merged via the queue intogithub:main with commit42985d7Jun 6, 2025
21 checks passed
@MichaelRFairhurst
Copy link
Contributor

Thank you@smowton ! 🎉 🎉 🎉

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@lcarteylcarteylcartey approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@smowton@lcartey@MichaelRFairhurst

[8]ページ先頭

©2009-2025 Movatter.jp