-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Avoid conhost processes for worker nodes on Windows #12356
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
Conversation
- Added DETACHED_PROCESS constant (0x00000008) to NativeMethods.cs - Added DETACHED_PROCESS flag to creationFlags in NodeLauncher.cs for Windows only - This prevents child nodes from being actual child processes of the parent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes resource usage on Windows by preventing the creation of unnecessary conhost.exe processes for MSBuild worker nodes. Worker nodes don't require console output, but Windows automatically attaches console host processes to console subsystem applications like MSBuild.exe.
- Added
DETACHED_PROCESSflag constant to prevent console inheritance - Modified worker node creation to use the
DETACHED_PROCESSflag alongside existingCREATENOWINDOWflag
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Build/BackEnd/Node/NativeMethods.cs | Added DETACHED_PROCESS constant definition for Windows process creation |
| src/Build/BackEnd/Components/Communications/NodeLauncher.cs | Applied DETACHED_PROCESS flag when launching worker nodes to prevent console attachment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
This reverts commit 7bebbdd.
### Context On Windows, apps targeting the console subsystem, like `MSBuild.exe`, get [launched by default with a console](https://learn.microsoft.com/windows/console/creation-of-a-console), which on modern Windows means that it gets an attached `conhost.exe` process. This has been happening with our worker nodes, but isn't necessary and uses some resources. <img width="203" height="533" alt="Screenshot of Task Explorer showing a bunch of dotnet processes each with a conhost process child" src="https://github.com/user-attachments/assets/df753c95-4a3d-4c05-bbec-bbf8b8e4fd1a" /> ### Changes Made Pass `DETACHED_PROCESS` when we are already jumping through hoops to avoid creating console windows on Windows. ### Testing <img width="151" height="421" alt="Screenshot of Task Explorer showing a bunch of dotnet processes with no conhost children (and a couple of other processes)" src="https://github.com/user-attachments/assets/c028e050-b51f-4472-851c-bcfb616947cf" /> --------- Co-authored-by: Copilot <[email protected]>


Context
On Windows, apps targeting the console subsystem, like
MSBuild.exe, get launched by default with a console, which on modern Windows means that it gets an attachedconhost.exeprocess.This has been happening with our worker nodes, but isn't necessary and uses some resources.
Changes Made
Pass
DETACHED_PROCESSwhen we are already jumping through hoops to avoid creating console windows on Windows.Testing