Skip to content

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Mar 7, 2019

This PR has a quite positive impact on performance (internal link), as the default LGTM suite contains many data-flow-based queries.

Commit-by-commit review is encouraged.

hvitved added 5 commits March 7, 2019 12:15
Before this change,

```
flowOutOfCallableStep(CallNode call, ReturnNode ret, OutNode out, CallContext cc)
```

would compute all combinations of call sites `call` and returned expressions `ret`
up front.

Now, we instead introduce explicit return nodes, so each callable has exactly
one return node (as well as one for each `out`/`ref` parameter). There is then
local flow from a returned expression to the relevant return node, and
`flowOutOfCallableStep()` computes combinations of call sites and return nodes.

Not only does this result in better performance, it also makes `flowOutOfCallableStep()`
symmetric to `flowIntoCallableStep()`, where each argument is mapped to a parameter,
and not to all reads of that parameter.
@hvitved hvitved added the C# label Mar 7, 2019
@hvitved hvitved requested a review from calumgrant March 7, 2019 18:56
@hvitved hvitved added this to the 1.20 milestone Mar 7, 2019
@hvitved hvitved marked this pull request as ready for review March 7, 2019 18:57
@hvitved hvitved requested a review from a team as a code owner March 7, 2019 18:57
Copy link
Contributor

@calumgrant calumgrant left a comment

Choose a reason for hiding this comment

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

Awesome speedup. A few minor questions.

@@ -1100,7 +1125,10 @@ module DataFlow {
config.isSource(node) or
jumpStep(_, node) or
node instanceof ParameterNode or
node instanceof OutNode
node instanceof OutNode or
node instanceof NormalReturnNode or
Copy link
Contributor

Choose a reason for hiding this comment

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

Just node instanceof ReturnNode ?

node instanceof ReturnNode
or
exists(ReturnNode rn | localFlowStep(node, rn, config) |
rn instanceof NormalReturnNode or
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how the body of this exists can be false? So perhaps

localFlowStep(node, any(ReturnNode rn), config)


override DotNet::Callable getEnclosingCallable() { this = TNormalReturnNode(result) }

override string toString() { result = "return" }
Copy link
Contributor

Choose a reason for hiding this comment

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

"return " + getEnclosingCallable().getName()
Could that be useful?

@@ -591,18 +581,47 @@ module DataFlow {
abstract private class ReturnNode extends Node { }
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be useful to have getAReturnedExpr() on this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an internal class, so I think we should only add it if we need it later on.

@hvitved hvitved force-pushed the csharp/dataflow/performance branch from 631c7b0 to 8959d52 Compare March 10, 2019 14:07
calumgrant
calumgrant previously approved these changes Mar 11, 2019
Copy link
Contributor

@calumgrant calumgrant left a comment

Choose a reason for hiding this comment

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

Wait for dist-compare results.

@hvitved
Copy link
Contributor Author

hvitved commented Mar 11, 2019

Wait for dist-compare results.

The new report is ready (internal link), and things still look good.

@calumgrant calumgrant merged commit 242f8f2 into github:rc/1.20 Mar 11, 2019
@hvitved hvitved deleted the csharp/dataflow/performance branch March 11, 2019 18:26
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.

2 participants