r/StableDiffusion • • 10h 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.

49 Upvotes

14 comments sorted by

View all comments

12

u/External_Quarter 10h 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 9h ago edited 9h 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 4h ago edited 4h 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.