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

Search Service consumes 70% of my CPU on startup for quite some time #34434

Closed
dbaeumer opened this issue Sep 15, 2017 · 28 comments
Closed

Search Service consumes 70% of my CPU on startup for quite some time #34434

dbaeumer opened this issue Sep 15, 2017 · 28 comments
Assignees
Labels
search Search widget and operation issues

Comments

@dbaeumer
Copy link
Member

Latest insider On Windows

  • starte code-insiders on a vscode workspace

You get:

cast

@dbaeumer dbaeumer added search Search widget and operation issues bug Issue identified by VS Code Team member as probable bug labels Sep 15, 2017
@dbaeumer
Copy link
Member Author

@joaomoreno FYI

@joaomoreno
Copy link
Member

I don't see the same process madness as @dbaeumer, but I do see this in the devtools:

image

cc @jrieken

@jrieken
Copy link
Member

jrieken commented Sep 15, 2017

Yep, seeing the same

@jrieken
Copy link
Member

jrieken commented Sep 15, 2017

Also these things seem to stick around for way to long...

screen shot 2017-09-15 at 13 09 52

@roblourens
Copy link
Member

Do they pile up when you do a text search or just quickopen?

@jrieken
Copy link
Member

jrieken commented Sep 15, 2017

I start the product. That's it. My guess is that extensions using the workspaceContains-event trigger a search for file names. And yes, they do pile up.

@roblourens
Copy link
Member

I'm not seeing it, but I am seeing the error that @joaomoreno posted at least so I can start there.

@roblourens
Copy link
Member

Can you grab the grab the args from a few of those rg processes with ps?

@jrieken
Copy link
Member

jrieken commented Sep 15, 2017

nah, deleted the vscode-ripgrep module because my system was practically un-usable when running ./scripts/code often. Tho, I do remember seeing some glob patterns in htop

@roblourens
Copy link
Member

Can you give me your extensions list?

@roblourens
Copy link
Member

I fixed the error that @joaomoreno posted. @dbaeumer's issue is possibly doing too much work because of #34487. I never saw @jrieken's issue but please try again.

@jrieken jrieken added the important Issue identified as high-priority label Sep 20, 2017
@jrieken
Copy link
Member

jrieken commented Sep 20, 2017

This is just killing me. @roblourens to reproduce do this

  • install the c#-extension or any extension with many workspace contains activation events
  • have a large workspace, e.g. / or a folder with node modules
  • start vscode and when it's up hit refresh, repeat 5 times
  • 🐛 many rg processes

screen shot 2017-09-20 at 16 17 31

Yes, the activation of extensions is a little stupid and should merge the query per extension but the disk search should not spawn so many processes and eventually start queuing process execution and it should make sure to kill the processes (which is hard usually the child process must check if its parent pid is still alive and self-terminate)

@roblourens
Copy link
Member

roblourens commented Sep 20, 2017

I can repro this on / now and we can at least shut down the rg processes properly when the window closes or reloads. I'm still confused as to why it's so slow for you just in the vscode folder. Those searches terminate for me in a few milliseconds. Does the screenshot show the vscode workspace or /? If it's vscode, that's a problem.

Also just to confirm, this isn't new, right? I see the same behavior with find. It might be more noticeable now, since rg is more efficient and parallelized, and will probably use higher CPU while it runs but complete sooner.

And also, there's yet another issue that Dirk shows where the rg processes terminate quickly, but the searchService uses high CPU for a long time.

To summarize this issue up to this point:

  • console errors when launching with workspaceContains
    • Fixed
  • rg processes not shut down when the windows closes or reloads
    • I can fix
  • rg processes run slowly and pile up in vscode workspace for @jrieken
    • I don't repro, they complete and terminate almost immediately
  • After rg processes terminate quickly, searchService takes high CPU for awhile, in vscode repo, on Windows, for @dbaeumer
    • I think I can repro, it's not nearly to the same degree but it's running longer than it takes on Mac. I can check whether we are doing something dumb.

@peabnuts123
Copy link

peabnuts123 commented Sep 24, 2017

Just to chip in here, on my Macbook Pro the search service ramps up to high CPU usage (100% of a core) on startup and never terminates on both my work and home laptops. I'm not 100% confident this happens without any extensions but I am also not 100% sure that means it isn't vscode's problem.

image

image

image

@roblourens
Copy link
Member

Pushed the change to ensure it's killed. I will open an issue just for that to make sure it gets verified. The rest of #34434 (comment) I will investigate in October.

@peabnuts123
Copy link

If anybody here has the exact problems that I described above, I tracked it down to the Omnisharp-vscode C# extension. Try disabling that if you have issues.

I've opened an issue here: dotnet/vscode-csharp#1770

@roblourens
Copy link
Member

Thanks for the datapoint - No need to file an issue on individual extensions, this will impact any extension that uses the workspaceContains pattern to activate when the workspace contains a certain type of file. The C# extension triggers this in particular because it happens to use several of these.

You should see an improvement already in the latest insiders (https://az764295.vo.msecnd.net/insider/683a46efbab870527671f1ae55f9ebce5f3f5a3c/VSCode-darwin-insider-unsigned.zip) because we will batch these per extension. But it won't go away entirely.

@peabnuts123
Copy link

I see. I hadn't fully realised that there was a concrete issue with vscode itself that was causing these problems

@roblourens
Copy link
Member

Discussion for this has also spread out into

#34487
#34711
and
#34823

@Chillee
Copy link

Chillee commented Oct 1, 2017

I've had a similar issue for a while. It seems to usually appear when I accidentally start vscode in the home directory, for example. The process does not close upon the vscode instance being closed.

@jrieken
Copy link
Member

jrieken commented Oct 3, 2017

Pushed the change to ensure it's killed.

@roblourens I still see plenty of rg-processes (without a parent) on my machine.

screen shot 2017-10-03 at 10 42 20

It's from scripts/code.sh and they all look like this

13609 ttys001    0:48.65 /Users/jrieken/Code/vscode/node_modules/vscode-ripgrep/bin/rg --files --hidden --case-sensitive -g **/test* -g !Users/jrieken/Code/_samples/ConsoleAppDnx -
jrieken:~/Code$

@jrieken
Copy link
Member

jrieken commented Oct 3, 2017

Unsure how these processes are meant to die but from my experience it is hopeless to try to manage from the outside, e.g. ext-host/renderer killing them on shutdown, because the "outside" my disappear without notice. Usually, we put something into the processes, like a pointer to the parent/owner, and when that disappears the processes shutdown themselves. Maybe you are already doing that tho...

For instance the extension host checks every 5 secs if its owning renderer process is still around

@roblourens
Copy link
Member

How are you killing vscode? It's not bulletproof but should at least work for a normal shutdown.

We don't own the rg process, ideally I think we would run ripgrep as a library from a process we control, not yet possible.

@jrieken
Copy link
Member

jrieken commented Oct 4, 2017

How are you killing vscode?

Depends, but during development and when I am in the console anyways often with Ctrl+C

It's not bulletproof but should at least work for a normal shutdown.

I don't think that's enough, processes crash and when that happens it will leak.

@roblourens
Copy link
Member

That's true but I think it's the best we can do without making a change in ripgrep. But it sounds like there is still the real problem of the rg processes not terminating when they are actually finished, which I haven't been able to repro.

@chrmarti
Copy link
Contributor

@jrieken You could use sudo opensnoop -n rg to check if it is still accessing files.

@chrmarti
Copy link
Contributor

@jrieken Do you still see these? Could you post the full command line (the above seems truncated)? And maybe run the same command from the workspace folder (redirect stdout to /dev/null) to see what that does and outputs on stderr?

@chrmarti chrmarti removed this from the November 2017 milestone Dec 1, 2017
@roblourens
Copy link
Member

Still an issue? I still haven't encountered this...

@roblourens roblourens removed bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority labels Sep 12, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
search Search widget and operation issues
Projects
None yet
Development

No branches or pull requests

7 participants