Skip to content

C++: Fix join order in definitionHasPhiNode #4730

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

Merged
merged 1 commit into from
Nov 27, 2020

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Nov 26, 2020

When trying to make sense of https://github.com/github/codeql-c-analysis-team/issues/190 yesterday, I noticed a bad join order (which sadly didn't fix that issue, but nonetheless seems worth fixing) on kamailio/kamailio.

Before:

[2020-11-26 09:49:25] (682s) Starting to evaluate predicate SSAConstruction::PhiInsertion::definitionHasPhiNode#2#ff/2@i6#72c4bw (iteration 6)
[2020-11-26 09:49:27] (683s) Tuple counts for SSAConstruction::PhiInsertion::definitionHasPhiNode#2#ff/2@i6#72c4bw:
    23942751 ~1%      {3} r1 = JOIN SSAConstruction::PhiInsertion::definitionHasDefinitionInBlock#2#ff#prev_delta AS L WITH SSAConstruction::PhiInsertion::definitionLiveOnEntryToBlock#2#ff AS R ON FIRST 1 OUTPUT L.<1>, R.<1>, L.<0>
    11753    ~24%     {2} r2 = JOIN r1 WITH Dominance::getDominanceFrontier#2#ff AS R ON FIRST 2 OUTPUT r1.<2>, r1.<1>
    3224     ~36%     {2} r3 = r2 AND NOT SSAConstruction::PhiInsertion::definitionHasPhiNode#2#ff#prev AS R(r2.<0>, r2.<1>)
    return r3

After:

[2020-11-26 09:22:05] (652s) Starting to evaluate predicate SSAConstruction::PhiInsertion::definitionHasPhiNode#2#ff/2@i6#64968w (iteration 6)
[2020-11-26 09:22:05] (652s) Tuple counts for SSAConstruction::PhiInsertion::dominanceFrontierOfDefinition#2#ff/2@i5#64968x:
    320824  ~0%      {2} r1 = SCAN SSAConstruction::PhiInsertion::definitionHasDefinitionInBlock#2#ff#prev_delta AS I OUTPUT I.<1>, I.<0>
    314862  ~17%     {2} r2 = JOIN r1 WITH Dominance::getDominanceFrontier#2#ff AS R ON FIRST 1 OUTPUT r1.<1>, R.<1>
    242301  ~7%      {2} r3 = r2 AND NOT SSAConstruction::PhiInsertion::dominanceFrontierOfDefinition#2#ff#prev AS R(r2.<0>, r2.<1>)
    return r3
...
[2020-11-26 09:22:05] (652s) Tuple counts for SSAConstruction::PhiInsertion::definitionHasPhiNode#2#ff/2@i6#64968w:
    13051    ~0%     {2} r1 = JOIN SSAConstruction::PhiInsertion::dominanceFrontierOfDefinition#2#ff#prev_delta AS L WITH SSAConstruction::PhiInsertion::definitionLiveOnEntryToBlock#2#ff AS R ON FIRST 2 OUTPUT L.<0>, L.<1>
    return r1

I can't quite work out why the intermediary tuple counts have changed, but the size of the final predicate is unchanged:

Before:

[2020-11-26 09:49:27] (684s)  >>> Created relation SSAConstruction::PhiInsertion::definitionHasPhiNode#2#ff/2@72c4bw with 404674 rows.

After:

[2020-11-26 09:22:05] (652s)  >>> Created relation SSAConstruction::PhiInsertion::definitionHasPhiNode#2#ff/2@64968w with 404674 rows.

CPP-differences: https://jenkins.internal.semmle.com/job/Changes/job/CPP-Differences/1572/

@MathiasVP MathiasVP added the C++ label Nov 26, 2020
@MathiasVP MathiasVP requested review from a team as code owners November 26, 2020 09:12
@github-actions github-actions bot added the C# label Nov 26, 2020
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

Code change LGTM. Waiting to confirm performance on the CPP-Differences job.

@MathiasVP
Copy link
Contributor Author

MathiasVP commented Nov 26, 2020

Performance numbers look relatively unchanged. The numbers might be a slight improvement, but it's all within the noise range.

@jbj jbj merged commit a48235e into github:main Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants