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

Git: Spawning git.exe takes over the event loop #71290

Closed
jrieken opened this issue Mar 27, 2019 · 12 comments
Closed

Git: Spawning git.exe takes over the event loop #71290

jrieken opened this issue Mar 27, 2019 · 12 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 git GIT issues perf
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Mar 27, 2019

Telemetry tells us that git is one of the extensions causes the extension host to freeze. I have capture the following, unsuspicious, profile. It only got reported to the log because the freeze was only for ~1sec. Anyways, we should see if there is something wrong with git or the cpu profile logic.

git-slow.cpuprofile.txt

@jrieken jrieken added extensions Issues concerning extensions perf labels Mar 27, 2019
@jrieken
Copy link
Member Author

jrieken commented Mar 28, 2019

I'd put my money on spawn. In the profile it's called ~10 times, often costing 30ms. On windows spawning is much slower, esp on some setups. @joaomoreno did we do this different before moving into the extension host? Didn't we have a dedicated process that manages git processes?

Screenshot 2019-03-28 at 14 02 19

@jrieken
Copy link
Member Author

jrieken commented Mar 28, 2019

From 24047 stalls caused by vscode.git, 18517 happen on windows, 1468 on mac, and 4062 on linux. I blame it on git and its usage of spawn, the reporting seems to work

@jrieken jrieken removed their assignment Mar 28, 2019
@jrieken jrieken added the git GIT issues label Mar 28, 2019
@joaomoreno
Copy link
Member

We did! In Visual Studio Online "Monaco". 😆

@jrieken Bringing it back means we'll have yet another process in our tree structure, serving the single purpose of spawning git.exe processes.

@joaomoreno joaomoreno added this to the Backlog milestone Mar 28, 2019
@jrieken
Copy link
Member Author

jrieken commented Mar 28, 2019

We did! In Visual Studio Online "Monaco".

No - before git became an extension, running in the UX process were these things aren't "accepted"

serving the single purpose of spawning git.exe processes.

If you rather prefer to block any other extension from working than that's your decision. Those 24047 stalls, are stalls over 5 secs exclusively caused by git. That's almost one work day wasted plus all the time below the threshold that we don't report.

@jrieken jrieken added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Mar 28, 2019
@joaomoreno
Copy link
Member

No - before git became an extension, running in the UX process were these things aren't "accepted"

Oh yeah, I guess we kept that going from Monaco.

If you rather prefer to block any other extension from working than that's your decision. Those 24047 stalls, are stalls over 5 secs exclusively caused by git. That's almost one work day wasted plus all the time below the threshold that we don't report.

@jrieken I don't dispute the severity, I 100% agree with you on that. I just find it hard to accept the tradeoff of having 50MB allocated for spawning processes.

Instead of forking, we could actually write a lightweight process spawner (C++/Rust) and just use that instead. 🤓

@joaomoreno
Copy link
Member

Reference issue: nodejs/node#14917

@jrieken
Copy link
Member Author

jrieken commented Mar 28, 2019

Instead of forking, we could actually write a lightweight process spawner (C++/Rust) and just use that instead. 🤓

I don't really care how you do it but it's kinda lame that we aggressively chase extensions that block the extension host (#70492) and on the other side ship a built-in extension that's almost the worst (git is second)

@jrieken
Copy link
Member Author

jrieken commented Mar 28, 2019

and you aren't alone, emmet is 3rd (#71381) moving up the ranks fast

@joaomoreno
Copy link
Member

joaomoreno commented Mar 28, 2019

Ahah check out this reply from that thread from @nathansobo back in 2017:

I don't understand the details of process spawning as well as I'd like, but I thought it might be helpful to report that the synchronous nature of child_process.spawn has been a problem for us in Atom. We were making pretty heavy use of spawn to run Git commands in the background, and eventually tracked it down as the source of intermittent pauses that were harming the responsiveness of the application.

As a solution, we moved all Git spawning to a separate Electron process. Since that eats way more memory than we'd like, I'm tinkering with a native spawn server that will serve a similar role to the server in node-spawn-async, but with a lighter memory footprint.

@jrieken
Copy link
Member Author

jrieken commented Mar 28, 2019

Well, I see that as a clear sign of moving things into a separate process. Sure, there is a memory drawback but it won't freeze the process anymore. One really bad thing and one less ideal thing

@joaomoreno
Copy link
Member

OK thanks for the help.

@joaomoreno joaomoreno changed the title git extension consuming much cpu Git: Spawning git.exe takes over the event loop Mar 28, 2019
@joaomoreno joaomoreno added the bug Issue identified by VS Code Team member as probable bug label Nov 4, 2020
@lszomoru lszomoru self-assigned this Oct 4, 2021
@isidorn isidorn removed the extensions Issues concerning extensions label Dec 6, 2022
@lszomoru
Copy link
Member

This does not seem to be an issue any more based on our recent telemetry data.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 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 git GIT issues perf
Projects
None yet
Development

No branches or pull requests

4 participants