zed icon indicating copy to clipboard operation
zed copied to clipboard

Markdown: stable 70%+ CPU usage on typing

Open paulcarroty opened this issue 1 year ago • 7 comments

Describe the bug / provide steps to reproduce it

Constantly high CPU usage on Markdown documents, the preview is off. Tested also on .js files and got 35%, which is quite high.

Environment

Zed preview 0.160.6 on Linux & Wayland

paulcarroty avatar Jun 27 '24 07:06 paulcarroty

Could it be an LSP?

Feel-ix-343 avatar Jun 30 '24 14:06 Feel-ix-343

Tested with "enable_language_server": "false" - no difference.

paulcarroty avatar Jun 30 '24 16:06 paulcarroty

Same problem here. Switching the file type to "plain text": no change, markdown seems not to be specific to the problem. Disabling language server: no change. CPU usage seems related to window size. CPU usage goes down when window is smaller.

UlrichAlt avatar Jul 12 '24 07:07 UlrichAlt

Is this something you're still seeing in current versions of Zed?

notpeter avatar Nov 05 '24 18:11 notpeter

Yes.

paulcarroty avatar Nov 05 '24 21:11 paulcarroty

Still actual on v0.188.6.

paulcarroty avatar Jun 04 '25 07:06 paulcarroty

Can you paste your zed: copy system specs into clipboard into the original description. Curious what your video device is.

notpeter avatar Jun 04 '25 13:06 notpeter

Done.

paulcarroty avatar Jun 04 '25 18:06 paulcarroty

I think this may be related to your video device or driver revision. The Intel(R) HD Graphics 5500 is ~10 years old (Broadwell, first launched Fall 2014) and has to share your 16GB of system memory.

CPU usage goes down when window is smaller.

This sounds like it is having trouble redrawing the editor each frame, and it can't really keep up drawing Zed when fullscreen. Almost sounds like you're getting LLVMpipe level of performance (quite bad).

Based on a cursory search, there are other folks who are appear to be using this or similar GPUs, but I don't have any great recommendations -- perhaps try X11 instead of Wayland? See if an older release of Mesa works better? We'd love to support older hardware (similar vintage hardware on the Mac the Metal renderer is usable) but given that your card predates Vulkan by a couple years, it's not that surprising that the Vulkan driver on Linux does not perform as well as Metal on MacOS or likely Direct3D on Windows.

Sorry I don't have a better answer.

notpeter avatar Jun 04 '25 19:06 notpeter

@notpeter The workaround is systemd-run --scope -p CPUQuota="20%" --user zed, I got very small UI lag. If this issue is related only to Vulkan performance then how it's even possible? Also tested 12% and the lag was bigger, the app was barely usable.

I think the problem is hidden deep within type processing, autocomplete etc.

paulcarroty avatar Jun 05 '25 09:06 paulcarroty

All type processing/autocomplete is handled by LSPs. You should see subprocesses for each of these -- so it should be easy to tell whether it's Zed using the CPU or one of the LSPs.

notpeter avatar Jun 05 '25 18:06 notpeter