Improve efficiency of arranging nodes #34
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As the number of nodes and links increase, some performance issues become apparent in the ~100 to ~1000 range.
The performance particularly suffers when the number of links to a join geometry node increases.
Both tree 1 and tree 2 here have ~1000 nodes and ~1000 links but tree 2 has more links going into a single join geometry node.
Time to Generate Topo Sorted Columns of Nodes
The performance enhancement is mostly due to avoiding repetitive use of the 'links' property of the NodeSocket class which is currently being invoked for every node input of each node. This is problematic since the links property iterates through all the links of the nodetree. In the new implementation, direct iteration over the links occurs only once to create a graph structure which is then used to topologically sort the nodes.
Other bottlenecks occur at the >1k nodes range.
For example, both running the update function on a node and setting its location
each take about 1.5 seconds on a node tree with 1k nodes but 20 seconds each with 3k nodes (some very weird super quadratic complexity going on here).
I'm not really sure if
node.update()
is required though. I've tried commenting it out and everything seemed fine ¯\_(ツ)_/¯