Open siyia2 opened 3 months ago
Hey @siyia2, we have a similar issue here:
Is this what you are experiencing as well? Is responsiveness pretty bad when interacting with Zed?
no responsiveness in my case seems fine but i get a constant ~+15% cpu usage just from having zed open , however i guess it could be related.
Having the same issue, I believe. kwin_wayland
jumps from single digits to constant ~50% CPU usage just by having Zed open.
i also use wayland with sway
Zed experience is very nice but the high CPU usage is really not living up to it. It's bad.
On Win 11 HP Game Laptop 13th Gen Intel i7 NVidia RTX 4x
Zed 0.149.5 is idling at 20% and forcing my cooling fans to be constantly at max level. For this reason I only use Zed to open my StarFluke C# Unity project for short browsing as I port the C# game to Rust on another IDE.
Most features of Zed are awesome! This CPU thing is a deal breaker for now. But I keep surfing the Zed update waves with hopes of seeing a fix come in. (Too bad I have no bandwidth to find a fix myself right now. LOL.)
I have the same issue. I tried to profile the execution of zed and kwin_wayland and it looks like zed is stuck in an animation rendering loop. I.e. it get a callback from wayland for a new frame and zed commits a new frame even though nothing has changed in the ui. Unfortunately I'm not familiar with the zed codebase nor the wayland protocol, so I cant tell whether thats wrong or it is the intended behaviour. Running vkcube to test that vulkan works gives approximately the same cpu load.
I did a quick test with the simplest possible C application that opens a wayland window and starts a rendering loop without doing any rendering, just request frame callback and then commit the frame. It also causes kwin_wayland to jump up to approximately 20% CPU usage. So this seems to be the issue. Now the question is whether this is a wayland issue or a zed issue. One interesting aspect is that forcing zed to use X11 by setting WAYLAND_DISPLAY='' will not cause increased CPU usage. So this could be a workaround while working on a fix.
Would it be feasible to change the rendering logic so we only request frame callbacks when there actually are any new things to render? Would you perhaps care to comment @mikayla-maki, @gabydd, @witelokk or @apricotbucket28? I see your names in the git history :)
Zed (on Wayland) currently works like this:
wl_callback::done
is fired.wl_surface::frame
states the following:
The server must send the notifications so that a client will not send excessive updates, while still allowing the highest possible update rate for clients that wait for the reply before drawing again.
and
A server should avoid signaling the frame callbacks if the surface is not visible in any way
But I noticed that KWin still sends the event even when Zed is minimized. Nevertheless, CPU usage is still at zero in my machine in that case.
Interesting! Thanks for explanation
But to clarify my findings, the wayland client code also requests a renewed frame throttling callback in frame.window() when wl_callback::done
is fired. The on_request_frame handler ends up calling completed_frame which will commit the frame. Even if nothing is going to be drawn. And this loop seems to cause increased cpu load on some, but not all systems. The question remains if this is a bug in kwin_wayland or in zed, but it feels kind of silly to repeatedly request and commit empty frames. It is like an animation loop without animation. No other wayland app on my system has this behavior when idling. When minimizing zed the CPU load drops though. Now the question remains, is this animation loop like behavior intentional or is it a bug? Is zed supposed to stop requesting frame callbacks when it has nothing to draw?
Check for existing issues
Describe the bug / provide steps to reproduce it
When zed is open it consumes 15%-20% cpu usage just by sitting there.
Environment
Computer Information: Manufacturer: Gigabyte Technology Co., Ltd. Model: GA-78LMT-USB3 6.0 Form Factor: Desktop No Touch Input Detected Processor Information: CPU Vendor: AuthenticAMD CPU Brand: AMD FX(tm)-8300 Eight-Core Processor CPU Family: 0x15 CPU Model: 0x2 CPU Stepping: 0x0 CPU Type: 0x0 Speed: 3300 MHz 8 logical processors 8 physical processors Hyper-threading: Unsupported FCMOV: Supported SSE2: Supported SSE3: Supported SSSE3: Supported SSE4a: Supported SSE41: Supported SSE42: Supported AES: Supported AVX: Supported AVX2: Unsupported AVX512F: Unsupported AVX512PF: Unsupported AVX512ER: Unsupported AVX512CD: Unsupported AVX512VNNI: Unsupported SHA: Unsupported CMPXCHG16B: Supported LAHF/SAHF: Supported PrefetchW: Unsupported Operating System Version: "Manjaro Linux" (64 bit) Kernel Name: Linux Kernel Version: 6.6.40-1-MANJARO X Server Vendor: The X.Org Foundation X Server Release: 12401001 X Window Manager: wlroots wm Steam Runtime Version: steam-runtime_0.20240610.91380 Video Card: Driver: AMD AMD Radeon RX 5500 XT (radeonsi, navi14, LLVM 18.1.8, DRM 3.54, 6.6.40-1-MANJARO) Driver Version: 4.6 (Compatibility Profile) Mesa 24.1.3-manjaro1.1 OpenGL Version: 4.6 Desktop Color Depth: 24 bits per pixel Monitor Refresh Rate: 74 Hz VendorID: 0x1002 DeviceID: 0x7340 Revision Not Detected Number of Monitors: 1 Number of Logical Video Cards: 1 Primary Display Resolution: 1920 x 1080 Desktop Resolution: 1920 x 1080 Primary Display Size: 18.90" x 10.63" (21.65" diag), 48.0cm x 27.0cm (55.0cm diag) Primary VRAM: 4096 MB Sound card: Audio device: Realtek ALC892 Memory: RAM: 15973 Mb VR Hardware: VR Headset: None detected Miscellaneous: UI Language: English LANG: en_US.UTF-8 Total Hard Disk Space Available: 1807727 MB Largest Free Hard Disk Block: 1062225 MB Storage: Number of SSDs: 2 SSD sizes: 2000G,240G Number of HDDs: 0 Number of removable drives: 0
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your Zed.log file to this issue.
2024-07-19T21:34:22.413302905+03:00 [INFO] ========== starting zed ========== 2024-07-19T21:34:22.471539011+03:00 [INFO] perform; 2024-07-19T21:34:22.471703366+03:00 [INFO] read_command; 2024-07-19T21:34:22.471824372+03:00 [INFO] Opening main db 2024-07-19T21:34:22.471966298+03:00 [INFO] read_command; 2024-07-19T21:34:22.47224024+03:00 [INFO] socket reader; 2024-07-19T21:34:22.472675678+03:00 [INFO] new; 2024-07-19T21:34:22.473810356+03:00 [INFO] keep_updated; 2024-07-19T21:34:22.476400749+03:00 [INFO] Using git binary path: None 2024-07-19T21:34:22.553487869+03:00 [INFO] extensions updated. loading 1, reloading 0, unloading 0 2024-07-19T21:34:22.553840959+03:00 [INFO] activate is not implemented on Linux, ignoring the call 2024-07-19T21:34:22.590949076+03:00 [INFO] perform; 2024-07-19T21:34:22.591113612+03:00 [INFO] read_command; 2024-07-19T21:34:22.59124909+03:00 [INFO] read_command; 2024-07-19T21:34:22.591459617+03:00 [INFO] socket reader; 2024-07-19T21:34:22.59920281+03:00 [ERROR] DBus error service error org.freedesktop.zbus.Error: The name is not activatable 2024-07-19T21:34:22.599502119+03:00 [INFO] Opening main db 2024-07-19T21:34:22.642965688+03:00 [INFO] Enabling Vulkan Portability 2024-07-19T21:34:22.643150283+03:00 [INFO] Enabling color space support 2024-07-19T21:34:22.653625866+03:00 [INFO] Adapter "AMD Radeon RX 5500 XT (RADV NAVI14)" 2024-07-19T21:34:22.65377521+03:00 [INFO] No ray tracing extensions are supported 2024-07-19T21:34:22.673253939+03:00 [INFO] Using surface present mode MAILBOX 2024-07-19T21:34:22.673976586+03:00 [WARN] Unable to forbid exclusive full screen 2024-07-19T21:34:22.67499158+03:00 [INFO] Creating a descriptor pool for at most 16 sets 2024-07-19T21:34:22.675191797+03:00 [INFO] Creating a descriptor pool for at most 16 sets 2024-07-19T21:34:22.675411021+03:00 [INFO] Initializing Blade pipelines for surface SurfaceInfo { format: Bgra8UnormSrgb, alpha: PreMultiplied } 2024-07-19T21:34:22.692151572+03:00 [INFO] Using surface present mode MAILBOX 2024-07-19T21:34:22.692783267+03:00 [WARN] Unable to forbid exclusive full screen 2024-07-19T21:34:22.693477294+03:00 [INFO] Initializing Blade pipelines for surface SurfaceInfo { format: Bgra8UnormSrgb, alpha: Ignored } 2024-07-19T21:34:22.711589686+03:00 [INFO] Opening main db 2024-07-19T21:34:22.831448006+03:00 [INFO] Using surface present mode MAILBOX 2024-07-19T21:34:22.83209415+03:00 [WARN] Unable to forbid exclusive full screen 2024-07-19T21:34:22.839962283+03:00 [INFO] Node runtime install_if_needed 2024-07-19T21:34:22.842507719+03:00 [INFO] Opening main db 2024-07-19T21:34:23.395895518+03:00 [INFO] starting language server. binary path: "/home/siyia/.local/share/zed/node/node-v18.15.0-linux-x64/bin/node", working directory: "/", args: ["/home/siyia/.local/share/zed/copilot/copilot-v0.5.0/dist/agent.js", "--stdio"] 2024-07-19T21:34:23.758927443+03:00 [INFO] Initializing default prettier with plugins {} 2024-07-19T21:34:23.759127942+03:00 [INFO] starting language servers for C++: clangd 2024-07-19T21:34:23.75928461+03:00 [INFO] starting language server "clangd", path: "/mnt/D/Test/iso-commander-5.0.7/src/isocmd/main_general.cpp", id: 1 2024-07-19T21:34:23.759640536+03:00 [INFO] Initializing default prettier with plugins {} 2024-07-19T21:34:23.759795055+03:00 [INFO] starting language servers for C++: clangd 2024-07-19T21:34:24.244227463+03:00 [INFO] Language server with id 0 sent unhandled notification LogMessage: { "level": 0, "message": "[DEBUG] [agent] [2024-07-19T18:34:24.236Z] Agent service starting", "metadataStr": "[DEBUG] [agent] [2024-07-19T18:34:24.236Z]", "extra": [ "Agent service starting" ] } 2024-07-19T21:34:24.248121422+03:00 [INFO] Language server with id 0 sent unhandled notification client/registerCapability: { "registrations": [ { "id": "6b35c2b2-5066-45c6-b38e-892e18f548eb", "method": "workspace/didChangeWorkspaceFolders", "registerOptions": {} } ] } 2024-07-19T21:34:24.323734301+03:00 [INFO] Language server with id 0 sent unhandled notification LogMessage: { "level": 0, "message": "[DEBUG] [agent] [2024-07-19T18:34:24.258Z] Telemetry initialized", "metadataStr": "[DEBUG] [agent] [2024-07-19T18:34:24.258Z]", "extra": [ "Telemetry initialized" ] }