mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-03-13 22:31:08 +00:00
Reduce repeated calls of get_immediate_node_signature for ancestors in cache (#4871)
This commit is contained in:
parent
7c6eb4fb29
commit
f6b7194f64
@ -67,6 +67,7 @@ class CacheKeySetInputSignature(CacheKeySet):
|
|||||||
super().__init__(dynprompt, node_ids, is_changed_cache)
|
super().__init__(dynprompt, node_ids, is_changed_cache)
|
||||||
self.dynprompt = dynprompt
|
self.dynprompt = dynprompt
|
||||||
self.is_changed_cache = is_changed_cache
|
self.is_changed_cache = is_changed_cache
|
||||||
|
self.immediate_node_signature = {}
|
||||||
self.add_keys(node_ids)
|
self.add_keys(node_ids)
|
||||||
|
|
||||||
def include_node_id_in_input(self) -> bool:
|
def include_node_id_in_input(self) -> bool:
|
||||||
@ -94,6 +95,8 @@ class CacheKeySetInputSignature(CacheKeySet):
|
|||||||
if not dynprompt.has_node(node_id):
|
if not dynprompt.has_node(node_id):
|
||||||
# This node doesn't exist -- we can't cache it.
|
# This node doesn't exist -- we can't cache it.
|
||||||
return [float("NaN")]
|
return [float("NaN")]
|
||||||
|
if node_id in self.immediate_node_signature: # reduce repeated calls of ancestors
|
||||||
|
return self.immediate_node_signature[node_id]
|
||||||
node = dynprompt.get_node(node_id)
|
node = dynprompt.get_node(node_id)
|
||||||
class_type = node["class_type"]
|
class_type = node["class_type"]
|
||||||
class_def = nodes.NODE_CLASS_MAPPINGS[class_type]
|
class_def = nodes.NODE_CLASS_MAPPINGS[class_type]
|
||||||
@ -108,6 +111,7 @@ class CacheKeySetInputSignature(CacheKeySet):
|
|||||||
signature.append((key,("ANCESTOR", ancestor_index, ancestor_socket)))
|
signature.append((key,("ANCESTOR", ancestor_index, ancestor_socket)))
|
||||||
else:
|
else:
|
||||||
signature.append((key, inputs[key]))
|
signature.append((key, inputs[key]))
|
||||||
|
self.immediate_node_signature[node_id] = signature
|
||||||
return signature
|
return signature
|
||||||
|
|
||||||
# This function returns a list of all ancestors of the given node. The order of the list is
|
# This function returns a list of all ancestors of the given node. The order of the list is
|
||||||
|
Loading…
Reference in New Issue
Block a user