100% CPU usage when compiled from source in Linux
Check for existing issues
- [X] Completed
Describe the bug / provide steps to reproduce it
When I compiled the code from source by using this guide developing_zed__building_zed_linux.md and after the compilation when it's open only for hovering over application the CPU picked at 100%
Environment
OS: Pop!_OS 22.04 LTS x86_64 Host: VivoBook_ASUSLaptop X415JA_X415JA 1.0 Kernel: 6.8.0-76060800daily20240311-generic Packages: 3819 (dpkg), 45 (flatpak), 16 (snap) Shell: bash 5.1.16 Resolution: 1920x1080 WM: i3 CPU: Intel i5-1035G1 (8) @ 3.600GHz GPU: Intel Iris Plus Graphics G1 Memory: 15737MiB
If applicable, add mockups / screenshots to help explain present your vision of the feature
https://github.com/zed-industries/zed/assets/141448219/986f1646-7afc-49a4-8254-4aee7b5dfb16
If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.
No response
I think it'd be useful to check if disabling LSP reduces the CPU usage.
no, disabling LSP does nothing
./Zed [2024-04-27T15:50:31+05:30 ERROR util] crates/zed/src/zed.rs:660: EOF while parsing a value at line 1 column 0 [2024-04-27T15:50:33+05:30 ERROR auto_update] auto-update failed: error:error deserializing release
Caused by: expected value at line 1 column 1 [2024-04-27T15:53:52+05:30 ERROR util] crates/lsp/src/lsp.rs:768: oneshot canceled
This is what get when open application from terminal.
I'm having a similar issue on fedora 36 on my desktop, however it might be my GPU/Driver related. vulkaninfo reports an error for me.
it does work fine on my laptop on both fedora 39/40.
Did you compile in release mode? If that's not the problem and it's also not the LSP then idk
Did you compile in release mode? If that's not the problem and it's also not the LSP then idk
Yes, I have compiled it in release mode sorry for late replied.
Do you have the Vulkan drivers installed? Can you run vkcube and show the command line output?
Do you have the Vulkan drivers installed? Can you run
vkcubeand show the command line output?
https://github.com/zed-industries/zed/assets/141448219/41685400-21f3-4e35-b74d-470bdb7372dd
output of "vkcube" command
Do you have the Vulkan drivers installed? Can you run
vkcubeand show the command line output?vkcube.mp4 output of "vkcube" command
Hmmm, You seem to have the Vulkan drivers installed and working. So I don't think it explains the high CPU usage...
I do not think guessing is a good strategy here.
Linux has perf and other profiling tools, taking a sample of the 100% load is the next reasonable step to have this issue solved.
I have a similar issue, it turns out that LLVMPIPE was chosen as the graphics render, switching to a discrete graphics card solved the issue for me:
kvark/blade#115
Perf output
# Total Lost Samples: 0
#
# Samples: 199K of event 'cycles:P'
# Event count (approx.): 204022395792
#
# Children Self Command Shared Object Symbol
# ........ ........ ............... .................... .......................................
#
2.29% 0.00% llvmpipe-2 libvulkan_lvp.so [.] 0x00007e965e2c0d23
|
---0x7e965e2c0d23
2.25% 0.00% llvmpipe-1 libvulkan_lvp.so [.] 0x00007e965e2c0d23
|
---0x7e965e2c0d23
2.24% 0.00% llvmpipe-6 libvulkan_lvp.so [.] 0x00007e965e2c0d23
|
---0x7e965e2c0d23
2.23% 0.00% llvmpipe-3 libvulkan_lvp.so [.] 0x00007e965e2c0d23
|
---0x7e965e2c0d23
2.23% 0.00% llvmpipe-5 libvulkan_lvp.so [.] 0x00007e965e2c0d23
|
---0x7e965e2c0d23
2.20% 0.00% llvmpipe-0 libvulkan_lvp.so [.] 0x00007e965e2c0d23
|
---0x7e965e2c0d23
2.20% 0.00% llvmpipe-4 libvulkan_lvp.so [.] 0x00007e965e2c0d23
|
To switch the graphic card you can do the following:
- list availabe gpu :
MESA_VK_DEVICE_SELECT=list vulkaninfo, note the ids (the second column like 8086:166) - force zed to use the correct one :
MESA_VK_DEVICE_SELECT={id}! zed{id}need to be replaced with the correct id
To switch the graphic card you can do the following:
- list availabe gpu :
MESA_VK_DEVICE_SELECT=list vulkaninfo, note the ids (the second column like 8086:166)- force zed to use the correct one :
MESA_VK_DEVICE_SELECT={id}! zed{id}need to be replaced with the correct id
Thanks, that also works.
Mine was driver related, Fedora & Ubuntu by default uses Radeon for my older card i have switched over to AMDGPU. It has resolved my issues. The 3D cube demo does work for both drivers.
To switch the graphic card you can do the following:
- list availabe gpu :
MESA_VK_DEVICE_SELECT=list vulkaninfo, note the ids (the second column like 8086:166)- force zed to use the correct one :
MESA_VK_DEVICE_SELECT={id}! zed{id}need to be replaced with the correct id
list of available gpu MESA_VK_DEVICE_SELECT=list vulkaninfo WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Failed to CreateInstance in ICD 4. Skipping ICD. selectable devices: GPU 0: 10005:0 "llvmpipe (LLVM 15.0.7, 256 bits)" CPU 0000:00:00.0 GPU 1: 8086:8a56 "Intel(R) UHD Graphics (ICL GT1)" integrated GPU 0000:00:02.0
when open the zed by seleting the gpu1 it errors
MESA_VK_DEVICE_SELECT=8086:8a56! /mnt/0da5f057-93ef-4a51-824c-4ff9f439e2bb/bfs/zed/target/release/Zed &>> /mnt/0da5f057-93ef-4a51-824c-4ff9f439e2bb/error.txt
When only open the zed normally
To switch the graphic card you can do the following:
- list availabe gpu :
MESA_VK_DEVICE_SELECT=list vulkaninfo, note the ids (the second column like 8086:166)- force zed to use the correct one :
MESA_VK_DEVICE_SELECT={id}! zed{id}need to be replaced with the correct idlist of available gpu MESA_VK_DEVICE_SELECT=list vulkaninfo WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Failed to CreateInstance in ICD 4. Skipping ICD. selectable devices: GPU 0: 10005:0 "llvmpipe (LLVM 15.0.7, 256 bits)" CPU 0000:00:00.0 GPU 1: 8086:8a56 "Intel(R) UHD Graphics (ICL GT1)" integrated GPU 0000:00:02.0
when open the zed by seleting the gpu1 it errors
MESA_VK_DEVICE_SELECT=8086:8a56! /mnt/0da5f057-93ef-4a51-824c-4ff9f439e2bb/bfs/zed/target/release/Zed &>> /mnt/0da5f057-93ef-4a51-824c-4ff9f439e2bb/error.txt
When only open the zed normally
After the stable, it gives this error MESA_VK_DEVICE_SELECT=8086:8a56! /home/vaibhav/.local/zed.app/libexec/zed-editor Zed failed to open a window: NoSupportedDeviceFound
Device should support my CPU is not that old right.
2024-07-13T16:11:44+05:30 [INFO] Enabling Vulkan Portability 2024-07-13T16:11:44+05:30 [INFO] Enabling color space support 2024-07-13T16:11:44+05:30 [WARN] Rejecting Intel for not presenting when Nvidia is present (on Linux) 2024-07-13T16:11:44+05:30 [INFO] Adapter "llvmpipe (LLVM 15.0.7, 256 bits)" 2024-07-13T16:11:44+05:30 [INFO] No ray tracing extensions are supported
I found this according to the log the zed detect the NVIDIA so it rejects to use intel and end up using the llvmpipe
Possibly related, when opening Zed I see a blank window (no new content, it has a "snapshot" of other window's contents underneath the newly created window) and high cpu usage when moving the cursor inside it. I am on Qubes OS 4.1.2 with a Fedora 37 VM, only GPU available is llvmpipe due to the graphics stack of Qubes, so switching the GPU driver in use is not an option. Same result when using the install script, the release and nightly tarballs, and running from source.
From prior experience developing software on Linux, I usually see this "snapshot" behavior when a window is created but nothing is ever drawn to it. This is however not a recurring issue with other programs on my system.
Only quirk I noticed for a program I develop is that GLFW cannot detect the display FPS on my system (as per the isolation of the VM) and so swap interval does not aim for a fixed refresh rate but rather refreshes as quickly as possible. I mention this in case Zed is relying on a detected FPS value, and when this fails it simply draws nothing to the window. However I am led to believe that Zed is actually drawing fine and simply not committing to the window, since my CPU usage spikes when moving the cursor inside the blank window, and also considering the Refreshing at 16673 micros line in logs below.
Screenshot:
Logs (when running without --foreground):
Click to expand
2024-07-23T23:46:51.683041639+02:00 [INFO] ========== starting zed ==========
2024-07-23T23:46:51.694877878+02:00 [INFO] Compositor detection: _NET_WM_CM_S?=false, _NET_WM_CM_OWNER=false, _NET_SUPPORTING_WM_CHECK=true
2024-07-23T23:46:51.694958636+02:00 [INFO] x11: compositor present: true, gtk_frame_extents_supported: false
2024-07-23T23:46:51.702941568+02:00 [INFO] Opening main db
2024-07-23T23:46:51.703466476+02:00 [INFO] perform;
2024-07-23T23:46:51.703555236+02:00 [INFO] read_command;
2024-07-23T23:46:51.703618899+02:00 [INFO] read_command;
2024-07-23T23:46:51.703830177+02:00 [INFO] socket reader;
2024-07-23T23:46:51.70407217+02:00 [INFO] new;
2024-07-23T23:46:51.704245947+02:00 [INFO] Using git binary path: None
2024-07-23T23:46:51.705001654+02:00 [INFO] keep_updated;
2024-07-23T23:46:51.735003959+02:00 [INFO] extensions updated. loading 1, reloading 0, unloading 0
2024-07-23T23:46:51.735143658+02:00 [INFO] activate is not implemented on Linux, ignoring the call
2024-07-23T23:46:51.73520788+02:00 [INFO] Opening main db
2024-07-23T23:46:51.745914945+02:00 [INFO] Using Visual { id: 99, colormap: 0, depth: 32 }
2024-07-23T23:46:51.745972784+02:00 [INFO] Creating colormap 25165827
2024-07-23T23:46:51.746532035+02:00 [INFO] perform;
2024-07-23T23:46:51.746586926+02:00 [INFO] read_command;
2024-07-23T23:46:51.750878975+02:00 [INFO] read_command;
2024-07-23T23:46:51.750990821+02:00 [INFO] socket reader;
2024-07-23T23:46:51.764472827+02:00 [INFO] Enabling Vulkan Portability
2024-07-23T23:46:51.764517038+02:00 [INFO] Enabling color space support
2024-07-23T23:46:51.767819802+02:00 [INFO] Adapter "llvmpipe (LLVM 15.0.7, 128 bits)"
2024-07-23T23:46:51.767868416+02:00 [INFO] No ray tracing extensions are supported
2024-07-23T23:46:51.776038734+02:00 [INFO] Using surface present mode MAILBOX
2024-07-23T23:46:51.776584586+02:00 [WARN] Unable to forbid exclusive full screen
2024-07-23T23:46:51.776869239+02:00 [INFO] Creating a descriptor pool for at most 16 sets
2024-07-23T23:46:51.776906818+02:00 [INFO] Creating a descriptor pool for at most 16 sets
2024-07-23T23:46:51.776941163+02:00 [INFO] Initializing Blade pipelines for surface SurfaceInfo { format: Bgra8UnormSrgb, alpha: Ignored }
2024-07-23T23:46:51.796700058+02:00 [INFO] Refreshing at 16673 micros
2024-07-23T23:46:51.796788902+02:00 [INFO] x11: no compositor present, falling back to server-side window decorations
2024-07-23T23:46:51.817163216+02:00 [INFO] set environment variables from shell:/bin/bash, path:/home/user/.local/bin:/home/user/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
2024-07-23T23:46:51.948245288+02:00 [INFO] Initializing default prettier with plugins {}
2024-07-23T23:46:51.954419909+02:00 [INFO] Initializing default prettier with plugins {}
2024-07-23T23:46:52.104663118+02:00 [INFO] Node runtime install_if_needed
2024-07-23T23:46:52.552546189+02:00 [INFO] starting language server. binary path: "/home/user/.local/share/zed/node/node-v18.15.0-linux-x64/bin/node", working directory: "/", args: ["/home/user/.local/share/zed/copilot/copilot-v0.5.0/dist/agent.js", "--stdio"]
2024-07-23T23:46:53.059436337+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
"level": 0,
"message": "[DEBUG] [agent] [2024-07-23T21:46:53.048Z] Agent service starting",
"metadataStr": "[DEBUG] [agent] [2024-07-23T21:46:53.048Z]",
"extra": [
"Agent service starting"
]
}
2024-07-23T23:46:53.062981446+02:00 [INFO] Language server with id 0 sent unhandled notification client/registerCapability:
{
"registrations": [
{
"id": "b691a49e-5430-4d0c-b74e-d00ccce6f92d",
"method": "workspace/didChangeWorkspaceFolders",
"registerOptions": {}
}
]
}
2024-07-23T23:46:53.094995789+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
"level": 0,
"message": "[DEBUG] [agent] [2024-07-23T21:46:53.067Z] Telemetry initialized",
"metadataStr": "[DEBUG] [agent] [2024-07-23T21:46:53.067Z]",
"extra": [
"Telemetry initialized"
]
}
Output of vkcube:
