r/StableDiffusion • • 11h ago

Resource - Update ComfyUI's long-session performance issues and a series of PRs to fix them

For some time I've had issues with ComfyUI becoming increasingly sluggish after running a lot of generations. Queueing a prompt could take 5-6 seconds, queue UI itself becoming laggy, the canvas would periodically freeze, even when stationary, and the generations themselves became progressively slower.

After investigating this extensively, I identified several performance issues in both ComfyUI and its frontend:

  • Repeated retrieval of unchanged job details. One of my network captures contained 4,744 job-detail requests amounting to 25 GB of traffic.
  • Backend history processing that scales with the entire retained history, even when the frontend only requests a small page. With 10,000 retained jobs, the patch reduced history retrieval latency from 312 ms to 34 ms and concurrent prompt submission latency from 307 ms to 36 ms.
  • Unnecessary serialization and transfer of entire job records, including workflow data and potentially massive custom node outputs, when the frontend only needs output descriptors.
  • Queue thumbnails loading original full-resolution images. With 21-megapixel generations, a single decoded image can occupy approximately 80 MiB of memory.
  • Unnecessary reconstruction of queue and history state, causing redundant frontend processing and cache churn.
  • Obsolete canvas preview requests and media decoding continuing after their results are no longer needed.
  • Duplicate LiteGraph rendering loops and animation callbacks surviving canvas restarts or unmounts.

There are now eight upstream PRs addressing these issues.

I've been running the combined patches for hundreds of generations now and the difference is enormous. No canvas lag, no queue lag, no periodic freezes and no progressive generation slowdown. Prompt submissions typically take 30-80 ms.

A subsequent 32-minute network capture contained zero full job-detail requests and only 22 lightweight output descriptor requests, totaling approximately 39 KB of response data.

I've bundled the individual PRs, technical findings, reproductions and benchmarks into two tracking issues:

https://github.com/Comfy-Org/ComfyUI_frontend/issues/24775

https://github.com/Comfy-Org/ComfyUI/issues/18142

There's also a separate backend PR addressing unnecessary model eviction during single-frame Wan VAE decoding. In my workflow, ComfyUI was unnecessarily evicting and subsequently reloading approximately 17.3 GiB of model weights between generations. The patch eliminated that in my tested configuration.

https://github.com/Comfy-Org/ComfyUI/issues/18143

Since there's no telling when or whether these PRs will be merged, you can use my ComfyUI Patcher to apply them to your existing installation and automatically build the patched frontend and comfyui core. It handles multiple PR overlays, dependency installation, updates and rollback without requiring you to maintain your own forks.

https://github.com/xmarre/ComfyUI-Patcher

I'm particularly interested in whether other people who run ComfyUI for hundreds of generations without restarting it have experienced similar performance degradation.

47 Upvotes

16 comments sorted by

12

u/External_Quarter 11h ago

I'm particularly interested in whether other people who run ComfyUI for hundreds of generations without restarting it have experienced similar performance degradation.

Yes. It is why I:

I've come to rely on such custom nodes after receiving little to no developer attention on the issues and PRs I have opened. Hopefully, you have better luck with yours.

5

u/marres 10h ago edited 10h ago

Yeah, getting stuff merged is not easy, especially the bigger the PR's get. Been maintaining/syncing this PR here for example for over half a year.

https://github.com/Comfy-Org/ComfyUI_frontend/pull/10841

Or this one here I've been syncing for months now too:

https://github.com/Comfy-Org/ComfyUI_frontend/pull/14897

I understand the need to properly review PR's (since they are getting a big influx of subpar ones) but mine are actually fixing important things and should be addressed in a timely manner. It's actually getting a bit ridiculous with the amount of PR's I have to run and manage/maintain concurrently.

3

u/External_Quarter 5h ago edited 5h ago

Relatable. :/ Skimming through PRs, I noticed the vast majority that get merged are authored by in-house ComfyOrg developers, but not always.

I, too, had been reconciling a request for months. It was microscopic compared to some of yours, but it addressed a concrete bug and received some upvotes. I eventually found out that a mostly-duplicate PR was opened and approved in a matter of days, without any linkback to mine.

I can appreciate that Comfy is in a period of growth and probably swamped with community contributions, but it was still an off-putting experience for me.

If enough third-party devs become disillusioned by the approval process, I imagine we'll start seeing forks gaining traction, especially considering all of the longstanding performance issues in main and the recent emphasis on partner nodes/monetization.

1

u/DJLunacy 9h ago

Thanks for sharing details! In most cases when I'm using Comfy it's ran via my own front end. I've been working on ways to identify regressions in performance. PR lag I'm sure has only gotten worse, I haven't paid much attention to it directly in a while, but I feel like that's partly how/why the bigger forks popped up a couple of years ago. I'll take a look at this and see what my numbers look like.

For reference are you primarily using the same core model, and just running bulk workflows?

What OS & GPU are you using?

1

u/marres 9h ago

I currently primarily run Krea 2 with fairly complex workflows, dynamic LoRA stacks and multi-stage sampling at around 21 MP output resolution. Mostly bulk generations with varying prompts and seeds, while keeping ComfyUI running for long periods of time.

Windows 11, ComfyUI backend running in WSL2 (Ubuntu 22.04) with a RTX PRO 6000 Blackwell 96 GB.

1

u/Enshitification 8h ago

Loading the initial ComfyUI page requires a huge amount of bandwidth. This kills my phone tethering data when I am connecting remotely. Is there any way to cache the page locally to reduce this?

1

u/marres 28m ago

I checked the backend implementation and found that ComfyUI explicitly disables browser caching for JavaScript and CSS files. This is unnecessary for content-hashed frontend bundles, which could safely be cached across sessions.

For now, you can start ComfyUI with --enable-compress-response-body to reduce bandwidth consumption from large JSON responses.

The existing thumbnail and history PRs should also substantially reduce bandwidth consumption during normal use.

3

u/MarkB_- 10h ago

Im one of those that chain generation 24/7

For me the laggy frontend happen as soon inference start. The lag is the same after days of generating steady. Adding jobs is a pain.

2

u/FourtyMichaelMichael 🍦Ice Cream Lover 8h ago

Nodes2 feels a lot better than 10FPS.... But... Node2.0 still really suck. Blurry text and lots of nodes aren't supported.

3

u/tomByrer 5h ago

TBH I think the entire program, esp the generator part, should be re-written in RUST & get away from that Python crap.

There is also an AI engine being built in assembly that bypasses CUDA... give it another month.

1

u/SkegSurf 2h ago

Know the name of that AI engine in assembly?

2

u/Version-Strong 10h ago

Anyone else having a stupidly long wait to refresh nodes and models recently too? It takes forever now, used to be press 'r'... update requested = done.

2

u/hiperjoshua 9h ago

Can anyone confirm if the "Preview as text" node also causes massive frontend performance degradation? I removed all instances of that node and my workflows have stopped stuttering.

1

u/SkegSurf 1h ago

I think you might be onto something there. I disabled that node and gen times seem to be faster

3

u/tofuchrispy 11h ago

Yes I hope something is done about this. So egregious. Not only is the interface rendering slower since they switched the engine (to allow more complex nodes yes we like that)
And then it also slows and lags like hell in between.

1

u/MastMaithun 4h ago

Not 100s of generations but I am constantly seeing sluggish browser which actually holds my generations too. Two sepratate things happens:

  • when i start a generation, i have to close down the browser page as just keeping it open on the front takes up 40-50% gpu usage. so if i dont minimize the page, it keeps starts the generations much later.
  • when a generation is ongiong, if i open the page, it slowed the the generation. majority time i see this happening during minimax h3 (image or video) generations, less with moss.
  • many times like 50-60%, once the generation is completed and i open the browser, the page is super sluggish and showing like 5fps when i zoom in-out, move nodes etc. once i hit run button, sluggishness disappear. also in this case, i checked my gpu usage shoots to almost 100% and when i minimize the page, gpu goes to 0-2%

I started to see these happening on comfy later 0.40. Earlier it also happened but not that much. I tried several things which i knew but none of them solved any of the issue.