Python: bind captured type-tracking jumps from source - #22407
Draft
yoff wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The previous capturedJumpStep shape introduced an independent Cfg::DefinitionNode and related it to the captured variable before nodeTo bound the relevant scope-entry definition. On substantial databases, the evaluator chose a plan that materialized a high-duplication store/variable join before applying the target entry and source-node constraints. Bind the scope-entry definition from nodeTo first, derive its source variable, and then match nodeFrom's DefinitionNode directly to that variable's store. This is relation-equivalent existential elimination: the old nodeFrom.asCfgNode() = def and def.getNode() = store constraints become nodeFrom.asCfgNode().(Cfg::DefinitionNode).getNode() = store, preserving the DefinitionNode type restriction and the unchanged enclosing-scope condition. On Airflow a9da0f7 with CodeQL 2.26.2, against exact github#21925 head 1a8e317: * The call-target diagnostic retains the identical 59,732-edge set while tuples joined fall from 1,032,403,207 to 66,969,953 (-93.5%), maximum duplication falls from 1,473,981 to 4,053, and evaluator wall time falls from 59.9s to 6.2s. * py/clear-text-logging-sensitive-data retains every result tuple (130 alerts, 256,708 path edges, 102,385 path nodes, and 116,976 subpaths) while tuples joined fall from 1,329,594,809 to 242,111,554 (-81.8%) and evaluator wall time falls from 94s to 14.4s. The preceding commit is intentionally a semantic call-target invariant diagnostic that passes on the unoptimized relation and after this rewrite. An inline MISSING/SPURIOUS red-state would assert an artificial semantic delta; this optimization must preserve every valid captured call target. These measurements cover one exact substantial Airflow database and two query shapes. No DCA was run, the fix does not reduce legitimate call-graph or path growth, and broader fleet performance remains to be confirmed separately. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5dfda5f5-08c8-481b-9ecb-299018701497
yoff
force-pushed
the
yoff-python-dispatch-plan-cost
branch
from
August 21, 2026 18:21
f2a75c8 to
d7066b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #21925.
Summary
This rewrites the captured-scope type-tracking jump so the scope-entry definition binds the source variable before the source CFG node is matched. The relation is unchanged, but the evaluator no longer materializes the high-duplication store/variable cross product induced by the previous join shape.
The old constraints introduced an independent
Cfg::DefinitionNode def, relateddeftovar.getVariable().getAStore(), and only then constrainednodeFrom = def. The new form bindsefromnodeTo, derivesvarfrome, and directly applies the sameDefinitionNode.getNode() = storeconstraint tonodeFrom. This is existential elimination with the same type and scope restrictions, not a semantic change.Diagnostic commit
Commit 1 is intentionally a semantic call-target invariant diagnostic, not an inline
MISSING/SPURIOUSred-state. It records the valid captured-callable targets produced for decorator wrappers and captured type parameters in comprehensions, including the mechanism behind Airflow's legitimate_RegexpIgnoreRule.compileand_GlobIgnoreRule.compiletargets. It passes before and after the optimization so that commit 2 must preserve the relation exactly. An annotation that failed before the fix would assert an artificial semantic delta and would not test this behavior-preserving plan optimization.Exact Airflow measurement
Measured with CodeQL 2.26.2 on Airflow
a9da0f7fb48dc7526b2745be3e8fe64e1c775da2, comparing exact #21925 head1a8e317b4a328bea1059453a2ab3ba6eada09e3fto this branch:py/clear-text-logging-sensitive-data: every result tuple is preserved (130 alerts, 256,708 path edges, 102,385 path nodes, 116,976 subpaths); tuples joined 1,329,594,809 -> 242,111,554 (-81.8%); evaluator wall time 94s -> 14.4s.No valid call target is suppressed.
Limitations
These measurements cover one exact substantial Airflow database and two query shapes. The fix does not reduce legitimate semantic call-graph or path growth, and fleet-wide performance remains to be confirmed. No DCA was launched.
Tests
captured-call-targets/CallTargets.qltypetracking/tracked.ql