Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Jan 16, 2026

Before

Evaluated relational algebra for predicate _ElementImpl::Impl::MacroExpansion::isAttributeMacroExpansionSourceLocation/2#3429148c_Locatable::Lo__#antijoin_rhs@9f4aa4rk with tuple counts:
        5127263380  ~4%    {3} r1 = JOIN `_AstNodeImpl::Impl::AstNode#22e758cf_ElementImpl::Impl::MacroExpansion::getATokenTreeNode/1#a2df59a3__#shared` WITH `ElementImpl::Impl::MacroExpansion::isAttributeMacroExpansionSourceLocation/2#3429148c` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Lhs.0
            305226  ~0%    {2}    | JOIN WITH `Locatable::Locatable.getLocation/0#dispred#f3f7e2b2` ON FIRST 2 OUTPUT Lhs.0, Lhs.2
                           return r1

(No After; the predicate is no longer generated)

Before
```
Evaluated relational algebra for predicate _ElementImpl::Impl::MacroExpansion::isAttributeMacroExpansionSourceLocation/2#3429148c_Locatable::Lo__#antijoin_rhs@9f4aa4rk with tuple counts:
        5127263380  ~4%    {3} r1 = JOIN `_AstNodeImpl::Impl::AstNode#22e758cf_ElementImpl::Impl::MacroExpansion::getATokenTreeNode/1#a2df59a3__#shared` WITH `ElementImpl::Impl::MacroExpansion::isAttributeMacroExpansionSourceLocation/2#3429148c` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Lhs.0
            305226  ~0%    {2}    | JOIN WITH `Locatable::Locatable.getLocation/0#dispred#f3f7e2b2` ON FIRST 2 OUTPUT Lhs.0, Lhs.2
                           return r1
```

(No After; the predicate is no longer generated)
@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jan 16, 2026
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Jan 16, 2026
@hvitved hvitved marked this pull request as ready for review January 16, 2026 16:19
@hvitved hvitved requested a review from a team as a code owner January 16, 2026 16:19
Copilot AI review requested due to automatic review settings January 16, 2026 16:19
Copy link
Contributor

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 optimizes a CodeQL query in the Rust library by fixing a performance issue caused by an inefficient join operation. The change introduces an intermediate variable to store the location before using it in a negative condition, significantly reducing tuple processing from ~5 billion to eliminating the problematic predicate entirely.

Changes:

  • Introduced an intermediate variable l to store n.getLocation() in the isFromMacroExpansion predicate, preventing an expensive join operation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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 Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants