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

[perf] UI stalls and freezes when searching single whitespace #171436

Closed
jrieken opened this issue Jan 16, 2023 · 15 comments
Closed

[perf] UI stalls and freezes when searching single whitespace #171436

jrieken opened this issue Jan 16, 2023 · 15 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues perf search Search widget and operation issues verified Verification succeeded
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Jan 16, 2023

  • vscode repo
  • open search vielwet
  • expand replace part of the widget
  • search for a single space
  • in the file-include box type out **/electron-browser/**/*.test.ts
  • 🐌 notice how everything becomes sluggish

The performance trace shows some really long tasks that are preceded by some also long work

Screenshot 2023-01-16 at 17 26 32

Profile-20230116T172636.json.zip

@jrieken jrieken added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Jan 16, 2023
@andreamah andreamah added the search Search widget and operation issues label Jan 16, 2023
@andreamah
Copy link
Contributor

Hmm, I'm not sure if I can replicate it; do you have windows defender enabled to scan the vscode folder?

@roblourens
Copy link
Member

I also can't repro an issue. But do you know what it means to have a long task with no code under it?

@jrieken
Copy link
Member Author

jrieken commented Jan 17, 2023

No, unsure what that means. Usually, it's the browser that is doing stuff. I don't reproduce today, maybe there was fluke or some unwanted accessibility mode (@deepak1556 do we still have the problem?)

Tho, just before the l o n g task there is some actual work for ~500ms in JS. Maybe that's a hint?

@jrieken
Copy link
Member Author

jrieken commented Jan 17, 2023

Screenshot 2023-01-17 at 17 31 26

⬆️ That's what I mean (wrt long JS). It takes around 300-500ms on my machine (which is a really fast machine)

@deepak1556
Copy link
Collaborator

some unwanted accessibility mode (@deepak1556 do we still have the problem?)

Nope its addressed in Insiders since f807491

@andreamah
Copy link
Contributor

No, unsure what that means. Usually, it's the browser that is doing stuff. I don't reproduce today, maybe there was fluke or some unwanted accessibility mode (@deepak1556 do we still have the problem?)

Tho, just before the l o n g task there is some actual work for ~500ms in JS. Maybe that's a hint?

One thing I notice is that it's refreshing the tree quite a bit. Could you try to perform the trace in OSS so that I have a better idea of what is calling it?

@lramos15
Copy link
Member

lramos15 commented Mar 1, 2023

My editor locks up all the time searching causing the entire UI to become unresponsive. This is not only on white space search, but on all searches. I even have what I consider to be fairly conservative inclusions and exclusions. I include *.ts and exclude build/ and extensions/ so I'm only looking at VS Code source code.

I got a few CPU profiles.

The .json is from OSS and the .cpuprofile is from current insiders.
Profile.zip

@jrieken helped me do some digging through these profiles and it appears https://github.com/microsoft/vscode-distro/blob/e89a0ccea11902c6f67324fd38cd613f9bd90c5d/src/vs/workbench/contrib/search/browser/searchView.ts#L495-L498 might be the culprit. My search is unusable when the replace widget is visible, but when it is not everything is much smoother.

@jrieken
Copy link
Member Author

jrieken commented Mar 1, 2023

I think the culprit is that setReplaceAllActionState is called repeatedly (at least twice). You can see that from the attached profile and also when debugging. That in return triggers a full tree refresh which I believe is responsible for the freeze.

This gist (and repro steps) is that this requires the replace-part of the widget to be visible (I have updated the steps accordingly)

@andreamah andreamah added this to the March 2023 milestone Mar 1, 2023
@andreamah andreamah added the perf label Mar 1, 2023
@andreamah
Copy link
Contributor

@lramos15 when you were taking the perf log, how many searches did you do? Was it locked up the entire time that the perf logger was running?

@andreamah
Copy link
Contributor

andreamah commented Mar 1, 2023

Also, in the profile, I saw many instances of onSearchInputChanged. What exactly was happening during the profile? Were you typing in the input box at all?

@jrieken
Copy link
Member Author

jrieken commented Mar 2, 2023

@andreamah Can you not reproduce this locally?

@lramos15
Copy link
Member

lramos15 commented Mar 2, 2023

@lramos15 when you were taking the perf log, how many searches did you do? Was it locked up the entire time that the perf logger was running?

I would say a small handful. It doesn't seem to matter though, when I start typing it locks up or when I go to change the query it locks up. Maybe this has to do with refreshing while the tree is populating, I'm unsure.

@andreamah
Copy link
Contributor

@andreamah Can you not reproduce this locally?

I can't repro this locally, but I'm trying to look into the logs. I think it's about this call here:

this._onReplaceStateChange.fire(newState);
sometimes being unnecessary, but I'll need to think a bit about a clean fix for this.

@andreamah
Copy link
Contributor

@lramos15 @jrieken If you're not seeing this anymore, can we close this? (and re-open if the behavior appears again)

@lramos15
Copy link
Member

Yes feel free to close and I will try to verify it for endgame

@andreamah andreamah added the bug Issue identified by VS Code Team member as probable bug label Mar 20, 2023
@mjbvz mjbvz added the verified Verification succeeded label Mar 22, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues perf search Search widget and operation issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants