Skip to content

Enable safe TemplateEngine test parallelization - #55993

Merged
Evangelink merged 1 commit into
dotnet:mainfrom
Evangelink:dev/amauryleve/template-utility-audit
Sep 9, 2026
Merged

Evangelink merged 1 commit into
dotnet:mainfrom
Evangelink:dev/amauryleve/template-utility-audit

Conversation

@Evangelink

Copy link
Copy Markdown
Member

These TemplateEngine test projects currently run serially despite having independent test-class fixtures. This opts them into conservative class-level parallelism so independent classes can overlap without exposing method-scoped shared state to concurrency.

Summary

  • Enable MSTestParallelizeScope=ClassLevel in five TemplateEngine utility, search, localization, edge, and discovery test projects.
  • Preserve serial execution within classes that share settings helpers, mutable providers, package-manager state, culture-sensitive fixtures, fixed package outputs, or custom hives.
  • Avoid broad resource locks and DoNotParallelize because the audited shared state is contained within individual classes.

Validation

Local test and benchmark execution was intentionally deferred so the change can be measured in the coordinated 10-run baseline/changed full-fleet benchmark after integration.

Copilot AI lite review requested due to automatic review settings August 28, 2026 15:20
@Evangelink
Evangelink requested a review from a team as a code owner August 28, 2026 15:20
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

Review tier: Lite
Findings: None

What changed in this PR

This PR opts five TemplateEngine MSTest.Sdk test projects into conservative class-level parallel execution by overriding the repo default (test/Directory.Build.props sets MSTestParallelizeScope=None). The intent is to allow independent test classes to overlap while keeping methods within each class serialized to avoid class-scoped shared state conflicts.

Changes:

  • Set <MSTestParallelizeScope>ClassLevel</MSTestParallelizeScope> in five TemplateEngine test .csproj files.
  • Add explanatory comments in each project file describing the intended isolation/serialization boundary (methods serialized within a class; classes may run concurrently).
File Description
test/​TemplateEngine/​Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/​Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests.csproj Enables MSTest class-level parallelization for template discovery integration tests while keeping per-class method runs serial.
test/​TemplateEngine/​Microsoft.TemplateSearch.Common.UnitTests/​Microsoft.TemplateSearch.Common.UnitTests.csproj Enables class-level parallelization for TemplateSearch common unit tests, preserving class-internal serialization for shared fixtures.
test/​TemplateEngine/​Microsoft.TemplateEngine.Utils.UnitTests/​Microsoft.TemplateEngine.Utils.UnitTests.csproj Enables class-level parallelization for TemplateEngine utils unit tests across TFMs, keeping method runs serial within each class.
test/​TemplateEngine/​Microsoft.TemplateEngine.TemplateLocalizer.Core.UnitTests/​Microsoft.TemplateEngine.TemplateLocalizer.Core.UnitTests.csproj Enables class-level parallelization for TemplateLocalizer core unit tests with method serialization within each class.
test/​TemplateEngine/​Microsoft.TemplateEngine.Edge.UnitTests/​Microsoft.TemplateEngine.Edge.UnitTests.csproj Enables class-level parallelization for TemplateEngine edge unit tests, preserving class-internal serialization for shared state.

@Evangelink

Copy link
Copy Markdown
Member Author

Local before/after benchmark

Local gain confirmed on my Windows machine using the SDK repo test runner.

  • Machine: Microsoft Windows 11 Enterprise, AMD RYZEN AI MAX+ 395 w/ Radeon 8060S , 32 logical processors
  • Baseline: origin/main (890dd7f)
  • PR head: dev/amauryleve/template-utility-audit (4f9feb6)
  • Command shape: .\.dotnet\dotnet.exe scripts\RunTests.cs -- --project <project>
  • Reported numbers use the test run duration from the runner output; build/setup wall-clock is excluded.

Comparable clean total: 1m 13.4s before -> 58.424s after (14.963s saved, 20.4%).

Project Before After Delta Result
Microsoft.TemplateEngine.Edge.UnitTests 25.006s 18.492s 6.514s passed
Microsoft.TemplateEngine.TemplateLocalizer.Core.UnitTests 0.812s 0.794s 0.018s passed
Microsoft.TemplateEngine.Utils.UnitTests 0.791s 0.821s -0.03s passed; slower in this run
Microsoft.TemplateSearch.Common.UnitTests 11.729s 6.619s 5.11s passed
Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests 35.049s 31.698s 3.351s passed

Single local run; timings can vary with machine load, but this gives a direct before/after signal on this machine.

@Evangelink
Evangelink merged commit 7e3b393 into dotnet:main Sep 9, 2026
23 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/template-utility-audit branch September 9, 2026 05:40
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 10, 2026

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 4f9feb65 Deployed Sep 9, 2026 by Evangelink via pre_activation #3618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants