[Server] -mt implies MSBuild Server (stacked on Server GC)#21
Closed
JanProvaznik wants to merge 1 commit into
Closed
[Server] -mt implies MSBuild Server (stacked on Server GC)#21JanProvaznik wants to merge 1 commit into
JanProvaznik wants to merge 1 commit into
Conversation
Stacked on the server-GC change. When -mt is on the command line and
MSBUILDUSESERVER is unset, engage MSBuild Server automatically; explicit
MSBUILDUSESERVER=0 always opts out (takes precedence over the implicit -mt
opt-in).
Unifies the multithreaded determination: a single IsMultiThreadedRequested(args)
lightweight scan now feeds BOTH the server opt-in decision (ShouldUseMSBuildServer)
and the server Server-GC selection (the base PR's multiThreaded flag passed to
MSBuildClientApp.Execute). This removes the base PR's out-parameter on
CanRunServerBasedOnCommandLineSwitches (reverted to its original signature) in
favor of the shared determination, so there is exactly one -mt detector.
Adds BuildTelemetry.ServerEnableReason ("EnvVar" / "ImpliedByMt") to measure
adoption of the implicit path separately from the explicit env-var path.
Test: ServerStartsWhenMtPresentEvenWithoutEnvVar runs two consecutive -mt builds
with MSBUILDUSESERVER unset and asserts the server PID is the same for both
(server reuse is the unique signature). Spec updated.
Investigation dotnet#9379, Thread F (-mt + server interaction).
Co-authored-by: Copilot <[email protected]>
Owner
Author
|
Superseded: converted the original dotnet#13758 (dotnet/msbuild) into the stacked-on-dotnet#14043 PR instead of using this temporary fork PR. The branch dev/janprovaznik/mt-implies-server now backs dotnet#13758. |
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.
-mtimplies MSBuild Server (withMSBUILDUSESERVER=0opt-out)When
-mtis on the command line andMSBUILDUSESERVERis unset, automatically engage MSBuild Server. ExplicitMSBUILDUSESERVER=0always opts out (takes precedence over the implicit-mtopt-in).Why stack on the Server GC PR?
The base PR introduced a single, canonical answer to one question — "is this a
-mtbuild?" — and used it to decide whether the server gets Server GC. This PR needs the same answer to decide whether to engage the server at all. Stacking lets both decisions share one-mtdetector instead of each shipping its own (the standalone dotnet#13758 carried a privateCommandLineContainsMultiThreadedSwitch, duplicating exactly what the base PR already had to reason about).Combined decision flow
The single
multiThreadedvalue drives two decisions: (1) whether to engage the server (this PR), and (2) how the server is launched — Server GC (base PR). They stay distinct (aMSBUILDUSESERVER=1, non--mtbuild engages the server without Server GC), but share one input.Decision table
MSBUILDUSESERVER-mtbuildServerEnableReason1EnvVar1EnvVar0ImpliedByMtDoes stacking enable further refactors for the decision + telemetry? — Yes
-mtdetector.IsMultiThreadedRequested(args)is now the sole source; the base PR'sCanRunServerBasedOnCommandLineSwitches(out multiThreaded)out-parameter is reverted to the original signature, and [Server] -mt implies MSBuild Server dotnet/msbuild#13758's private duplicate is gone.ShouldUseMSBuildServer(multiThreaded, out reason)is now the place server routing is decided inMain, replacing the inlineEnvVar == "1"check. Future inputs (e.g. a config-file default, a new switch) plug in here.ServerEnableReason(EnvVar/ImpliedByMt) is emitted right where the decision is made, so the existingServerFallbackReasonand this new field form a coherent server-routing telemetry surface.Implementation
XMake.Main: computemultiThreadedonce; gate onShouldUseMSBuildServer(multiThreaded, out reason); setServerEnableReason; revertCanRunServerBasedOnCommandLineSwitchesto its 1-arg form.IsMultiThreadedRequested(args): lightweight scan (no fullGatherAllSwitcheson the hot no-server path), honors-mt:false/:0andMSBUILDFORCEMULTITHREADED. Conservative on parse problems (declines the implicit opt-in only;=1unaffected).BuildTelemetry.ServerEnableReason.documentation/specs/multithreading/multithreaded-msbuild.md.Test
MSBuildServer_Tests.ServerStartsWhenMtPresentEvenWithoutEnvVar— two consecutive-mtbuilds withMSBUILDUSESERVERunset reuse the same server PID (server reuse is the unique signature). All 14MSBuildServer_Testspass, including the base PR's Server-GC tests.Open questions
"ImpliedByMt"— or something more neutral ("MtSwitch")?MSBUILDUSESERVER=false/nofor symmetry with other Boolean MSBuild env vars?-mtfrom a response file is not detected by the lightweight scan (so it triggers neither implicit server nor Server GC). Consistent across both decisions, but worth confirming we don't want the (more expensive) full-parse detection here.MSBUILDFORCEMULTITHREADED=1now implies server too (resolves [Server] -mt implies MSBuild Server dotnet/msbuild#13758's open Q3 affirmatively, for consistency with the Server GC determination) — confirm desired.