Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zed freezes when editing Rust code #24788

Open
road2react opened this issue Feb 13, 2025 · 11 comments
Open

Zed freezes when editing Rust code #24788

road2react opened this issue Feb 13, 2025 · 11 comments

Comments

@road2react
Copy link

Summary

Zed freezes when editing Rust code and is stuck at 100% CPU usage

Steps to trigger the problem:

  1. I cannot find a consistent reproduction

Actual Behavior:

Zed freezes and becomes unresponsive, and is stuck at 100% CPU usage with increasing memory.

Recorded by samply when frozen:

Image

Image

Image

Image

profile.json (doesn't contain symbols, but they come from Arch Linux debug servers, with Zed installed from official repository)

Zed Version and System Specs

Zed: v0.172.8 (Zed)
OS: Linux Wayland arch unknown
Memory: 93.5 GiB
Architecture: x86_64
GPU: AMD Radeon 680M (RADV REMBRANDT) || radv || Mesa 24.3.4-arch1.1

@maxbrunsfeld
Copy link
Collaborator

@SomeoneToIgnore It looks like a lot of time being spent in InlayHintCache::new_update_task. Could you look into this?

@SomeoneToIgnore
Copy link
Contributor

I'm afraid it's looping there without end, but I'm not certain how to trigger that, will try to look at the code better.

Meanwhile, if anyone experiencing that could get RPC messages that Zed receives from rust-analyzer, it would help a lot with the fix:

Image Image

@road2react
Copy link
Author

@SomeoneToIgnore

Meanwhile, if anyone experiencing that could get RPC messages that Zed receives from rust-analyzer, it would help a lot with the fix:

How to access the logs when the editor is frozen? Are they saved to a file?

@SomeoneToIgnore
Copy link
Contributor

Good point, they are not accessible then.
But if you can trigger this reliably, can you share a project and a way to repro this?

@beniaminzagan beniaminzagan added the awaiting info Issue that needs more information from the user label Feb 20, 2025
@road2react
Copy link
Author

I killed rust-analyzer processes but the editor was still mostly frozen. I can however get a click response in every few seconds, which moves the text cursor but then freezes again.

New flamegraph:

Image

Image

Image

profile.json

@beniaminzagan beniaminzagan removed the awaiting info Issue that needs more information from the user label Feb 21, 2025
@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Feb 21, 2025

That's all pretty clear from the original trace — we're stuck in the hint traversal.
More interesting question is how to repro this, as I've never got this, unfortunately.

What kind of settings do you have for inlay hints?

@ggueyraud
Copy link

ggueyraud commented Feb 21, 2025

I have a similar issue on PopOs 22.04, Zed 0.173.x (don't know exactly which minor version, I write this message from my config) and rust 1.85
In my cast that freeze the screen, then black screen for few seconds and then it nothing respond (it's like basicly the OS crash).
How can I give you informations that can help to solve this issue ? At the moment I use macos instead but it's not convenient as PopOs in my opinion

@SomeoneToIgnore
Copy link
Contributor

What's discussed here is not OS-dependent, it's a cross-platform inlay hints' storage code that malfunctions.

I'm interested in the inlay hint-related settings (maybe, on PopOs you have a different config?) and a project where I can try to reproduce this in, ideally with some sequence of actions described.

@ggueyraud
Copy link

How can I have the "inlay hint-related settings"?
I don't know if that's not OS depend because for a same codebase it crash on PopOS but not on MacOS. Unfortunatly I cannot give you access it's a commercial project
Please ask if I can give you any others informations that could help you to investigate this issue.

@SomeoneToIgnore
Copy link
Contributor

Are we talking about the same thing here?
Nothing crashes in the OP, it hangs.

For the hint settings, interested to see if anything from Zed settings

"inlay_hints": {
// Global switch to toggle hints on and off, switched off by default.
"enabled": false,
// Toggle certain types of hints on and off, all switched on by default.
"show_type_hints": true,
"show_parameter_hints": true,
// Corresponds to null/None LSP hint type value.
"show_other_hints": true,
// Whether to show a background for inlay hints.
//
// If set to `true`, the background will use the `hint.background` color from the current theme.
"show_background": false,
// Time to wait after editing the buffer, before requesting the hints,
// set to 0 to disable debouncing.
"edit_debounce_ms": 700,
// Time to wait after scrolling the buffer, before requesting the hints,
// set to 0 to disable debouncing.
"scroll_debounce_ms": 50
},

or LSP setting https://zed.dev/docs/languages/rust#inlay-hints is different between OSes you use.

If nothing's different, this is quite unexpected to see, but good pointer, I will try to find a Linux machine to use things on and see how it behaves for me.

@SomeoneToIgnore
Copy link
Contributor

After testing it for a few days on Fedora, I'm not sure that it's entirely platform-related, as I had no hangs while using hints extensively (as usual).

Another possibility could be rust-analyzer installations?
I use rust-analyzer releases, published on https://github.com/rust-lang/rust-analyzer/releases every Monday.

Could be so that a particular, older, one is used on PopOS and causes Zed to hang?
Using

Image

command will allow to open the language server info tab with the data to check and copy for sharing:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants