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

Sverchok Node Tree Updates needlessly #4576

Closed
wassimj opened this issue Jul 17, 2022 · 15 comments
Closed

Sverchok Node Tree Updates needlessly #4576

wassimj opened this issue Jul 17, 2022 · 15 comments
Labels

Comments

@wassimj
Copy link

wassimj commented Jul 17, 2022

Problem statement

With the latest version of sverchok, it seems anytime I connect a new node, existing nodes that are on a separate unrelated branch get updated which slows down all execution.

For any other issues, or if the installation still failed; Please describe the problem here.

Steps to reproduce

  1. Create a node tree that is time consuming to complete
  2. Add a new node and connetc

Expected result

Only the affected/downstream nodes to be updated

Actual result

Unrelated nodes get updated.

Sverchok version

Latest from downloading from the Green Code button as a ZIP file

@Durman
Copy link
Collaborator

Durman commented Jul 18, 2022

Could you upload a file with such problem?

@wassimj
Copy link
Author

wassimj commented Jul 18, 2022

I was recording a video and noticed the exact behaviour: If you connect a second output to the same output socket, then all nodes that were previously connected to that output socket get updated. This can cause a cascade of un-necessary updates. To test:

  1. Create a Sphere node with U=500 and V=500 (to slow it down)
  2. Attach a Stethoscope to the Vertices output socket
  3. Attach a Matrix Out to the Vertices output socket
    You will notice that the Stethoscope node also gets re-updated when it shouldn't (See the messages on top left about what nodes are being updated)

@Durman
Copy link
Collaborator

Durman commented Jul 18, 2022

Now it's clear and ,actually, it's intendent behavior for now, but of cause it should be improved in future.

The problem is that many nodes uses next optimization:

def process(self):
    if not self.any_ouputs_linked:
        return
    ...
    if self.outputs[0].is_linked:
        self.outputs[0].sv_set(data)
    if self.outputs[1].is_linked:
        self.outputs[1].sv_set(data)

It means that update system should process the node not only when input data was changed bat also when output connection was changed. It of cause leads to redundant calculations.

We can either:

@wassimj
Copy link
Author

wassimj commented Jul 18, 2022

Thank you. From a user perspective, the cost can be really high if the existing chain of nodes is long and/or time-consuming to compute.

@wassimj
Copy link
Author

wassimj commented Jul 26, 2022

By the way, even dragging and dropping a new node seems to trigger updates. It has slowed down the workflow considerably. I would appreciate an urgent look at this if it can be remedied. I currently have a node that has 1200 wires in it and if I simply connect another node to it, I have to wait a few minutes for it to re-update. Thank you!

@Durman
Copy link
Collaborator

Durman commented Jul 27, 2022

I thought to wait with the fix for next Sverchok version because it requires a lot of small changes and can bring some instability. But probably what I can do now is to add some temporary node attribute which would mark a node for update system that it should not be updated when its output sockets are connected. In this case you have to add the attribute to all nodes which should not be updated.

@wassimj
Copy link
Author

wassimj commented Jul 27, 2022

I think I would wait for next release because I don’t control the code for all nodes. So if my workflow depends on an OOTB node and that node is connected to a time consuming Topologic node, I would still face the same problem because the input socket data ‘changed’. Thank you for looking at this and solving it. Also please look at why dragging and dropping a new disconnected node sometimes triggers an update and the GUI freezes until the update is done. In that case no sockets are connected to trigger an update. Weird.

@Durman
Copy link
Collaborator

Durman commented Jul 28, 2022

I see what you mean. In an example below the nodes will be called each time when new node is added to the tree. This because Get Objects Data uses scene update handler. Unfortunately the handler does not produce information about what exactly was change in a scene and it's difficult to filter out specific events. I'll have a look what can be done.

image

@Durman Durman added the todo label Jul 28, 2022
@Durman Durman closed this as completed in 70cd8f1 Aug 4, 2022
@wassimj
Copy link
Author

wassimj commented Aug 4, 2022

I downloaded the latest sverchok software using the green code button then download ZIP and installed. Sadly this does not seem to be resolved. If you notice in the attached images, if I add a second stethoscope, the Vertex.ByCoordinates node re-triggers and creates a brand new vertex with a different address
vertex01
vertex02
.

@Durman
Copy link
Collaborator

Durman commented Aug 4, 2022

You've reported two problems here, I fixed one of them believe.

Another problem should be fixed within #4322
But I'm not sure when such changes should be introduce because they way I think to implement them might broke all other Sverchok add-ons.
The simplest way, as I said, is to remove extra checks inside nodes and I'm not against it but I guess that @portnov @zeffii @vicdoval think that they are must have.

@wassimj
Copy link
Author

wassimj commented Aug 4, 2022

Apologies for the confusion. Can you please explain what the two problems are and which one is fixed? Thank you.

@wassimj
Copy link
Author

wassimj commented Aug 4, 2022

I just modified the code inside my Vertex.ByCoordinates to remove the check for output links and actually it makes it worse. It still re-triggers the node and therefore can create three different outputs: 1 when the node is created, 2 when an output is connected, 3 when a second output is connected and so on and so forth.
step01
step02
step03

@Durman
Copy link
Collaborator

Durman commented Aug 4, 2022

All described above behavior, as I said, is expected for now.

Apologies for the confusion. Can you please explain what the two problems are and which one is fixed? Thank you.

I mean this.

Also please look at why dragging and dropping a new disconnected node sometimes triggers an update and the GUI freezes until the update is done. In that case no sockets are connected to trigger an update. Weird.

@wassimj
Copy link
Author

wassimj commented Aug 4, 2022

ok thank you. My current workaround for now is when I create a node, I immediately mute it (by pressing M on it), connect all the nodes that need to emanate from it, then unmute it to see the result without having to create multiple copies of the output.

@Durman
Copy link
Collaborator

Durman commented Aug 4, 2022

I'm sorry you have to do all this and I hope that Sverchok will get improvement in this area once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants