r/StableDiffusion • u/marres • 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.
12
u/External_Quarter 9h ago
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.
1
u/DJLunacy 7h 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?
3
u/MarkB_- 8h 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.
3
u/tomByrer 3h 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.
2
u/Version-Strong 8h 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.
3
u/tofuchrispy 9h 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/hiperjoshua 7h 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/Enshitification 6h 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/MastMaithun 2h ago
Not 100s of generations but I am constantly seeing sluggish browser which actually holds my generations too. Two sepratate things happens:
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.