Skip to content

Commit f4e48e6

Browse files
authored
[ui] Improve buildGraphData performance (#32818)
## Summary & Motivation In `buildGraphData`, we're currently using spread operators to keep the internal `data` value from being mutated, but this avoidance isn't useful and it's causing a perf bottleneck for large asset graphs. Just mutate `data` directly within the function. This gets the large sample asset graph (~15k assets) from 8+ seconds of chug time to ~80ms. ## How I Tested These Changes Proxy as izzy's org, load Catalog. Verify with logging that the timing for this function has dropped. ## Changelog [ui] Improve browser performance for large asset graphs.
1 parent dc3604a commit f4e48e6

File tree

1 file changed

+8
-8
lines changed
  • js_modules/dagster-ui/packages/ui-core/src/asset-graph

1 file changed

+8
-8
lines changed

js_modules/dagster-ui/packages/ui-core/src/asset-graph/Utils.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ export const buildGraphData = (assetNodes: AssetNode[]) => {
8686
// Skip add edges for self-dependencies (eg: assets relying on older partitions of themselves)
8787
return;
8888
}
89-
data.downstream[upstreamGraphId] = {
90-
...(data.downstream[upstreamGraphId] || {}),
91-
[downstreamGraphId]: true,
92-
};
93-
data.upstream[downstreamGraphId] = {
94-
...(data.upstream[downstreamGraphId] || {}),
95-
[upstreamGraphId]: true,
96-
};
89+
if (!data.downstream[upstreamGraphId]) {
90+
data.downstream[upstreamGraphId] = {};
91+
}
92+
if (!data.upstream[downstreamGraphId]) {
93+
data.upstream[downstreamGraphId] = {};
94+
}
95+
data.downstream[upstreamGraphId][downstreamGraphId] = true;
96+
data.upstream[downstreamGraphId][upstreamGraphId] = true;
9797
};
9898

9999
assetNodes.forEach((definition: AssetNode) => {

0 commit comments

Comments
 (0)