Eliminate conhost.exe from git.exe and hooks process launches#1981
Open
ShiningMassXAcc wants to merge 1 commit into
Open
Eliminate conhost.exe from git.exe and hooks process launches#1981ShiningMassXAcc wants to merge 1 commit into
ShiningMassXAcc wants to merge 1 commit into
Conversation
wilbaker
reviewed
May 21, 2026
4c8b9ee to
2714f45
Compare
GVFS launches git.exe processes with CreateNoWindow=true (or CREATE_NO_WINDOW in native code). Despite the name, this flag tells Windows to create a new hidden console for each child process, which allocates a conhost.exe instance. For frequent, small git operations (e.g., during prefetch), the per-process conhost creation/teardown overhead is disproportionately large. Changes: - GitProcess.cs: Set CreateNoWindow=false. With UseShellExecute=false and stdout/stderr redirected to pipes, the child inherits the parent's console state. Since GVFS.Mount runs as a service with no console, the child gets no console and no conhost. Also remove the unused redirectStandardError parameter (all callers pass true). - ProcessHelper.cs: Set CreateNoWindow=false unconditionally. When redirectOutput is true, I/O goes through pipes so no console is needed. When redirectOutput is false, the child inherits the parent's console handles, which is correct for terminal contexts and harmless in service contexts (output was already going to an invisible hidden console). - GitHooksLoader.cpp: Use DETACHED_PROCESS instead of CREATE_NO_WINDOW in the no-console branch. Explicitly detaches from any console without allocating a new one. The console branch (user terminal) is unchanged. Verified with edge-case tests across terminal, hidden-console, and fully-detached (DETACHED_PROCESS) parent contexts. All git status, git fetch (prefetch hook), and gvfs health scenarios pass. Assisted-by: Tyrie Vella <tyrielv@gmail.com> Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
2714f45 to
6c01575
Compare
tyrielv
approved these changes
May 22, 2026
wilbaker
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GVFS launches git.exe processes with
CreateNoWindow=true(orCREATE_NO_WINDOWin native code). Despite the name, this flag tells Windows to create a new hidden console for each child process, which allocates aconhost.exeinstance. For frequent, small git operations (e.g., during prefetch), the per-process conhost creation/teardown overhead is disproportionately large.Changes
GitProcess.cs:827CreateNoWindow = truetofalseProcessHelper.cs:21CreateNoWindow = redirectOutputtofalseGitHooksLoader.cpp:132CREATE_NO_WINDOWtoDETACHED_PROCESSHow it works
CreateNoWindow = falsewithUseShellExecute = false: child inherits parent console state. Since GVFS runs as a service with no console, child gets no console and no conhost.DETACHED_PROCESS(native): explicitly detaches from any console without allocating a new one.Verification
Conhost elimination confirmed
CreateNoWindow=true(old)CreateNoWindow=false(new)Benchmark (3 runs x 50 git.exe invocations)
For a prefetch spawning 20-50 git.exe processes, this eliminates ~380-960ms of pure conhost overhead per cycle.
Reference