Skip to content

Commit f6b7194

Browse files
authored
Reduce repeated calls of get_immediate_node_signature for ancestors in cache (#4871)
1 parent 7c6eb4f commit f6b7194

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

comfy_execution/caching.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(self, dynprompt, node_ids, is_changed_cache):
6767
super().__init__(dynprompt, node_ids, is_changed_cache)
6868
self.dynprompt = dynprompt
6969
self.is_changed_cache = is_changed_cache
70+
self.immediate_node_signature = {}
7071
self.add_keys(node_ids)
7172

7273
def include_node_id_in_input(self) -> bool:
@@ -94,6 +95,8 @@ def get_immediate_node_signature(self, dynprompt, node_id, ancestor_order_mappin
9495
if not dynprompt.has_node(node_id):
9596
# This node doesn't exist -- we can't cache it.
9697
return [float("NaN")]
98+
if node_id in self.immediate_node_signature: # reduce repeated calls of ancestors
99+
return self.immediate_node_signature[node_id]
97100
node = dynprompt.get_node(node_id)
98101
class_type = node["class_type"]
99102
class_def = nodes.NODE_CLASS_MAPPINGS[class_type]
@@ -108,6 +111,7 @@ def get_immediate_node_signature(self, dynprompt, node_id, ancestor_order_mappin
108111
signature.append((key,("ANCESTOR", ancestor_index, ancestor_socket)))
109112
else:
110113
signature.append((key, inputs[key]))
114+
self.immediate_node_signature[node_id] = signature
111115
return signature
112116

113117
# This function returns a list of all ancestors of the given node. The order of the list is

0 commit comments

Comments
 (0)