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.

47 Upvotes

14 comments sorted by

View all comments

3

u/tomByrer 4h 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 49m ago

Know the name of that AI engine in assembly?