-
Notifications
You must be signed in to change notification settings - Fork 636
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-6449 Graph Loading Performance Improving #14929
DYN-6449 Graph Loading Performance Improving #14929
Conversation
Using Jetbrains dotTrace I noticed that creating the NodeView for Watch nodes was taking too much time when loading the Graph (due that was creating the PreviewControl), then due that Watch nodes doesn't have Preview I've added code for preventing the creation of the PreviewControl, this improved the Graph loading time. Also I've noticed that the call nodeView.UpdateLayout() was consuming loading time so I've modified the code in a way that the method call will be executed asynchronous in background.
UI Smoke TestsTest: success. 2 passed, 0 failed. |
src/DynamoCoreWpf/NodeViewCustomization/NodeViewCustomizations/FunctionNodeViewCustomization.cs
Outdated
Show resolved
Hide resolved
@@ -551,6 +551,9 @@ private void OnNodeViewMouseLeave(object sender, MouseEventArgs e) | |||
{ | |||
ViewModel.ZIndex = oldZIndex; | |||
|
|||
//Watch nodes doesn't have Preview so we should avoid to use any method/property in PreviewControl class due that Preview is created automatically | |||
if (ViewModel.NodeModel != null && ViewModel.NodeModel is CoreNodeModels.Watch) return; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another Idea would be to stop loading controls that are not immediately visible to the user (like context menu stuff, tooltips etc) These could be loaded on demand when the user interacts with the UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pinzart90 I think for this case we will need a specific Jira task since I noticed that just the PreviewControl is being used in several places and due to the current implementation of this property, when you use it automatically creates the instance.
For example in this piece of code when using PreviewControl.StaysOpen, the instance is created automatically:
This is the declaration of the Property and the references in code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, a lot of code assumes the existence of the PreviewControl. We should create a task for it if we can say for sure it would benefit performance.
It should either be properly refactored to be optional or create it hidden for certain node types (so that it does not contribute to the layout tree calculations) Not sure about the perf results of either.
Removing the nodeView.UpdateLayout(); call in the PythonNode.
I've done some testing using the dyn files located in |
@@ -59,7 +61,6 @@ public void CustomizeView(Function function, NodeView nodeView) | |||
|
|||
publishCustomNodeItem.Command = nodeView.ViewModel.DynamoViewModel.PublishSelectedNodesCommand; | |||
publishCustomNodeItem.CommandParameter = functionNodeModel; | |||
|
|||
nodeView.UpdateLayout(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this updateLayout call useful ?
Looks like the customization only creates some context menu items. THey do not appear to be updated when the customization is applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pinzart90 like the other case I don't know the purpose of calling UpdateLayout(); I think is the same author than the case of the Python node.
I leave it because in the dotTrace performance report showed that was not consuming too much time when loading the graph for this specific line (due that the graph provided had few custom nodes) but probably we should deleted also.
Do you suggest this call also could be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like it could be deleted. But maybe we should leave it for another task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also deleted this call, seems that was created by the same person that the Python node one.
a548050
Deleting not necessary call to nodeView.UpdateLayout() for CustomNodes
@@ -551,6 +551,9 @@ private void OnNodeViewMouseLeave(object sender, MouseEventArgs e) | |||
{ | |||
ViewModel.ZIndex = oldZIndex; | |||
|
|||
//Watch nodes doesn't have Preview so we should avoid to use any method/property in PreviewControl class due that Preview is created automatically | |||
if (ViewModel.NodeModel != null && ViewModel.NodeModel is CoreNodeModels.Watch) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this only apply to watch node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, When running dotTrace I noticed that we were creating the PreviewControl for Watch node when this kind of nodes doesn't have Preview.
Probably we will need to get a list of nodes that doesn't support preview or do you know if there is already a list?
@@ -59,8 +61,6 @@ public void CustomizeView(Function function, NodeView nodeView) | |||
|
|||
publishCustomNodeItem.Command = nodeView.ViewModel.DynamoViewModel.PublishSelectedNodesCommand; | |||
publishCustomNodeItem.CommandParameter = functionNodeModel; | |||
|
|||
nodeView.UpdateLayout(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this moved to other places based on your PR description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR description
@avidit I feel we need to test the cases where input ports were added/removed based on Python script change or custom drop downs etc |
Purpose
Improvements for loading a Graph in Dynamo
Using Jetbrains dotTrace I noticed that creating the NodeView for Watch nodes was taking too much time when loading the Graph (due that was creating the PreviewControl), then due that Watch nodes doesn't have Preview I've added code for preventing the creation of the PreviewControl, this improved the Graph loading time. Also I've noticed that the call nodeView.UpdateLayout() was consuming loading time so I deleted the calls to UpdateLayout since seems that is not needed
Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
Improvements for loading a Graph in Dynamo
Reviewers
@QilongTang
@reddyashish
FYIs
@Amoursol