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
39.41k stars 2.05k forks source link

Noticeable latency on Asahi Linux #13734

Open jvoisin opened 2 days ago

jvoisin commented 2 days ago

Check for existing issues

Describe the bug / provide steps to reproduce it

  1. Get an Apple M2 laptop
  2. Install Asahi Linux on it
  3. Install Zed via curl https://zed.dev/install.sh | bash
  4. Open a file in Zed
  5. Move the cursor around
  6. Notice that there is a noticeable input lag.
  7. Notice that the opening of menu is also lagging
  8. Notice that clicks are also laggy

I asked a couple of non-tech people "Does the movement seem more sluggish in this window (Zed) or this window (neovim in a terminal)?" and all of them said that the neovim window had instantaneous cursor movement, while the Zed one was a bit lagging.

Environment

Zed: v0.142.3 (Zed Preview) OS: Linux Wayland fedora-asahi-remix 40 Memory: 23.2 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

2024-07-02T12:21:43+02:00 [INFO] ========== starting zed ==========
2024-07-02T12:21:43+02:00 [INFO] perform;
2024-07-02T12:21:43+02:00 [INFO] read_command;
2024-07-02T12:21:43+02:00 [INFO] read_command;
2024-07-02T12:21:43+02:00 [INFO] Opening main db
2024-07-02T12:21:43+02:00 [INFO] socket reader;
2024-07-02T12:21:43+02:00 [INFO] new;
2024-07-02T12:21:43+02:00 [INFO] keep_updated;
2024-07-02T12:21:43+02:00 [INFO] Using git binary path: None
2024-07-02T12:21:43+02:00 [INFO] extensions updated. loading 1, reloading 0, unloading 0
2024-07-02T12:21:43+02:00 [INFO] activate is not implemented on Linux, ignoring the call
2024-07-02T12:21:43+02:00 [INFO] Opening main db
2024-07-02T12:21:43+02:00 [INFO] perform;
2024-07-02T12:21:43+02:00 [INFO] read_command;
2024-07-02T12:21:43+02:00 [INFO] read_command;
2024-07-02T12:21:43+02:00 [INFO] socket reader;
2024-07-02T12:21:43+02:00 [INFO] building git repository, `.git` path in the worktree: ".git"
2024-07-02T12:21:43+02:00 [INFO] Enabling Vulkan Portability
2024-07-02T12:21:43+02:00 [INFO] Enabling color space support
2024-07-02T12:21:43+02:00 [INFO] Adapter "llvmpipe (LLVM 18.1.6, 128 bits)"
2024-07-02T12:21:43+02:00 [INFO] Ray tracing is supported
2024-07-02T12:21:43+02:00 [INFO] Using surface present mode MAILBOX
2024-07-02T12:21:43+02:00 [WARN] Unable to forbid exclusive full screen
2024-07-02T12:21:43+02:00 [INFO] Creating a descriptor pool for at most 16 sets
2024-07-02T12:21:43+02:00 [INFO] Creating a descriptor pool for at most 16 sets
2024-07-02T12:21:43+02:00 [INFO] Initializing Blade pipelines for surface SurfaceInfo { format: Bgra8UnormSrgb, alpha: Ignored }
2024-07-02T12:21:44+02:00 [INFO] Using surface present mode MAILBOX
2024-07-02T12:21:44+02:00 [WARN] Unable to forbid exclusive full screen
2024-07-02T12:21:44+02:00 [INFO] Using surface present mode MAILBOX
2024-07-02T12:21:44+02:00 [WARN] Unable to forbid exclusive full screen
2024-07-02T12:21:44+02:00 [INFO] set environment variables from shell:/bin/bash, path:/home/jvoisin/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/go/bin:/home/jvoisin/go/bin:/home/jvoisin/.cargo/bin:/home/jvoisin/app/
2024-07-02T12:21:44+02:00 [INFO] Opening main db
2024-07-02T12:21:44+02:00 [INFO] Opening main db
2024-07-02T12:21:44+02:00 [INFO] Initializing default prettier with plugins {}
2024-07-02T12:21:44+02:00 [INFO] starting language servers for Markdown: 
2024-07-02T12:21:44+02:00 [INFO] Node runtime install_if_needed
2024-07-02T12:21:44+02:00 [ERROR] crates/workspace/src/persistence/model.rs:353: No path stored for this editor
2024-07-02T12:21:44+02:00 [INFO] Wayland does not support this API
2024-07-02T12:21:44+02:00 [INFO] starting language server. binary path: "/home/jvoisin/.local/share/zed/node/node-v18.15.0-linux-arm64/bin/node", working directory: "/", args: ["/home/jvoisin/.local/share/zed/copilot/copilot-v0.5.0/dist/agent.js", "--stdio"]
2024-07-02T12:21:44+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 0,
  "message": "[DEBUG] [agent] [2024-07-02T10:21:44.879Z] Agent service starting",
  "metadataStr": "[DEBUG] [agent] [2024-07-02T10:21:44.879Z]",
  "extra": [
    "Agent service starting"
  ]
}
2024-07-02T12:21:44+02:00 [INFO] Language server with id 0 sent unhandled notification client/registerCapability:
{
  "registrations": [
    {
      "id": "90666579-52f1-4202-a0c6-661b458a7608",
      "method": "workspace/didChangeWorkspaceFolders",
      "registerOptions": {}
    }
  ]
}
2024-07-02T12:21:45+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 0,
  "message": "[DEBUG] [agent] [2024-07-02T10:21:44.947Z] Telemetry initialized",
  "metadataStr": "[DEBUG] [agent] [2024-07-02T10:21:44.947Z]",
  "extra": [
    "Telemetry initialized"
  ]
}
SomeoneToIgnore commented 2 days ago

I doubt that somebody in the Zed team will install Asahi Linux some time soon, so some profiling would be really helpful here.

https://github.com/zed-industries/zed/issues/13203 has a number of techniques described below.

AlexDaniel commented 2 days ago

Just to be clear, https://github.com/zed-industries/zed/issues/13203 is about Zed being “half the time just as slow as VS Code, and sometimes 1 frame slower”. In other words, it's pretty fast. If you feel that Zed is truly lagging, then it's possibly a different issue.

Are you sure that you're able to run Vulkan apps? I see:

2024-07-02T12:21:43+02:00 [INFO] Adapter "llvmpipe (LLVM 18.1.6, 128 bits)"

Doesn't that mean that you're using a software renderer?

What happens when you run vkcube or vkgears?

@mrnugget I don't know who else to ping, but this is this issue again: https://github.com/zed-industries/zed/issues/13154. Even though Zed is not wrong in this case, and it's probably a good idea to fall back to a software renderer, I'm now 100% convinced that Zed should show a warning to the user when that happens. Otherwise people start assuming that zed is lagging, while they're simply using the software renderer.

AlexDaniel commented 2 days ago

How to detect software rendering: image

someone13574 commented 2 days ago

Asahi doesn’t have a public Vulkan driver so you are almost certainly running llvmpipe. Try using the OpenGL backend: https://github.com/zed-industries/zed/issues/13305. There’s a chance it will not work because it’s very new and not many people use it.

jvoisin commented 2 days ago

I'm indeed running llmvpipe:

$ vulkaninfo  | grep -i llvmpipe
        GPU id = 0 (llvmpipe (LLVM 18.1.6, 128 bits))
GPU id : 0 (llvmpipe (LLVM 18.1.6, 128 bits)):
GPU id : 0 (llvmpipe (LLVM 18.1.6, 128 bits)):
    deviceName        = llvmpipe (LLVM 18.1.6, 128 bits)
    driverID                                             = DRIVER_ID_MESA_LLVMPIPE
    driverName                                           = llvmpipe
$

Having a warning about this would be nice indeed.

On the bright side, @alyssarosenzweig has a working vulkan implementation that should land into Asahi Linux at some point.

lukaslihotzki commented 2 days ago

Zed works well on Asahi Linux when compiling with RUSTFLAGS="--cfg gles". Installing the Vulkan driver somehow also should work.