Skip to content

Conversation

MathiasVP
Copy link
Contributor

QA exposed a join order problem that happens on #18207 when running cpp/guarded-free.

Before:

[2024-12-04 20:18:49] Tuple counts for _IRGuards::GuardConditionFromIR#2c83f350_10#join_rhs_IRGuards::GuardConditionImpl.valueControls/2#di__#count_range/2@e5cbfe69 after 4m47s:
                      2822000     ~828%        {2} r1 = SCAN `Operand::Operand.getAnyDef/0#dispred#8dbe2fb8` OUTPUT In.1, In.0
                      933500      ~15963%      {1}    | JOIN WITH `project#Instruction::Instruction.getUnconvertedResultExpression/0#dispred#d46d1df3` ON FIRST 1 OUTPUT Lhs.1
                      23966000    ~119664%     {2}    | JOIN WITH `IRGuards::IRGuardCondition.comparesEq/4#dispred#be87109f#ffbff#cpe#1245_103#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Rhs.2
                      23915563    ~115617%     {2}    | JOIN WITH IRGuards::GuardConditionFromIR#2c83f350_10#join_rhs ON FIRST 1 OUTPUT Rhs.1 'arg0', Lhs.1
                      25354606500 ~164093%     {2}    | JOIN WITH `IRGuards::GuardConditionImpl.valueControls/2#dispred#b7fb47ca_021#join_rhs` ON FIRST 2 OUTPUT Lhs.0 'arg0', Rhs.2 'arg1'
                                               return r1

(cancelled before it ended!)

After:

[2024-12-04 19:37:28] Evaluated non-recursive predicate GuardedFree::interesting/4#946d570b@003f1361 in 5ms (size: 2).
Evaluated relational algebra for predicate GuardedFree::interesting/4#946d570b@003f1361 with tuple counts:
         3   ~0%    {5} r1 = SCAN `_Element::Element.isInMacroExpansion/0#dispred#baf892eb#b_Expr::Expr.getEnclosingStmt/0#224d8d99_10#__#shared` OUTPUT In.1, In.2, In.3, In.4, In.0
                    {5}    | AND NOT `_#Expr::Expr.getAChild/0#dispred#90427aa9Plus#bf_10#join_rhs__Element::Element.isInMacroExpansion/0#__#antijoin_rhs`(FIRST 5)
         3   ~0%    {6}    | SCAN OUTPUT In.4, _, In.0, In.1, In.2, In.3
         3   ~0%    {6}    | REWRITE WITH Out.1 := 0
         3   ~0%    {6}    | JOIN WITH `Call::Call.getArgument/1#dispred#ada436ba#ffb` ON FIRST 2 OUTPUT Rhs.2, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Lhs.0
         3   ~0%    {6}    | JOIN WITH `Access::Access.getTarget/0#dispred#cf25c8aa` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5
        10   ~0%    {7}    | JOIN WITH `Access::Access.getTarget/0#dispred#cf25c8aa_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Lhs.0
        13   ~0%    {8}    | JOIN WITH `Instruction::Instruction.getUnconvertedResultExpression/0#dispred#d46d1df3_10#join_rhs` ON FIRST 1 OUTPUT Lhs.2, _, Lhs.4, Lhs.1, Lhs.3, Lhs.5, Lhs.6, Rhs.1
        13   ~0%    {8}    | REWRITE WITH Out.1 := false
         8   ~0%    {6}    | JOIN WITH `IRGuards::IRGuardCondition.comparesEq/4#dispred#be87109f#ffbff#cpe#1245_0231#join_rhs` ON FIRST 3 OUTPUT Rhs.3, Lhs.7, Lhs.3, Lhs.4, Lhs.5, Lhs.6
         2   ~0%    {4}    | JOIN WITH `Operand::Operand.getAnyDef/0#dispred#8dbe2fb8` ON FIRST 2 OUTPUT Lhs.2, Lhs.4, Lhs.5, Lhs.3
                    return r1

[2024-12-04 19:37:30] Evaluated non-recursive predicate _IRGuards::GuardConditionFromIR#2c83f350_IRGuards::GuardConditionImpl.valueControls/2#dispred#b7fb47__#count_range@7057da67 in 3ms (size: 6).
Evaluated relational algebra for predicate _IRGuards::GuardConditionFromIR#2c83f350_IRGuards::GuardConditionImpl.valueControls/2#dispred#b7fb47__#count_range@7057da67 with tuple counts:
         2   ~0%    {1} r1 = SCAN `project#GuardedFree::interesting/4#946d570b` OUTPUT In.0
         2   ~0%    {1}    | STREAM DEDUP
         2   ~0%    {2}    | JOIN WITH IRGuards::GuardConditionFromIR#2c83f350 ON FIRST 1 OUTPUT Lhs.0, Rhs.1
         6   ~0%    {4}    | JOIN WITH `IRGuards::GuardConditionImpl.valueControls/2#dispred#b7fb47ca` ON FIRST 1 OUTPUT Lhs.1, Rhs.2, Lhs.0, Rhs.1
        12   ~0%    {3}    | JOIN WITH `IRGuards::IRGuardCondition.comparesEq/4#dispred#be87109f#ffbff#cpe#1245_031#join_rhs` ON FIRST 2 OUTPUT Rhs.2, Lhs.2, Lhs.3
        12   ~0%    {3}    | JOIN WITH `Operand::Operand.getAnyDef/0#dispred#8dbe2fb8` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
        12  ~99%    {2}    | JOIN WITH `project#Instruction::Instruction.getUnconvertedResultExpression/0#dispred#d46d1df3` ON FIRST 1 OUTPUT Lhs.1, Lhs.2
                    return r1

@MathiasVP MathiasVP requested a review from a team as a code owner December 4, 2024 20:21
@github-actions github-actions bot added the C++ label Dec 4, 2024
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Dec 4, 2024
Copy link
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

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

LGTM

@jketema jketema merged commit 65a4dc3 into github:main Dec 5, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ 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