Skip to content

Reduce MTP startup work and service-resolution allocations by @thomhurst in #12069 (backport to rel/4.5) - #12086

Merged
Amaury Levé (Evangelink) merged 2 commits into
microsoft:rel/4.5from
nohwnd-bot:backport/12069/to/rel/4.5
Oct 26, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
microsoft:rel/4.5from
nohwnd-bot:backport/12069/to/rel/4.5

Conversation

@nohwnd-bot

@nohwnd-bot nohwnd-bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Release-applicable backport of #12069 to rel/4.5, sourced from merge commit 92cbd59de751ca7ce5a44974073c30badeee93f5. This preserves the command-line option index optimization, cached internal-extension types, direct first-match service resolution, lazy missing-service diagnostics, and the no-controller configuration fast path.

The original backport head 06f71daed6fd1aa568ba3a509adfe9e9f1b520bb already contained real source changes, but also committed merge-conflict markers and a main-only run-completion handler block. Repair commit 4c0d2967377fd3e2aa37484bce8af38442eb6c25 removes that incompatible block and adapts the fast path to the existing release controller/reporting lifecycle. It does not introduce run-completion handler APIs or import the separate build-date optimization in #12085.

Controller factories and enablement checks still execute before deciding whether a controller is required. Enabled registrations retain their ordering, custom launchers still force process restart, and service selection, internal visibility, case-insensitive option matching, duplicate failures, and missing-service exception type/message remain unchanged. Two additional release-specific tests cover empty controller configuration and disabled environment/lifetime/data-consumer/launcher factories, including their evaluation and lack of service registration.

Revision-bound validation

Base: d15f90a1218299d67e9d2c35395f58bf052c9854. Windows x64, repository-bootstrapped SDK 12.0.100-alpha.1.26480.103, Release configuration, test runtime 9.0.20. Direct MSBuild commands used -m:2 -nr:false.

Check Result
Compile original backport head, net9.0 Exit 1; three CS8300 merge-conflict errors in TestHostControllersManager.cs.
Build release-base platform baseline, net9.0 Exit 0; zero errors, one MSB4011 warning from the temporary baseline-source import hook.
Build repaired platform: net8.0, net9.0, netstandard2.0 Exit 0; zero warnings/errors.
Build retained net9.0 unit-test assembly Exit 0; zero warnings/errors.
Focused tests with release-base platform DLL Exit 0; 653 passed, 0 failed, 0 skipped.
Identical test assembly with repaired platform DLL Exit 0; 653 passed, 0 failed, 0 skipped.
Whitespace, C# BOMs, changed-file conflict/placeholder checks Passed; six real source/test files, no conflict markers or changes.patch in the PR diff.

The baseline uses the four touched production files exported verbatim with git archive from the base commit; their extracted Git blob IDs were verified. A temporary CustomBeforeMicrosoftCommonTargets hook substituted only those files during the baseline platform build. The baseline DLL was saved, the repaired host built, and the same retained test assembly run once with each platform DLL. Both TRX files confirm the new controller cases and the preserved first-match/internal-visibility/missing-diagnostic cases passed.

Retained test-assembly SHA-256: 24879C79B57E9BB9D7AFD0159E0031D7DBDE3B51448360BBADC3883BE4DF3A67.

Commands from the repository root:

# Original broken head: exit 1, three CS8300 errors.
.\.dotnet\dotnet.exe build src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj -c Release -f net9.0 -m:2 -nr:false -p:TargetFrameworks=net9.0 -p:SupportedNetFrameworks=net9.0 -p:SkipUapTargetFramework=true '-p:ModernUwpMinimum=' '-p:WinUiMinimum=' '-bl:artifacts\backport-12086\broken-head-direct-{}.binlog' -v minimal

# Release baseline: exit 0, one temporary-import MSB4011 warning.
$baselineTargets = (Resolve-Path .\artifacts\backport-12086\release-baseline.targets).Path
.\.dotnet\dotnet.exe build src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj --no-restore -c Release -f net9.0 -m:2 -nr:false -p:TargetFrameworks=net9.0 -p:SupportedNetFrameworks=net9.0 "-p:CustomBeforeMicrosoftCommonTargets=$baselineTargets" '-bl:artifacts\backport-12086\release-baseline-net9-{}.binlog' -v minimal

# Repaired platform, all three release TFMs: exit 0, zero warnings/errors.
.\.dotnet\dotnet.exe build src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj -c Release -m:2 -nr:false '-bl:artifacts\backport-12086\repaired-all-frameworks-{}.binlog' -v minimal

# Retained net9.0 test host: exit 0, zero warnings/errors.
.\.dotnet\dotnet.exe build test\UnitTests\Microsoft.Testing.Platform.UnitTests\Microsoft.Testing.Platform.UnitTests.csproj --no-restore -c Release -f net9.0 -m:2 -nr:false -p:SupportedNetFrameworks=net9.0 -p:SkipUapTargetFramework=true '-p:ModernUwpMinimum=' '-p:WinUiMinimum=' '-bl:artifacts\backport-12086\unit-tests-net9-final-{}.binlog' -v minimal

The direct host command was executed with each selected DLL. The baseline run used --report-trx-filename baseline.trx --results-directory .\artifacts\backport-12086\results\baseline; the repaired run used the following command. Both exited 0 with 653 passed:

.\.dotnet\dotnet.exe .\artifacts\bin\Microsoft.Testing.Platform.UnitTests\Release\net9.0\Microsoft.Testing.Platform.UnitTests.dll --no-banner --progress off --filter 'FullyQualifiedName~CommandLine|FullyQualifiedName~ServiceProviderTests|FullyQualifiedName~TestApplicationBuilderTests|FullyQualifiedName~TestHostBuilderTests|FullyQualifiedName~ExtensionBuilderHelperTests|FullyQualifiedName~ToolsHostTests' --report-trx --report-trx-filename repaired.trx --results-directory .\artifacts\backport-12086\results\repaired

Binlogs, exported baseline sources, saved baseline/repaired DLLs, and both TRX files are retained locally under artifacts\backport-12086.

Limitations

The repository build script bootstrapped the pinned SDK/workloads, but its nested eng\common\dotnet-install.cmd runtime-install step could not resolve legacy powershell on this host; the inner toolset build failed, despite the wrapper returning exit 0. The successful compilation commands above therefore use the bootstrapped local SDK directly. The required pinned test runtime was installed successfully using eng\common\dotnet-install.ps1 -runtime dotnet -version 9.0.20 -dotnetPath <worktree>\.dotnet -architecture x64.

Execution coverage is the focused net9.0 selection, not the full suite or acceptance tests; net8.0 and netstandard2.0 were compiled, not executed. No new performance measurements are claimed for this release branch. Unrelated conflict markers in src\Platform\Microsoft.Testing.Extensions.PackagedApp\InternalAPI\InternalAPI.Unshipped.txt are already present in the base revision and are unchanged by this PR; full-repository CI can still encounter that inherited release-base problem. CI for the repair commit has not been awaited.

/cc Amaury Levé (@Evangelink) Tom Longhurst (@thomhurst)

@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 26, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 26, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Oct 26, 2026
Adapt the no-controller fast path to the release lifecycle without main-only run-completion handlers. Cover empty and disabled controller configurations while preserving factory evaluation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/approved Proposal approved; ready for implementation. labels Oct 26, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 4bffad0 into microsoft:rel/4.5 Oct 26, 2026
4 of 8 checks passed
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants