WASasquatch / was-node-suite-comfyui

An extensive node suite for ComfyUI with over 210 new nodes
MIT License
1.23k stars 178 forks source link

WAS Node Suite extremely slow to load on startup (3.9s) #281

Open oxysoft opened 1 year ago

oxysoft commented 1 year ago

Hi, I would like to report the poor performance of this node suite for startup / initialization, as you can see from this line in my log:

   3.9 seconds: D:\Projects\ComfyUI_windows_portable\ComfyUI\custom_nodes\was-node-suite-comfyui  

That is almost 4x as long as the next one in my list, so I highly recommend that an investigation be done to understand what is taking so long.

WASasquatch commented 1 year ago

You do realize the sheer size of WAS Node Suite, right? It's the largest custom node suite for ComfyUI.

Not to mention 4s is nothing to write home about... This is even used on prod for commercial uses.

There is I/O checking (settings) which is only as fast as the HDD it's deployed on, and then package checks on whether it should even import X or not using pip freeze, so if your env is blogged down, that'll be a blogged down call too.

oxysoft commented 1 year ago

I am well aware, but most workflows require maybe 1 or 2 node max from this suite at once, so there is clearly room for optimization if not downright splitting up the project. You've encouraged people to use a giant monolithic codebase, and now everybody assumes you have it when sharing their workflows.

If you have done everything you can and the overhead is simply from registering all the classes (which it probably is, because I can see that your imports are clean) surely it is time to discuss with comfyanonymous about a lazy loading mechanism for nodes. I mean in the grand scheme of things, registering thousands of nodes on startup when the user will only be using 20-30 throughout their session seems really really sus.

Four seconds is a huge deal, the ultimate state of quality is to have instantaneous startup - open the batch file and immediately the web page opens. All these delays seriously impact my ability to work as an artist, when the creative stroke comes out of nowhere you don't have forever to actuate on it, you have to be fast. We can't just keep the Comfy UI server open all the time because it takes up major RAM and VRAM.

WASasquatch commented 1 year ago

I am simply not worried about 3.9s as a one time thing during startup. Sorry. Lol that is ridiculous to make a issue report about. It also takes 1.2s for me so I am assuming your system is slower for this sort of thing, or a slow HDD.

Your report has nothing to do with the operation of nodes in the flow, and is obsessive over startup times. It takes seconds for ComfyUI Manager to process prestartup scripts even though it does nothing, and everyone has that too. It's a startup procedure. Most software takes a bit to startup in DCC (digital content creation) field.

poisenbery commented 1 year ago

image

This isn't a "Bug" this is a skill issue.

Your report has nothing to do with the operation of nodes in the flow

This is becoming very common in the AI scene

kunibald413 commented 12 months ago

caching the packages in WAS_Node_Suite.py can save some time on startup (on my setup a few secs)

# Freeze PIP modules
_packages_cached = None
def packages(versions=False):
    global _packages_cached
    if not _packages_cached:
        import sys
        import subprocess
        _packages_cached = [( r.decode().split('==')[0] if not versions else r.decode() ) for r in subprocess.check_output([sys.executable, '-s', '-m', 'pip', 'freeze']).split()]
    return _packages_cached
bigcat88 commented 4 days ago

Is it possible to add an environment flag, in which case if it is set when the node is launched, there will be no checks at all whether something is set(scipy, opencv) or not?

Specifically, all calls to packages() which creates a new process each time it is called?

If the environment flag is unacceptable, we can check for the presence of some file that will be a flag(like some nodes are checking for presence empty file skip_download_model).

If necessary, I can make a PR, but I need to know which type of solution will be acceptable, and this is a matter of taste.

Without commented calls to "packages()" in my local setup this node takes from 1 to 1.1 seconds to load, with commented ones from 0.3 to 0.4, the difference is more than 2.5 times...


And thanks for the wonderful set of nodes.

WASasquatch commented 3 days ago

I think I had a PR I was working on to remove it. I don't believe it's needed anymore, could be wrong though, lots of custom code I did converting HLSL and other shader stuff to python.

On Thu, Nov 28, 2024, 9:00 AM Alexander Piskun @.***> wrote:

Is it possible to add an environment flag, in which case if it is set when the node is launched, there will be no checks at all whether something is set(scipy, opencv) or not?

Specifically, all calls to packages() which creates a new process each time it is called?

If the environment flag is unacceptable, we can check for the presence of some file that will be a flag(like some nodes are checking for presence empty file skip_download_model).

If necessary, I can make a PR, but I need to know which type of solution will be acceptable, and this is a matter of taste.

Without commented calls to "packages()" in my local setup this node takes from 1 to 1.1 seconds to load, with commented ones from 0.3 to 0.4, the difference is more than 2.5 times...

And thanks for the wonderful set of nodes.

— Reply to this email directly, view it on GitHub https://github.com/WASasquatch/was-node-suite-comfyui/issues/281#issuecomment-2506520139, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIZEZOY7R543BRAX6M7X7T2C5D4NAVCNFSM6AAAAABSVRRKAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBWGUZDAMJTHE . You are receiving this because you commented.Message ID: @.***>