Skip to content

Type inference: Small join-order tweak#22114

Merged
hvitved merged 2 commits into
github:mainfrom
hvitved:type-inference-join
Jul 8, 2026
Merged

Type inference: Small join-order tweak#22114
hvitved merged 2 commits into
github:mainfrom
hvitved:type-inference-join

Conversation

@hvitved

@hvitved hvitved commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

A small performance tweak extracted from #21795, where it makes a big difference. The most important change in this PR is the removal of argRootTypeSatisfiesTargetTypeCand/7, which could have a large explosion because of getTarget fan-out.

@hvitved hvitved added the no-change-note-required This PR does not need a change note label Jul 3, 2026
@hvitved hvitved marked this pull request as ready for review July 3, 2026 07:53
@hvitved hvitved requested a review from a team as a code owner July 3, 2026 07:53
Copilot AI review requested due to automatic review settings July 3, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 applies a targeted join-order/performance tweak in the shared type inference library, extracted from #21795, primarily by removing the higher-fanout candidate predicate that depended on getTarget expansion.

Changes:

  • Reworks the argRootTypeSatisfiesTargetTypeCand candidate logic to avoid the previous higher-fanout approach described in the PR metadata.
  • Introduces an intermediate predicate (accessTargetsWithArgRootType) to separate access target enumeration from type-candidate filtering.
  • Tightens some bindings in baseTypeMatch using pragma[only_bind_into] to influence evaluation order/binding behavior.
Show a summary per file
File Description
shared/typeinference/codeql/typeinference/internal/TypeInference.qll Adjusts internal type inference candidate selection/binding structure to reduce join explosion risk.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Low

@hvitved

hvitved commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author
Rerun has been triggered, but no failed runs found ⚠️

@hvitved hvitved requested a review from geoffw0 July 7, 2026 07:21
) {
target = a.getTarget(e) and
argRootTypeSatisfiesTargetTypeCand(argRootType, target, apos, tp, pathToTp) and
not exists(getTypeArgument(a, target, tp, _))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I notice this not exists(getTypeArgument... constraint does not show up in the new code. Is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch, I'll reintroduce it.

conditionSatisfiesConstraintTypeAt(_, condition, constraint, TypePath::nil(),
constraintRootType) and
constraintRootType = target.getDeclaredType(dpos, TypePath::nil()) and
constraintRootType.getATypeParameter() = pathToTp.getHead() and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this change do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It will mean the same thing whenever getDeclaredType is functional (which it should be), but I have a mild preference for the rewrite.

@geoffw0 geoffw0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, assuming nothing comes up in the DCA re-run.

@hvitved hvitved merged commit f4773e9 into github:main Jul 8, 2026
133 of 140 checks passed
@hvitved hvitved deleted the type-inference-join branch July 8, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants