zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
44.03k stars 2.37k forks source link

Zed performance on VMware Virtual Machine #14402

Open fattymango opened 1 month ago

fattymango commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I have installed the latest Zed on my VMware with Ubuntu 22.04 and 8 GB RAM, and when I started using it was very laggy, and couldn't get any work done on it, for reference I use VS Code and Neovim on my VM smoothly without any issue.

I understand that Zed relies heavily on the GPU and VMs do not provide much GPU power, but I believe Zed should also at least run smooth enough even without good GPU power.

Environment

VMware Ubuntu 22.04 Intel i7-8750H 8 GB RAM

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.

Zed.log


notpeter commented 1 month ago

Trying to gather some background info:

According to this doc for VMWare Fusion 13:

On virtual machines running Linux, Fusion supports OpenGL 4.1 for accelerated 3D graphics. Hardware version 18 is required. Linux kernel and Mesa 3D versions that support 3D accelerated graphics are required.

On virtual machines running Linux, Fusion supports OpenGL 4.3 for accelerated 3D graphics. Hardware version 20 and later is required. Linux kernel and Mesa 3D versions that support 3D accelerated graphics are required. But according to this doc on VMWare Workstation Player for Linux 17.0: OpenGL applications run in software emulation mode.

fattymango commented 1 month ago

Trying to gather some background info:

* Are you using Wayland or X11 in your Ubuntu guest?

* What is the GPU in your host system?

* What is your host operating system?

* Which VMWare product and version are you using (VMWare Fusion, Workstation, Player, etc)

* Can you confirm your VM is using only one display?

* Can you confirm you've installed the VMWare Tools in your VM?

* Can you confirm you've enabled "Accelerated Graphics" in the Virtual Machine Settings->Hardware->Display? There also may be a "Battery Life" dropdown, can you confirm this is set to "Always use High Performance Graphics"

* Can you confirm which Hardware version your VM is using?

According to this doc for VMWare Fusion 13:

On virtual machines running Linux, Fusion supports OpenGL 4.1 for accelerated 3D graphics. Hardware version 18 is required. Linux kernel and Mesa 3D versions that support 3D accelerated graphics are required. On virtual machines running Linux, Fusion supports OpenGL 4.3 for accelerated 3D graphics. Hardware version 20 and later is required. Linux kernel and Mesa 3D versions that support 3D accelerated graphics are required. But according to this doc on VMWare Workstation Player for Linux 17.0: OpenGL applications run in software emulation mode.

wayland Host GPU : GeForce GTX 1060 Host OS : Windows 11 VMWare Player 17 Yes only one display Yes installed VMWare tools Accelerated Graphics is enabled virtualHW.version = "21"

lukaslihotzki commented 1 month ago

Zed always uses Vulkan by default. Is Vulkan available in the VMware Virtual Machine? If there is only OpenGL, Zed needs to be build with RUSTFLAGS="--cfg gles".

fattymango commented 3 weeks ago

Zed always uses Vulkan by default. Is Vulkan available in the VMware Virtual Machine? If there is only OpenGL, Zed needs to be build with RUSTFLAGS="--cfg gles".

i tried adding the flag and build it from source, but build failed due to this error:

error: linking with `clang` failed: exit status: 1
 |
  = note: LC_ALL="C" PATH=...

note: clang: error: no such file or directory: ''-Wl,--disable-new-dtags,-rpath,$ORIGIN/../lib''
error: could not compile `zune-jpeg` (lib) due to 1 previous error
clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
fattymango commented 3 weeks ago

Zed always uses Vulkan by default. Is Vulkan available in the VMware Virtual Machine? If there is only OpenGL, Zed needs to be build with RUSTFLAGS="--cfg gles".

I built and installed zed with RUSTFLAGS="--cfg gles" and now it doesn't even launch.

lukaslihotzki commented 3 weeks ago

Can you share the error message?

Maybe the problem is that the required OpenGL version (OpenGL ES 3.1 roughly corresponding to OpenGL 4.3) is not supported on your system. Can you check with a 3rd party tool which OpenGL version is available on your system (also, which OpenGL ES version, if possible)? OpenGL 4.3 should be available in VMware (as @notpeter said), but please check if it actually is.

fattymango commented 3 weeks ago

@lukaslihotzki

there is no error message, when I run zed (after building with RUSTFLAGS="--cfg gles") nothing happens and the editor doesn't show.

glxinfo | grep "OpenGL version"
OpenGL version string: 4.3 (Compatibility Profile) Mesa 23.2.1-1ubuntu3.1~22.04.2

es2_info | grep "OpenGL ES"
GL_VERSION: OpenGL ES 3.1 Mesa 23.2.1-1ubuntu3.1~22.04.2
lukaslihotzki commented 3 weeks ago

So, it should work in theory. Again, can you share the error message, what's in your terminal after starting zed from there? Also, can you make sure that zed runs when compiled with RUSTFLAGS="" (using slow Vulkan software rendering) to rule out any other problems in your custom build?

fattymango commented 3 weeks ago

@lukaslihotzki this is output when built with RUSTFLAGS="--cfg gles"

user@vm:~$ zed //this doesnt show any output
user@vm:~$ ps aux | grep zed
user      5117  0.0  0.0   9216  2560 pts/0    S+   20:54   0:00 grep --color=auto zed
user@vm:~$ pgrep -fl zed //this doesnt show any output

when built with slow Vulkan it launches but is still slow and laggy.

lukaslihotzki commented 3 weeks ago

It seems like you are using the zed cli to start the actual program. Try to use the --foreground option, or start the binary zed-editor in /usr/libexec or /usr/lib/zed. The error output must be directed to your terminal. Probably, this should block the shell as long as zed runs. Also, try to add an eprintln! statement somewhere in the graphics code (for example, in https://github.com/zed-industries/zed/blob/f4bbbe69b46447b4811ed125cf5e65b3f0a81fd5/crates/gpui/src/platform/blade/blade_atlas.rs#L49C31-L49C46). If you can't see this message, you can't read the actual error message.

fattymango commented 3 weeks ago

@lukaslihotzki I used both the cli and the desktop icon both have the same result, on the other hand, when built with Vulkan it works when launched using the cli.

lukaslihotzki commented 3 weeks ago

I meant the zed cli program (this repo contains it in crates/cli) as opposed to the zed binary (as defined in crates/zed). Of course you won't see any error message when you start using the desktop icon. To make it more clear, start zed (the GLES version) by writing zed --foreground in your terminal and paste the terminal output.

fattymango commented 3 weeks ago

@lukaslihotzki

usr@vm:~/.tmp/zed$ zed --foreground
libEGL warning: bad surface attribute 0x3034
Thread "main" panicked with "called `Result::unwrap()` on an `Err` value: BadAttribute" at /home/usr/.cargo/git/checkouts/blade-ea462a0faa3f9995/a477c20/blade-graphics/src/gles/egl.rs:448:18
   0: zed::reliability::init_panic_hook::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::begin_panic_handler::{{closure}}
   3: std::sys_common::backtrace::__rust_end_short_backtrace
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::result::unwrap_failed
   7: blade_graphics::hal::platform::Context::resize
   8: gpui::platform::blade::blade_renderer::BladeRenderer::new
   9: gpui::platform::linux::wayland::window::WaylandWindow::new
  10: <gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::open_window
  11: gpui::platform::linux::platform::<impl gpui::platform::Platform for P>::open_window
  12: gpui::window::Window::new
  13: workspace::Workspace::new_local::{{closure}}::{{closure}}
  14: async_task::raw::RawTask<F,T,S,M>::run
  15: <gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::run
  16: gpui::platform::linux::platform::<impl gpui::platform::Platform for P>::run
  17: gpui::app::App::run
  18: zed::main
  19: std::sys_common::backtrace::__rust_begin_short_backtrace
  20: std::rt::lang_start::{{closure}}
  21: std::rt::lang_start_internal
  22: main
  23: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  24: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:392:3
  25: _start
lukaslihotzki commented 3 weeks ago

0x3034 is egl::TRANSPARENT_TYPE. This was removed in https://github.com/kvark/blade/commit/9f36d1d0b3acd0a3c77cfd6b29575a377c9db082. Zed uses this version since https://github.com/zed-industries/zed/pull/14706. So, please try it again with the current main branch of zed or the v0.146.0 (or later) prerelease.

fattymango commented 3 weeks ago

@lukaslihotzki After pulling the latest version of the main and building zed with GLES, it runs but it glitches hard to the point that you can't see the text inside. image

fattymango commented 2 weeks ago

And this is when built without GLES, I get this warning: image

james-3r commented 1 week ago

Hi @fattymango, had the same error. Some searching around suggests that VMware doesn't support pass through of GPU (my very limited understanding suggests that this is needed for Vulkan). Sorry, I don't the links open to paste them here for you to follow and I'm very much no expert in either Zed or VMware!