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

Editor freezes while scrolling through project search results while it's still streaming #20436

Open
1 task done
RemcoSmitsDev opened this issue Nov 8, 2024 · 10 comments
Open
1 task done
Labels
bug [core label] freeze Editor or OS - freezing / hanging / locking performance Feedback for performance issues, speed, memory usage, etc search buffer search, project search, etc

Comments

@RemcoSmitsDev
Copy link
Contributor

RemcoSmitsDev commented Nov 8, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Issue

There's a performance issue when searching through a large number of results (approximately 10,000). After pressing 'Enter' to initiate the search, scrolling becomes significantly delayed while results are still streaming in. This regression appears to be caused by the continuous refreshing of runnables.


Reproduce steps:

  1. Use the Zed codebase as a test environment.
  2. Enter a short search term that will yield a large number of results.
  3. Press 'Enter' to start the search.
  4. Attempt to scroll through the results.

You should experience noticeable lag or hanging during the scrolling process, similar to the original issue described.

https://github.com/user-attachments/files/17683266/ProjectSearchHang.trace.zip

Environment

Zed: v0.162.0 (Zed Nightly 706c385)
OS: macOS 15.1.0
Memory: 16 GiB
Architecture: aarch64

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

It's hard to see it inside the video, so might be easier to reproduce it yourself.

Screen.Recording.2024-11-08.at.19.55.34.mov
Screenshot 2024-11-08 at 20 07 41 Screenshot 2024-11-08 at 20 07 52

If applicable, attach your Zed.log file to this issue.

Zed.log

@JosephTLyons JosephTLyons added performance Feedback for performance issues, speed, memory usage, etc search buffer search, project search, etc freeze Editor or OS - freezing / hanging / locking and removed triage labels Nov 10, 2024
@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Nov 10, 2024

Interesting, I somehow cannot repro this on Zed project (testing with cargo run --profile release-fast which is important to do, as debug might show something totally odd).

But I have created a branch with the "fix", if you want to test it on your case: #20470

@RemcoSmitsDev
Copy link
Contributor Author

Hey @SomeoneToIgnore, thanks for looking into this. I will try to reproduce it again with the latest main and see if its fixed now.

@RemcoSmitsDev
Copy link
Contributor Author

RemcoSmitsDev commented Nov 10, 2024

Findings

So the change/fix that you made seem to do something, because it does not pop up anymore inside the profile as a slow task what is nice!
But it does not yet fix the freeze/hangs when scrolling or event just typing inside the search bar while the results are streaming.

I profiled your change/fix on nightly and a dev profile build with cargo run --profile release-fast.

It contains profile for project search scrolling and toggling the assistant panel

ProjectSearchHangAfterChange.trace.zip


Toggle assistant panel

I also added a profile for toggling the assistant panel, while having a lot of project search results open (10K). Because one of the things I noticed that the wrap_map seem to be slow. But the profile for this does say something else, pre-painting seem to be the task that takes most of the time.

Screen.Recording.2024-11-10.at.12.16.24.mov
Screenshot 2024-11-10 at 12 58 28 Screenshot 2024-11-10 at 13 01 08

Terminal Log:

[2024-11-10T12:31:45+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:31:46+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:31:46+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:31:46+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:31:46+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:31:46+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:31:54+01:00 ERROR editor] multiple different run targets found on a single line, only the last target will be rendered
[2024-11-10T12:31:56+01:00 ERROR editor] multiple different run targets found on a single line, only the last target will be rendered
[2024-11-10T12:33:25+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:33:26+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:33:26+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:33:26+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:33:26+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:33:26+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:33:31+01:00 ERROR editor] multiple different run targets found on a single line, only the last target will be rendered
[2024-11-10T12:33:33+01:00 ERROR editor] multiple different run targets found on a single line, only the last target will be rendered
[2024-11-10T12:35:11+01:00 ERROR lsp] Cancelled LSP request task for "textDocument/documentHighlight" id 3 which took over 120s
[2024-11-10T12:35:12+01:00 ERROR editor] LSP request timeout
[2024-11-10T12:35:30+01:00 ERROR lsp] Cancelled LSP request task for "textDocument/codeAction" id 45 which took over 120s
[2024-11-10T12:35:30+01:00 ERROR project] LSP request timeout
[2024-11-10T12:40:53+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:05+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR lsp] oneshot canceled
[2024-11-10T12:41:13+01:00 ERROR assistant] entity release
[2024-11-10T12:41:31+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:32+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:32+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:32+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:32+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:32+01:00 ERROR project] stream did not contain valid UTF-8
[2024-11-10T12:41:37+01:00 ERROR editor] multiple different run targets found on a single line, only the last target will be rendered
[2024-11-10T12:41:39+01:00 ERROR editor] multiple different run targets found on a single line, only the last target will be rendered
[2024-11-10T12:43:35+01:00 ERROR lsp] Cancelled LSP request task for "textDocument/codeAction" id 84 which took over 120s
[2024-11-10T12:43:35+01:00 ERROR project] LSP request timeout
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled
[2024-11-10T13:10:20+01:00 ERROR lsp] oneshot canceled

@SomeoneToIgnore
Copy link
Contributor

Sorry, still have nothing like that on my profiles of test search in Zed (maybe due to a different machine).

But *_map/layouting is bad news then, as itself it's most probably not the thing we can improve and only take a step back and understand what is being done wrong.

I have no good clues now though.

@RemcoSmitsDev
Copy link
Contributor Author

If you want to pair on this to find out what is taking so much time, let me know happy to help!

@vitordino
Copy link

vitordino commented Nov 14, 2024

that happens to me regardless wether the results are streaming or not, and i don’t even have the assistant panel enabled

@SomeoneToIgnore
Copy link
Contributor

Thank you for the proposal, @RemcoSmitsDev
I think I'm not the best person to do this and will waste a lot of time for nothing (I'd pick @\osiewicz instead for such a vague search) + have a bunch of other things to deal with that seem to be a bit more important in the next few months (git, LiveKit on Linux).

So, maybe let's do it next year if you won't find anyone by then 🙂

Another thing that might be very related and I've missed, are the actual files you're getting: Zed overly tries to start LSP servers for all open excerpts and that is not what we should do.

@RemcoSmitsDev
Copy link
Contributor Author

Alright, thanks @SomeoneToIgnore for looking into this anyway! Yeah, I did not see that inside the profile, or I'm just not reading it correctly.
But I'll wait patiently until someone picks it up😀

@hferreiro
Copy link
Contributor

Not sure if anything changed recently but I cannot reproduce this issue. I used a large repo to test: https://github.com/chromium/chromium and searched for a common string. The results buffer quickly reached the 10.000 results limit and everything works smoothly.

@rrpolanco
Copy link

rrpolanco commented Jan 31, 2025

I'm on Zed Preview 0.172.3 and the editor hangs four a couple of minutes when doing a project search on a large directory with 1K+ files. After Zed becomes responsive again, scrolling through search results is very slow.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] freeze Editor or OS - freezing / hanging / locking performance Feedback for performance issues, speed, memory usage, etc search buffer search, project search, etc
Projects
None yet
Development

No branches or pull requests

6 participants