Open liusida opened 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.
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.
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.