Conversation
e203d8b to
97e2376
Compare
97e2376 to
9e43da9
Compare
... and everything else that it depends on.
None of these required any changes to the dataflow libraries, so it seemed easiest to put them in their own commit.
These were causing the repo `gufolabs/noc` to spend ~30 seconds evaluating `ControlFlowNode.strictlyDominates`. Just in case, I added `overlay[caller] to the other instances of `pragma[inline]` as well.
On `keras-team/keras`, this was producing ~200 million intermediate tuples in order to produce a total of ... 2 tuples. After the refactor, max intermediate tuple count is ~80k for the charpred (and 4 for the new helper predicate).
This caused a ~30x blowup in intermediate tuples, now back to baseline.
c949417 to
304cd12
Compare
0ca3f60 to
cd62cda
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes the CodeQL Python analysis overlay-aware by adding overlay annotations throughout the Python QL libraries. The changes enable overlay evaluation, which should significantly improve performance when a base database already exists. According to the PR description, AST, CFG, SSA, and DataFlow::Node are marked as local, while call graph-related functionality remains global.
Changes:
- Added
overlay[local],overlay[local?],overlay[global], andoverlay[caller]annotations to Python QL library modules, classes, and predicates - Introduced join-order optimization helper predicates with
pragma[nomagic]to maintain performance after overlay annotations - Added final class aliases and converted to
instanceofpatterns to enable extending overlay[local] classes from non-overlay contexts
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| python/ql/lib/change-notes/2026-02-18-add-overlay-annotations.md | Documents the overlay evaluation compatibility changes |
| python/ql/lib/semmle/python/**/*.qll | Adds overlay[local] module annotations to AST, CFG, SSA, and dataflow libraries |
| python/ql/lib/semmle/python/dataflow/new/**/*.qll | Adds overlay[local] to dataflow components and overlay[global] to call graph-related predicates |
| python/ql/lib/semmle/python/frameworks/*.qll | Adds overlay[local?] module annotations and join-order helpers to framework models |
| python/ql/lib/semmle/python/objects/TObject.qll | Adds join-order helper predicate for missing_imported_module |
| python/ql/lib/semmle/python/internal/CachedStages.qll | Adds overlay[local] to AST and DataFlow stage predicates |
| python/ql/src/analysis/ImportFailure.ql | Introduces FinalControlFlowNode alias and removes override keyword |
| python/ql/src/Variables/LoopVariableCapture/LoopVariableCaptureQuery.qll | Introduces FinalAstNode alias and converts to instanceof pattern |
| python/ql/lib/analysis/DefinitionTracking.qll | Introduces FinalExpr alias for NiceLocationExpr |
| python/ql/test/library-tests/**/*.qll | Adds overlay annotations to test helper modules |
These were causing the repo `gufolabs/noc` to spend ~30 seconds evaluating `ControlFlowNode.strictlyDominates`. Just in case, I added `overlay[caller] to the other instances of `pragma[inline]` as well.
On `keras-team/keras`, this was producing ~200 million intermediate tuples in order to produce a total of ... 2 tuples. After the refactor, max intermediate tuple count is ~80k for the charpred (and 4 for the new helper predicate).
This caused a ~30x blowup in intermediate tuples, now back to baseline.
c949417 to
304cd12
Compare
0ca3f60 to
cd62cda
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes the CodeQL Python analysis overlay-aware by adding overlay annotations throughout the Python QL libraries. The changes enable overlay evaluation, which should significantly improve performance when a base database already exists. According to the PR description, AST, CFG, SSA, and DataFlow::Node are marked as local, while call graph-related functionality remains global.
Changes:
- Added
overlay[local],overlay[local?],overlay[global], andoverlay[caller]annotations to Python QL library modules, classes, and predicates - Introduced join-order optimization helper predicates with
pragma[nomagic]to maintain performance after overlay annotations - Added final class aliases and converted to
instanceofpatterns to enable extending overlay[local] classes from non-overlay contexts
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| python/ql/lib/change-notes/2026-02-18-add-overlay-annotations.md | Documents the overlay evaluation compatibility changes |
| python/ql/lib/semmle/python/**/*.qll | Adds overlay[local] module annotations to AST, CFG, SSA, and dataflow libraries |
| python/ql/lib/semmle/python/dataflow/new/**/*.qll | Adds overlay[local] to dataflow components and overlay[global] to call graph-related predicates |
| python/ql/lib/semmle/python/frameworks/*.qll | Adds overlay[local?] module annotations and join-order helpers to framework models |
| python/ql/lib/semmle/python/objects/TObject.qll | Adds join-order helper predicate for missing_imported_module |
| python/ql/lib/semmle/python/internal/CachedStages.qll | Adds overlay[local] to AST and DataFlow stage predicates |
| python/ql/src/analysis/ImportFailure.ql | Introduces FinalControlFlowNode alias and removes override keyword |
| python/ql/src/Variables/LoopVariableCapture/LoopVariableCaptureQuery.qll | Introduces FinalAstNode alias and converts to instanceof pattern |
| python/ql/lib/analysis/DefinitionTracking.qll | Introduces FinalExpr alias for NiceLocationExpr |
| python/ql/test/library-tests/**/*.qll | Adds overlay annotations to test helper modules |
Makes the CodeQL Python analysis overlay-aware, up to and including
DataFlow::Node.The rough rule of thumb in these changes is:
DataFlow::Nodeare all local,Finally, after adding all of the overlay annotations, a few join-order fixes were needed in order to get performance back to normal. These have been added at the end of this PR.