Content-Length: 285937 | pFad | http://github.com/github/codeql/pull/20091

C7 Java: Fix accidental CP in CFG for asserts. by aschackmull · Pull Request #20091 · github/codeql · GitHub
Skip to content

Java: Fix accidental CP in CFG for asserts. #20091

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aschackmull
Copy link
Contributor

The somewhat recent change to the CFG for Java assert statements introduced an accidental cartesian product. The product is between completions and assert statements, both of which are somewhat limited in number, which is why we haven't discovered this before now. It was identified by the join-order metric, since the CP was confusing the optimiser to select a particularly bad join order.

Before:

              444   ~4%    {2} r34 = JOIN Completion::Completion#3da5aa6a WITH num#Completion::NormalCompletion#17a01869 CARTESIAN PRODUCT OUTPUT Rhs.0, Lhs.0
        257653644   ~0%    {3}    | JOIN WITH `ControlFlowGraph::ControlFlowGraphImpl::last/3#f72f2d15_201#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Rhs.2
            17760   ~0%    {3}    | JOIN WITH `Statement::AssertStmt.getMessage/0#dispred#911385b1_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
            17760   ~0%    {3}    | JOIN WITH num#ControlFlowGraph::ControlFlow::TAssertThrowNode#fd4ea142 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Rhs.1

After:

[2025-07-18 13:46:42] Evaluated non-recursive predicate _ControlFlowGraph::ControlFlowGraphImpl::last/3#f72f2d15_201#join_rhs_num#Completion::NormalCompleti__#shared@4f47f1qe in 92ms (size: 580301).
Evaluated relational algebra for predicate _ControlFlowGraph::ControlFlowGraphImpl::last/3#f72f2d15_201#join_rhs_num#Completion::NormalCompleti__#shared@4f47f1qe with tuple counts:
        580301  ~1%    {3} r1 = JOIN `ControlFlowGraph::ControlFlowGraphImpl::last/3#f72f2d15_201#join_rhs` WITH num#Completion::NormalCompletion#17a01869 ON FIRST 1 OUTPUT Lhs.1, Lhs.0, Lhs.2
                       return r1

...
            40   ~3%    {3} r4 = JOIN `_ControlFlowGraph::ControlFlowGraphImpl::last/3#f72f2d15_201#join_rhs_num#Completion::NormalCompleti__#shared` WITH `Statement::AssertStmt.getMessage/0#dispred#911385b1_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
            40   ~0%    {3}    | JOIN WITH num#ControlFlowGraph::ControlFlow::TAssertThrowNode#fd4ea142 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Rhs.1

@Copilot Copilot AI review requested due to automatic review settings July 18, 2025 12:00
@aschackmull aschackmull requested a review from a team as a code owner July 18, 2025 12:00
@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Jul 18, 2025
Copy link
Contributor

@Copilot 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 fixes an accidental cartesian product in the control flow graph (CFG) implementation for Java assert statements. The issue was causing the query optimizer to select inefficient join orders, significantly impacting performance.

  • Replaces direct pattern matching with NormalCompletion() with explicit variable binding and constraint
  • Eliminates cartesian product between completions and assert statements in the query execution plan
  • Improves query performance by enabling better join order selection

@github-actions github-actions bot added the Java label Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java 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.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/codeql/pull/20091

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy