liusida / StoneSoup

StoneSoup is an open-source, flexible platform for AI workflows and experimentation. It focuses on plugin-centric development and extensibility, enabling users to easily test various methods and parameters in their AI projects.
MIT License
5 stars 1 forks source link

To avoid recompute as much as possible. #3

Open liusida opened 1 month ago

liusida commented 1 month ago

Currently, any server-side node sends a request to the server every time it is executed. Figure out a way to avoid that as much as possible. This is key to the efficiency of ComfyUI.

Future me, how to make nodes dirty and how to manage the status of all nodes. Think carefully.

liusida commented 1 month ago

In ComfyUI, the server compares the current workflow and the workflow from the last execution. The server search for discrepancy recursively.

Here we are going to do this in Javascript.

Whenever a node is changed, trigger an onChange function, and set all its output nodes to changed, and hence trigger a chain of onChange functions of its following nodes.

When onAction, if the node is not changed, use the cache and move on.

I think that is the basic principle.

liusida commented 1 month ago

so I've named the property complete.

So, everytime a node is computed, it sets its complete to true. And if next time this is true, skip computing and trigger the next node directly.

While something changed in this node, change the complete to false, and trigger the onChange() function of all the nodes next to this one. This function will return if the node doesn't have a complete or complete is false. otherwise, keep passing the signal to their children.