vivax3794 / ComfyUI-Sub-Nodes

Finally sub nodes in comfy!
120 stars 4 forks source link

every queue the subgraph will re generate again even no change #11

Closed xueqing0622 closed 1 month ago

xueqing0622 commented 1 month ago

every queue the subgraph will re generate again even no change

MatissesProjects commented 1 month ago

can you provide more information on this? Do you want subgraphs to be skipped if they would not be computing something new?

xueqing0622 commented 1 month ago

the subgraph pass even no change still re generate, I think that is waste, and not right for workflow. And no information for cmd window, just green line pass, re generate again.

vivax3794 commented 1 month ago

This is a surprisingly hard issue to solve, atm subgraphs are always ran as you pointed out, this is by design. the reason is that every node type can define their own logic for when they have "changed", you might think a reasonable one for us is just "when the workflow file is edited", but what if you edit a workflow file that is used by that subgraph? well we would basically have to evaluate the IS_CHANGED of every node in the subgraph, and while it could be done, it gets ugly real quick.

the core issue is that we dont want to repeat work we already have the results for, which is why there is caching logic in comfy, the issue is that there is only one cache at a time, I have now made a change that makes sure the caches for subgraphs stay alive longer that I will push alongside a bunch of other updates later today, this will result is higher memory usage unfortunately (but thats kinda a given), subgraphs will still be always be executed, but comfys caching logic should make sure no work is needlessly duplicated.

the main issue with this approach is cache invalidation (when is it ever not a issue), I do not want to keep stuff in cache forever, I will see what I can cook up.

vivax3794 commented 1 month ago

This is now implemented in the latest version

xueqing0622 commented 1 month ago

Yes, It works. Thx