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

DYN-8358 cleanup dependency graph from old nodes #15869

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

chubakueno
Copy link
Contributor

@chubakueno chubakueno commented Feb 28, 2025

Purpose

The dependency graph currently accumulates old versios of the nodes (modified and deleted) indefinitely while the Dynamo workspace is running and being edited. This PR aims to clean up old node versions to keep the quadratic complexity of BuildGraphNodeDependencies controlled.

Related performance spike: #15864

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

Clean up dependency graph to improve performance and prevent progressive Dynamo slowing down.

Reviewers

@QilongTang

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@chubakueno chubakueno added the WIP label Feb 28, 2025
@QilongTang QilongTang added this to the 3.5 milestone Feb 28, 2025
@@ -57,7 +57,12 @@ public static void BuildGraphNodeDependencies(List<AssociativeGraph.GraphNode> g
{
return;
}

for (int i = 0; i < graphNodesInScope.Count; ++i)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you add comments to this block, seems pretty important for others to understand

Copy link
Contributor Author

@chubakueno chubakueno Feb 28, 2025

Choose a reason for hiding this comment

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

The ChildrenNodes and ParentNodes are being rebuilt every time, but before this PR they were accumulating more dependencies each time BuildGraphNodeDependencies was called. So this is more of a bug correction.

@@ -1500,6 +1504,28 @@ private ulong GetGraphNodeKey(int classIndex, int procIndex)
return (((ulong)ci) << 32) | pi;
}

internal void Purge(List<AST.AssociativeAST.AssociativeNode> oldNodes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add some comments here? In general, the team try to have all the new functions covered by comments

Copy link
Contributor

@QilongTang QilongTang left a comment

Choose a reason for hiding this comment

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

Looks solid to me, waiting for @aparajit-pratap @saintentropy to comment

@QilongTang
Copy link
Contributor

QilongTang commented Feb 28, 2025

The Jira ticket check fails when Jira issue is not part of the PR title, I will do an example fix for you. When Jira issue correctly referenced in PR title, this PR will be linked to Jira task correctly for future reference

@QilongTang QilongTang changed the title cleanup dependency graph from old nodes DYN-8358 cleanup dependency graph from old nodes Feb 28, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-8358

@mjkkirschner
Copy link
Member

seems like some real test failures.

@QilongTang
Copy link
Contributor

seems like some real test failures.

yup, @chubakueno are you able to access PR check test failures?


var guids = new List<Guid>();
var guids = new HashSet<Guid>();
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps guids should remain a list ? we're only adding and we return a list

@QilongTang
Copy link
Contributor

Do you have the reported failure test Dynamo.Tests.Models.NodeModelWarningsTest.CombinedBuildAndRuntimeWarnings passing locally?

{
var nodes = runnerCore.CodeBlockList[(int)Language.Associative].instrStream.dependencyGraph.GetGraphNodesAtScope(Constants.kInvalidPC, Constants.kInvalidPC);
//delete all nodes which were redefined. For those nodes that were defined for the first time, this will be a no-op
nodes.RemoveAll(x=>!x.isActive || pendingUIDsForDeletion.Contains(x.guid));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this enough ? Isn't it possible that the children or parents of each node contain references to the nodes we remove ?
So should we also remove pendingUIDsForDeletion from the children and parents of each node ?

@BogdanZavu
Copy link
Contributor

Looks solid to me, waiting for @aparajit-pratap @saintentropy to comment

Same here. The dependency graph still grows but at a much slower rate.
We would like some blessings from the people who spent more time in this area.

@@ -1721,6 +1728,14 @@ private void SynchronizeInternal(GraphSyncData syncData)
var guids = runtimeCore.ExecutedAstGuids.ToList();
executedAstGuids[syncData.SessionID] = guids;
runtimeCore.RemoveExecutedAstGuids();

// There should be a CodeBlock in CodeBlockList by now
if (runnerCore.CodeBlockList.Any())
Copy link
Contributor

Choose a reason for hiding this comment

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

we can also check here is pendingUIDsForDeletion is empty

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.

5 participants