Skip to content
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

DataFlow: Cache getSecondLevelScope #16337

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

MathiasVP
Copy link
Contributor

I was seeing getSecondLevelScope evaluated 13 times when running security-and-quality on C++:

[2024-04-26 11:45:12] Evaluated non-recursive predicate DataFlowPrivate::getSecondLevelScope/1#14eac193@06c247lf in 6763ms (size: 17958858).
Evaluated relational algebra for predicate DataFlowPrivate::getSecondLevelScope/1#14eac193@06c247lf with tuple counts:
         17974438   ~0%    {2} r1 = SCAN `SSAConstruction::getInstructionAst/1#d0d95b50` OUTPUT In.1, In.0
         17007656   ~2%    {2}    | JOIN WITH `ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        171579959   ~0%    {2} r2 = JOIN r1 WITH `boundedFastTC:Stmt::Stmt.getParentStmt/0#dispred#c84c2aca:_ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97_SSAConstruction::getInstructi__#higher_order_body` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        188587615   ~0%    {2} r3 = r1 UNION r2
         10692306   ~0%    {2}    | JOIN WITH `DataFlowPrivate::DataFlowSecondLevelScope.getAStmt/0#dispred#a01ddd53_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1
         18671793  ~17%    {2}    | JOIN WITH `DataFlowPrivate::getAnInstruction/1#db1ad56d_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                           return r3
...
[2024-04-26 11:45:13] Evaluated non-recursive predicate DataFlowPrivate::getSecondLevelScope/1#14eac193@cff7d5oq in 6779ms (size: 17854084).
Evaluated relational algebra for predicate DataFlowPrivate::getSecondLevelScope/1#14eac193@cff7d5oq with tuple counts:
         17974438   ~0%    {2} r1 = SCAN `SSAConstruction::getInstructionAst/1#d0d95b50` OUTPUT In.1, In.0
         17007656   ~2%    {2}    | JOIN WITH `ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        171579959   ~0%    {2} r2 = JOIN r1 WITH `boundedFastTC:Stmt::Stmt.getParentStmt/0#dispred#c84c2aca:_ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97_SSAConstruction::getInstructi__#higher_order_body` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        188587615   ~0%    {2} r3 = r1 UNION r2
         10692306   ~0%    {2}    | JOIN WITH `DataFlowPrivate::DataFlowSecondLevelScope.getAStmt/0#dispred#a01ddd53_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1
         18671793  ~17%    {2}    | JOIN WITH `DataFlowPrivate::getAnInstruction/1#db1ad56d_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                           return r3
...
[2024-04-26 11:45:36] Evaluated non-recursive predicate DataFlowPrivate::getSecondLevelScope/1#14eac193@ce798187 in 23420ms (size: 18029768).
Evaluated relational algebra for predicate DataFlowPrivate::getSecondLevelScope/1#14eac193@ce798187 with tuple counts:
         17974438   ~0%    {2} r1 = SCAN `SSAConstruction::getInstructionAst/1#d0d95b50` OUTPUT In.1, In.0
         17007656   ~2%    {2}    | JOIN WITH `ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        171579959   ~0%    {2} r2 = JOIN r1 WITH `boundedFastTC:Stmt::Stmt.getParentStmt/0#dispred#c84c2aca:_ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97_SSAConstruction::getInstructi__#higher_order_body` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        188587615   ~0%    {2} r3 = r1 UNION r2
         10692306   ~0%    {2}    | JOIN WITH `DataFlowPrivate::DataFlowSecondLevelScope.getAStmt/0#dispred#a01ddd53_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1
         18671793  ~17%    {2}    | JOIN WITH `DataFlowPrivate::getAnInstruction/1#db1ad56d_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                           return r3

After this PR we just have:

[2024-04-26 13:02:04] Evaluated non-recursive predicate DataFlowImplCommon::Cached::getSecondLevelScopeCached/1#7c22811c@d8fc562i in 33857ms (size: 18161972).
Evaluated relational algebra for predicate DataFlowImplCommon::Cached::getSecondLevelScopeCached/1#7c22811c@d8fc562i with tuple counts:
         17974438   ~0%    {2} r1 = SCAN `SSAConstruction::getInstructionAst/1#d0d95b50` OUTPUT In.1, In.0
         17007656   ~0%    {2}    | JOIN WITH `ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        171579959   ~1%    {2} r2 = JOIN r1 WITH `boundedFastTC:Stmt::Stmt.getParentStmt/0#dispred#c84c2aca:_ControlFlowGraph::ControlFlowNode.getEnclosingStmt/0#dispred#fa57cf97_SSAConstruction::getInstructi__#higher_order_body` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                       
        188587615   ~0%    {2} r3 = r1 UNION r2
         10692306   ~0%    {2}    | JOIN WITH `DataFlowPrivate::DataFlowSecondLevelScope.getAStmt/0#dispred#a01ddd53_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1
         18671793  ~16%    {2}    | JOIN WITH `DataFlowPrivate::getAnInstruction/1#db1ad56d_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                           return r3

@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Apr 26, 2024
@MathiasVP MathiasVP requested a review from aschackmull April 26, 2024 12:16
Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

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

LGTM

@MathiasVP
Copy link
Contributor Author

DCA for C/C++ looks fantastic. All other languages are unaffected. I guess C/C++ simply have more second-level scopes than anyone else (which is not surprising, really!) 😅

@MathiasVP MathiasVP merged commit 6147a38 into github:main Apr 26, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFlow Library 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