ComfyUI_Custom_Nodes_AlekPet icon indicating copy to clipboard operation
ComfyUI_Custom_Nodes_AlekPet copied to clipboard

Node loading is slow.

Open zhangp365 opened this issue 1 year ago • 8 comments

Loading this customer node takes more than 10 seconds, perhaps some adjustments to the logic could be considered 20240123142745

zhangp365 avatar Jan 23 '24 06:01 zhangp365

Hello. The fact is that the argotranslate uses a neural network and it installs all sorts of different things, you can simply delete it if you don’t use it, it just doesn’t save all the dependencies in the python environment.

AlekPet avatar Jan 23 '24 19:01 AlekPet

Yes, this node took me about six or seven seconds to load, which is the longest load time of any node I have installed so far. However, if I delete the argotranslate module, the entire ComfyUI_Custom_Nodes_AlekPet node will also fail to start..... Or it will be overwritten in the next update

Pythonpa avatar Jul 24 '24 03:07 Pythonpa

This is due to the import of ArgosTranslate specified in init.py and insertion into mapping. https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L231-L234

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L250-L251

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L266-L267

AlekPet avatar Jul 24 '24 06:07 AlekPet

This is due to the import of ArgosTranslate specified in init.py and insertion into mapping. https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L231-L234

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L250-L251

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L266-L267

I don't think importing class and updating dict are time cost operations. In fact, I suspect the slow load is due to the module install procedure when checking modules as the following code shows:

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/d8629270c944f2328d890d03a6a73e14c428ef75/init.py#L79-L95

The module_install function creates one subprocess and two threads which are a little heavy. Maybe the two threads are not necessary if using subprocess.check_call or subprocess.check_output instead of subprocess.Popen

Maslino avatar Jul 24 '24 09:07 Maslino

This is due to the import of ArgosTranslate specified in init.py and insertion into mapping. https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L231-L234

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L250-L251

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L266-L267

I don't think importing class and updating dict are time cost operations. In fact, I suspect the slow load is due to the module install procedure when checking modules as the following code shows:

https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/d8629270c944f2328d890d03a6a73e14c428ef75/init.py#L79-L95

The module_install function creates one subprocess and two threads which are a little heavy. Maybe the two threads are not necessary if using subprocess.check_call or subprocess.check_output instead of subprocess.Popen

There is no line from the code I provided, I thought you wanted to turn off ArgosTranslate, after delete folder in custom_nodes. Let's see what we can do.

AlekPet avatar Jul 24 '24 16:07 AlekPet

This is due to the import of ArgosTranslate specified in init.py and insertion into mapping. https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L231-L234 https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L250-L251 https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/master/init.py#L266-L267

I don't think importing class and updating dict are time cost operations. In fact, I suspect the slow load is due to the module install procedure when checking modules as the following code shows: https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/d8629270c944f2328d890d03a6a73e14c428ef75/init.py#L79-L95

The module_install function creates one subprocess and two threads which are a little heavy. Maybe the two threads are not necessary if using subprocess.check_call or subprocess.check_output instead of subprocess.Popen

There is no line from the code I provided, I thought you wanted to turn off ArgosTranslate, after delete folder in custom_nodes. Let's see what we can do.

Oh, I misunderstood it. After deleting sub folder, some code in init.py should also be deleted. What I mentioned foreward may be another perfomance optimization point.

Maslino avatar Jul 25 '24 00:07 Maslino

Yes, that’s right, you need to remove the folder from the ComfyUi_Custom_Nodes_Alekpet/ArgosTranslate folder and delete or comment out those lines where argos is imported into __init_.py. There is another way - download the old __init__.py (https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet/blob/67b2134fb5d87d820c6c075c4015371871d8b9e3/init.py) and replace the original one, where nodes were added to my mapping automatically and also delete the folder. And this line change extensions_dirs_copy = ['js','assets', 'lib','css']

AlekPet avatar Jul 25 '24 05:07 AlekPet

Updated __init__.py, added check for already installed modules and other code optimizations

AlekPet avatar Jul 27 '24 09:07 AlekPet