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

Perf: Remove Duplicated In- and Outoging References #1014

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dataflow/internal/linker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function findNonLocalReads(graph: DataflowGraph): IdentifierReference[] {
nodeId: id,
controlDependencies: undefined
});
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ function processAssignmentToSymbol<OtherInfo>({
// we drop the first arg which we use to pass along arguments :D
const readFromSourceWritten = sourceArg.out.slice(1);
const readTargets: readonly IdentifierReference[] = [{ nodeId: rootId, name: nameOfAssignmentFunction, controlDependencies: data.controlDependencies }, ...sourceArg.unknownReferences, ...sourceArg.in, ...targetArg.in.filter(i => i.nodeId !== target.info.id), ...readFromSourceWritten];
const writeTargets = [...writeNodes, ...writeNodes, ...readFromSourceWritten];

information.environment = overwriteEnvironment(targetArg.environment, sourceArg.environment);

Expand All @@ -299,6 +298,6 @@ function processAssignmentToSymbol<OtherInfo>({
unknownReferences: [],
entryPoint: rootId,
in: readTargets,
out: writeTargets
out: [...writeNodes, ...readFromSourceWritten]
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ function linkReadNameToWriteIfPossible(read: IdentifierReference, environments:

// record if at least one has not been defined
if(probableTarget === undefined || probableTarget.some(t => !listEnvironments.has(t.nodeId) || !happensInEveryBranch(t.controlDependencies))) {
if(remainingRead.has(readName)) {
remainingRead.get(readName)?.push(read);
const has = remainingRead.get(readName);
if(has) {
if(!has?.some(h => h.nodeId === read.nodeId && h.name === read.name && h.controlDependencies === read.controlDependencies)) {
has.push(read);
}
} else {
remainingRead.set(readName, [read]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function processForLoop<OtherInfo>(
return {
unknownReferences: [],
// we only want those not bound by a local variable
in: [{ nodeId: rootId, name: name.content, controlDependencies: originalDependency }, ...variable.in, ...vector.in, ...vector.unknownReferences, ...[...nameIdShares.values()].flat()],
in: [{ nodeId: rootId, name: name.content, controlDependencies: originalDependency }, ...vector.unknownReferences, ...[...nameIdShares.values()].flat()],
out: outgoing,
graph: nextGraph,
entryPoint: name.info.id,
Expand Down
1 change: 0 additions & 1 deletion test/functionality/cli/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ describe('flowr', () => {
const messages = socket.getMessages(['hello', 'response-file-analysis', 'response-query']);
const response = messages[2] as QueryResponseMessage;

console.log(response.results);
assert.exists(response.results['call-context'], 'Expected the query to return at least one result');
assert.exists(response.results['.meta'], 'Expected the query to return at least one result');
assert.equal(response.results['call-context']['kinds']['.']['subkinds']['.'].length, 1, 'We should find one call to print!');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ print(x)`, emptyGraph()
.constant('1')
.defineVariable('0', 'x', { definedBy: ['1', '2'] })
.constant('10')
.defineVariable('9', 'x', { definedBy: ['10', '11'], controlDependencies: [{ id: '27', when: true }] })
.defineVariable('9', 'x', { definedBy: ['10', '11'], controlDependencies: [{ id: '19', when: true }, { id: '27', when: true }] })
.constant('16')
.defineVariable('15', 'x', { definedBy: ['16', '17'], controlDependencies: [{ id: '27', when: true }] })
.defineVariable('15', 'x', { definedBy: ['16', '17'], controlDependencies: [{ id: '19', when: false }, { id: '27', when: true }] })
.constant('24')
.defineVariable('23', 'x', { definedBy: ['24', '25'], controlDependencies: [{ id: '27', when: false }] })
);
Expand Down
73 changes: 25 additions & 48 deletions wiki/Dataflow Graph.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_This document was generated automatically from '/home/happy-feet/git/phd/flowr-field/flowr/src/documentation/print-dataflow-graph-wiki.ts' on 2024-09-23, 11:35:04 UTC presenting an overview of flowR's dataflow graph (version: 2.0.25, using R version 4.4.1)._
_This document was generated automatically from '/home/happy-feet/git/phd/flowr-field/flowr/src/documentation/print-dataflow-graph-wiki.ts' on 2024-09-23, 12:04:03 UTC presenting an overview of flowR's dataflow graph (version: 2.0.25, using R version 4.4.1)._

This page briefly summarizes flowR's dataflow graph, represented by DataflowGraph in [`./src/dataflow/graph/graph.ts`](https://github.com/flowr-analysis/flowr/tree/main/./src/dataflow/graph/graph.ts).
In case you want to manually build such a graph (e.g., for testing), you can use the builder in [`./src/dataflow/graph/dataflowgraph-builder.ts`](https://github.com/flowr-analysis/flowr/tree/main/./src/dataflow/graph/dataflowgraph-builder.ts).
Expand Down Expand Up @@ -61,8 +61,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _13.22 ms_ (including parsing and normalization) within the generation environment.

The analysis required _12.58 ms_ (including parsing and normalization) within the generation environment.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -194,8 +193,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.35 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
The analysis required _1.12 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 0.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -246,8 +244,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.19 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
The analysis required _1.01 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 0.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -298,8 +295,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.17 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 1.
The analysis required _1.03 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 1.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -357,8 +353,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _2.94 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 3.
The analysis required _2.13 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 3.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -428,8 +423,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.44 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
The analysis required _1.00 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 0.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -499,8 +493,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.53 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
The analysis required _1.55 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 0.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -570,8 +563,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.20 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 2.
The analysis required _0.98 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 2.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -652,8 +644,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.82 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 4->0.
The analysis required _1.67 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 4->0.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -751,8 +742,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _2.14 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 7->0.
The analysis required _1.87 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 7->0.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -854,8 +844,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.81 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 4->1.
The analysis required _2.39 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 4->1.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -947,8 +936,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.21 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0->1, 0->2.
The analysis required _1.03 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 0->1, 0->2.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1031,8 +1019,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.77 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0->4, 0->3, 1->3.
The analysis required _1.31 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 0->4, 0->3, 1->3.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1116,8 +1103,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.71 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0->3.
The analysis required _1.02 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 0->3.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1216,8 +1202,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.81 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 7->4.
The analysis required _1.62 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 7->4.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1326,8 +1311,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.68 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 6->1.
The analysis required _1.48 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 6->1.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1451,8 +1435,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _3.21 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 11->1, 1->11.
The analysis required _1.36 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 11->1, 1->11.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1591,8 +1574,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _2.24 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 11->1, 1->11.
The analysis required _1.84 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 11->1, 1->11.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1697,8 +1679,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.64 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 5->1, 5->3.
The analysis required _0.97 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 5->1, 5->3.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1806,8 +1787,7 @@ end

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _2.90 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 3->10.
The analysis required _2.12 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 3->10.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1912,8 +1892,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _0.92 ms_ (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 3->1.
The analysis required _0.82 ms_ (including parsing and normalization) within the generation environment. The following marks are used in the graph to highlight sub-parts (uses ids): 3->1.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -1986,8 +1965,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _1.31 ms_ (including parsing and normalization) within the generation environment.

The analysis required _2.09 ms_ (including parsing and normalization) within the generation environment.
We encountered no unknown side effects during the analysis.

```r
Expand Down Expand Up @@ -5476,8 +5454,7 @@ flowchart LR

<summary style="color:gray">R Code of the Dataflow Graph</summary>

The analysis required _3.98 ms_ (including parsing and normalization) within the generation environment.

The analysis required _2.20 ms_ (including parsing and normalization) within the generation environment.
We encountered unknown side effects (with ids: [3]) during the analysis.

```r
Expand Down Expand Up @@ -5525,7 +5502,7 @@ flowchart LR



In general, as we cannot handle these correctly, we leave it up to other analyses (and [queries](https://github.com/flowr-analysis/flowr/wiki//Query API)) to handle these cases
In general, as we cannot handle these correctly, we leave it up to other analyses (and [queries](https://github.com/flowr-analysis/flowr/wiki//Query%20API)) to handle these cases
as they see fit.


Expand Down
Loading