anapnoe / stable-diffusion-webui-ux

Stable Diffusion web UI UX
GNU Affero General Public License v3.0
989 stars 58 forks source link

[Bug]: slow initial page load time in recent builds #166

Closed halr9000 closed 11 months ago

halr9000 commented 1 year ago

Is there an existing issue for this?

What happened?

Seeing about 7.53 seconds of nothing as per this trace. I don't have time to compare to prev builds but it is noticeably longer. I loaded up sd-ui (auto1111) for comparison and it came right up.

Screenshot 2023-06-02 220832

I am no good at interpreting these traces but you can load this one up and perhaps its helpful. Trace-20230602T220129.zip

Steps to reproduce the problem

  1. start service, wait for it to show ip
  2. open web ui
  3. observe slow load time

Can repro on 3 diff platforms/devices.

What should have happened?

Entire page should load in 3-5 s as previous. It's taking closer to 13 sec total.

Commit where the problem happens

9931e861dfb128735c4a928a7beb5b5c0af30593

What Python version are you running on ?

Python 3.10.x

What platforms do you use to access the UI ?

Windows, MacOS, Android

What device are you running WebUI on?

No response

What browsers do you use to access the UI ?

No response

Command Line Arguments

Launching Web UI with arguments: --listen --enable-insecure-extension-access --no-half --api --xformers --update-all-extensions --ckpt-dir=D:\hal\stable-diffusion\models\Stable-diffusion --lora-dir=D:\hal\stable-diffusion\models\Lora --embeddings-dir=D:\hal\stable-diffusion\models\Embeddings --hypernetwork-dir=D:\hal\stable-diffusion\models\Hypernetworks --styles-file=D:\hal\stable-diffusion\other-bits\styles.csv --update-check

List of extensions

a1111-mini-paint a1111-sd-webui-lycoris a1111-sd-webui-tagcomplete model_preset_manager multidiffusion-upscaler-for-automatic1111 sd-dynamic-prompts sd-extension-system-info sd-webui-ar sd-webui-controlnet sd-webui-enable-checker sd-webui-regional-prompter sd-webui-stablesr Stable-Diffusion-Webui-Civitai-Helper stable-diffusion-webui-images-browser stable-diffusion-webui-randomize

Console logs

venv "D:\hal\stable-diffusion\ux\venv\Scripts\Python.exe"
fatal: No names found, cannot describe anything.
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb  7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]
Version: <none>
Commit hash: 9931e861dfb128735c4a928a7beb5b5c0af30593
Installing requirements
Requirement already satisfied: send2trash~=1.8 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (1.8.0)
Requirement already satisfied: dynamicprompts[attentiongrabber,magicprompt]~=0.27.0 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (0.27.0)
Requirement already satisfied: jinja2~=3.1 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (3.1.2)
Requirement already satisfied: pyparsing~=3.0 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (3.0.9)
Requirement already satisfied: transformers[torch]~=4.19 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (4.25.1)
Requirement already satisfied: MarkupSafe>=2.0 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from jinja2~=3.1->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (2.1.2)
Requirement already satisfied: filelock in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (3.12.0)
Requirement already satisfied: huggingface-hub<1.0,>=0.10.0 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (0.13.4)
Requirement already satisfied: numpy>=1.17 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (1.23.5)
Requirement already satisfied: packaging>=20.0 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (23.1)
Requirement already satisfied: pyyaml>=5.1 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (6.0)
Requirement already satisfied: regex!=2019.12.17 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (2023.5.5)
Requirement already satisfied: requests in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (2.31.0)
Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (0.13.3)
Requirement already satisfied: tqdm>=4.27 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (4.65.0)
Requirement already satisfied: torch!=1.12.0,>=1.7 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (2.0.0+cu118)
Requirement already satisfied: typing-extensions>=3.7.4.3 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from huggingface-hub<1.0,>=0.10.0->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (4.5.0)
Requirement already satisfied: sympy in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from torch!=1.12.0,>=1.7->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (1.11.1)
Requirement already satisfied: networkx in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from torch!=1.12.0,>=1.7->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (3.1)
Requirement already satisfied: colorama in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from tqdm>=4.27->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (0.4.6)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from requests->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from requests->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (2.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from requests->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from requests->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (2022.12.7)
Requirement already satisfied: mpmath>=0.19 in d:\hal\stable-diffusion\ux\venv\lib\site-packages (from sympy->torch!=1.12.0,>=1.7->transformers[torch]~=4.19->dynamicprompts[attentiongrabber,magicprompt]~=0.27.0) (1.3.0)
sd-dynamic-prompts installer: running 'D:\hal\stable-diffusion\ux\venv\Scripts\python.exe' -m pip install 'send2trash~=1.8' 'dynamicprompts[attentiongrabber,magicprompt]~=0.27.0'

--------------------------------------------------------
| You are not up to date with the most recent release. |
| Consider running `git pull` to update.               |
--------------------------------------------------------
Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\a1111-mini-paint':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\a1111-sd-webui-lycoris':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\a1111-sd-webui-tagcomplete':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\model_preset_manager':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\multidiffusion-upscaler-for-automatic1111':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\sd-dynamic-prompts':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\sd-extension-system-info':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\sd-webui-ar':
Already up to date.

remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 8 (delta 3), reused 8 (delta 3), pack-reused 0
Unpacking objects: 100% (8/8), 3.32 KiB | 179.00 KiB/s, done.
From https://github.com/Mikubill/sd-webui-controlnet
   84e92d0..3c41f15  main       -> origin/main
Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\sd-webui-controlnet':
Updating 84e92d0..3c41f15
Fast-forward

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\sd-webui-enable-checker':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\sd-webui-regional-prompter':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\sd-webui-stablesr':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\Stable-Diffusion-Webui-Civitai-Helper':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\stable-diffusion-webui-images-browser':
Already up to date.

Pulled changes for repository in 'D:\hal\stable-diffusion\ux\extensions\stable-diffusion-webui-randomize':
Already up to date.

Launching Web UI with arguments: --listen --enable-insecure-extension-access --no-half --api --xformers --update-all-extensions --ckpt-dir=D:\hal\stable-diffusion\models\Stable-diffusion --lora-dir=D:\hal\stable-diffusion\models\Lora --embeddings-dir=D:\hal\stable-diffusion\models\Embeddings --hypernetwork-dir=D:\hal\stable-diffusion\models\Hypernetworks --styles-file=D:\hal\stable-diffusion\other-bits\styles.csv --update-check
Civitai Helper: Get Custom Model Folder
Civitai Helper: Load setting from: D:\hal\stable-diffusion\ux\extensions\Stable-Diffusion-Webui-Civitai-Helper\setting.json
Civitai Helper: No setting file, use default
ControlNet v1.1.213
ControlNet v1.1.213
Loading weights [1eb67dbd14] from D:\hal\stable-diffusion\models\Stable-diffusion\sd15\aZovyaRPGArtistTools_v2Offset.safetensors
Create LRU cache (max_size=16) for preprocessor results.
Creating model from config: D:\hal\stable-diffusion\ux\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Create LRU cache (max_size=16) for preprocessor results.
Applying optimization: xformers... done.
Textual inversion embeddings loaded(40): 16-token-negative-deliberate-neg, AS-Adult-neg, AS-Young-neg, Asian-Less, Asian-Less-Neg, Athena-the-Puppy, Athena-the-Puppy-neg, bad_prompt_version2-neg, BadDream, Bsft, dangerdonkey, dog-athena, dog-athena-neg, easynegative, FastNegativeEmbedding, fractal-flame, gothbuilding, hrgiger-drmacabre, Isometric_Dreams, kc16-4000-sd1-5, kkw-micro, negative_hand-neg, ng_deepnegative_v1_75t, photozoov15, Planit, qualityzoov15, renderzoov15, st4rl0rd, structurezoov15, Style-Glass, Style-Info, style-paintmagic, Style-Psycho, Style-Renaissance, style-rustmagic, Style-Winter, UnrealisticDream, vintagemap_f, was-dieselpunk, was-mecha
Textual inversion embeddings skipped(11): badquality, dangerhorse, Neg_Facelift768, nfixer, nrealfixer, photozoov21, DrD_PNTE768, Painted_Landscape, ParchArt, Davespacefour, Knollingcase
Model loaded in 14.3s (load weights from disk: 0.2s, create model: 0.4s, apply weights to model: 8.0s, move model to device: 3.5s, load textual inversion embeddings: 2.0s).
Running on local URL:  http://0.0.0.0:7860

To create a public link, set `share=True` in `launch()`.
Create LRU cache (max_size=16) for preprocessor results.
Startup time: 33.0s (import torch: 2.7s, import gradio: 1.3s, import ldm: 0.8s, other imports: 1.4s, setup codeformer: 0.1s, load scripts: 3.3s, create ui: 15.9s, gradio launch: 7.4s).

Additional information

No response

anapnoe commented 1 year ago

can you test diff without extensions? it seems that something hasn't been updated you should always test bare bones, many plugins can cause delays and when a new gradio version introduce some adjustments need to be made. There is no a standard way how extensions are hooked and if uiupdate function is used for init without setinterval / clearinterval init may happen more than once

stable-diffusion-webui-images-browser hasn't been updated for six months use infinite image browser

halr9000 commented 1 year ago

can you test diff without extensions?

great idea, will report back

stable-diffusion-webui-images-browser hasn't been updated for six months use infinite image browser

hey now, I'm not that dense lol. I see you can't tell from the report, but I'm running this fork https://github.com/AlUlkesh/stable-diffusion-webui-images-browser which is actually well-maintained (ref). I tried infinite for a while and it is cool, but bugs me in some of the ways it works so I reverted back.

halr9000 commented 1 year ago

Trying something slightly different, I like the performance insights tab in dev tools a bit better as it's getting more to the point in a way I understand. Ok, looking at LCP (largest contentful paint, which is a way they determine programmatically when the page is probably ready/did the most work):

Description Time
With extensions 13.47 s
Without extensions 3.06 s (!)

Now...to figure out why. Sharing the profiles below, would love if you can give me some tips for how to determine which of the extensions might be at fault, other than one-by-one tediously doing before/after tests. (Which I'll do if I get annoyed enough, but would rather be smarter about it.)

image Profile-20230612T052138-with-extensions.json.gz

Without extensions: image Profile-20230612T053406-without.json.gz

anapnoe commented 1 year ago

I will have a look into it but probably is this one stable-diffusion-webui-images-browser as an alternative you can install the infinite image browser extension

halr9000 commented 1 year ago

Disabled the image browser plugin and there's still a big delay. I'll keep researching to see if I can isolate which extension is the trigger. But if this happens to be helpful:

See right column:

image