mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-18 01:53:31 +00:00
Put node_info caching in memory,and now 30x speedup when loading the page.
This commit is contained in:
parent
d40ac012bc
commit
4b2b24906a
@ -21,6 +21,7 @@ from io import BytesIO
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import logging
|
import logging
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from comfy.cli_args import args
|
from comfy.cli_args import args
|
||||||
@ -552,6 +553,7 @@ class PromptServer():
|
|||||||
async def get_prompt(request):
|
async def get_prompt(request):
|
||||||
return web.json_response(self.get_queue_info())
|
return web.json_response(self.get_queue_info())
|
||||||
# use getattr speedup 2x times in load node info
|
# use getattr speedup 2x times in load node info
|
||||||
|
@lru_cache(maxsize=None)
|
||||||
def node_info(node_class):
|
def node_info(node_class):
|
||||||
obj_class = nodes.NODE_CLASS_MAPPINGS[node_class]
|
obj_class = nodes.NODE_CLASS_MAPPINGS[node_class]
|
||||||
input_types = obj_class.INPUT_TYPES()
|
input_types = obj_class.INPUT_TYPES()
|
||||||
@ -587,6 +589,11 @@ class PromptServer():
|
|||||||
except Exception:
|
except Exception:
|
||||||
logging.error(f"[ERROR] An error occurred while retrieving information for the '{x}' node.")
|
logging.error(f"[ERROR] An error occurred while retrieving information for the '{x}' node.")
|
||||||
logging.error(traceback.format_exc())
|
logging.error(traceback.format_exc())
|
||||||
|
|
||||||
|
# Debug node_info in the current memory cache
|
||||||
|
#cache_stats = node_info.cache_info()
|
||||||
|
#print(f"node_info Cache Hits: {cache_stats.hits}, Misses: {cache_stats.misses}, Current Memory Cache Size: {cache_stats.currsize}")
|
||||||
|
|
||||||
response = web.json_response(out)
|
response = web.json_response(out)
|
||||||
response.enable_compression()
|
response.enable_compression()
|
||||||
return response
|
return response
|
||||||
|
Loading…
Reference in New Issue
Block a user