[wip experiment] Key transient MSBuild Server per build root, not one-per-machine - #14262
Closed
JanProvaznik wants to merge 1 commit into
Closed
[wip experiment] Key transient MSBuild Server per build root, not one-per-machine#14262JanProvaznik wants to merge 1 commit into
JanProvaznik wants to merge 1 commit into
Conversation
A /mt build with node reuse off engages the MSBuild Server purely to get Server GC, then shuts it down after the build (added in #14248). Because the server's pipe and mutex names are one-per-machine (per architecture/user/ version), two such transient builds running at once contend for a single server: all but one find it busy and fall back to an in-process, Workstation-GC build - losing the Server GC that /mt depends on. Key transient servers per build root instead: the entry project's full path (or the current directory when none is resolved) is folded into the handshake salt, which drives the pipe/mutex names. Both the client and the server it launches (which inherits the client's environment) derive the same per-root names, so parallel builds of different roots each get their own short-lived Server-GC server. Builds of the same root still share one server (the second concurrent build falls back), so it is one transient server per root, not an unbounded number per invocation. Reusable (non-transient) servers are unchanged and remain one-per-machine. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Context
A
/mtbuild with node reuse off (-nr:false, asdotnet restoredoes) engages the MSBuild Server purely to obtain Server GC, which/mtdepends on for performance, and then shuts the server down after the build (added in #14248).But the server's pipe and mutex names are one-per-machine (keyed by architecture/user/version/session). So when two such transient builds run at the same time, they contend for a single server: all but one find it busy and fall back to an in-process, Workstation-GC build — defeating the whole point of engaging the server under
/mt.Change
Key transient (non-reused) servers per build root instead of one-per-machine:
CanRunServerBasedOnCommandLineSwitchesnow emits aserverRootKey— the entry project's full path, or the current directory when no project is resolved — whenevershutdownServerAfterBuildis set (/mt+ node reuse off).Mainfolds that key into theMSBUILDNODEHANDSHAKESALTbefore handing off to the client. The salt drives the handshake hash that names the pipe and mutex, and the launched server inherits the client's environment, so both derive the same per-root names.Testing
New unit test
TransientServerIsKeyedPerRootAllowingConcurrentServers: two concurrent distinct-root-mt -nr:falsebuilds run in two distinct, simultaneously-alive server processes, both with Server GC, and both shut down afterward. All existingMSBuildServer_Testspass.Verified live on the bootstrap:
/nodemode:8servers, eachServerGC=True, 0 survivors afterward.ServerGC=True); the other two fall back to in-proc Workstation-GC builds.dotnet buildmuxer (DOTNET_CLI_USE_MSBUILD_SERVER=1), 2 roots → two distinctMSBuild.exe /nodemode:8Server-GC servers concurrently, both transient.Docs updated in
documentation/MSBuild-Server.md.