Skip to content

Parallelize NetAnalyzers unit tests - #56028

Merged
Evangelink merged 2 commits into
mainfrom
dev/amauryleve/parallelize-netanalyzers-tests
Sep 1, 2026
Merged

Evangelink merged 2 commits into
mainfrom
dev/amauryleve/parallelize-netanalyzers-tests

Conversation

@Evangelink

@Evangelink Evangelink commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Summary

This is the independent net-analyzers replacement slice of #56015.

  • Enable MSTest MethodLevel parallelization for the NetAnalyzers unit-test assembly.
  • Document the concurrency requirement in the area-owned src/Microsoft.CodeAnalysis.NetAnalyzers/AGENTS.md guidance.

Ownership

@dotnet/dotnet-analyzers owns this NetAnalyzers test area, with agent and contributor guidance maintained in src/Microsoft.CodeAnalysis.NetAnalyzers/AGENTS.md.

Isolation rationale

Each test creates a self-contained Roslyn compilation through a fresh verifier instance. The assembly has no assembly-, class-, or test-initialization fixtures, and its shared state is limited to init-once immutable metadata references and dynamic-data providers. ReferenceAssemblies.ResolveAsync protects the shared package cache with its cross-process semaphore.

The added AGENTS guidance requires future fixtures, data sources, process-global state, and filesystem paths to remain safe for concurrent test methods.

10× benchmark results

The combined Razor-fixed branch was measured on the same machine under an exclusive benchmark lock. Each iteration ran the identical 54 affected projects sequentially through scripts/RunTests.cs, with the same 90-minute per-project timeout and the same exclusion for the pre-existing hanging interruption test.

Fleet statistic Baseline Changed Improvement
Mean 14,773.837s 7,341.516s 50.31%
Median 14,276.260s 6,742.966s 52.77%
Min 14,193.833s 5,426.805s —
Max 18,277.595s 10,443.242s —

All 10 changed iterations completed with zero timeouts and retained exactly the same 10-project local-environment/prerequisite failure set as all 10 baseline iterations; there were no new or resolved failing projects. These combined-branch measurements provide performance and stability context, not isolated attribution or a per-slice tests-passed claim.

A separate 10-run NetAnalyzers measurement completed with exit code 0 on every run and no failures or timeouts.

NetAnalyzers statistic Baseline Changed Improvement
Mean 402.691s 122.301s 69.63%
Median 364.287s 121.878s 66.54%
Min 354.850s 114.518s —
Max 760.757s 138.448s —

Raw baseline seconds: 760.757, 370.872, 367.239, 370.873, 356.237, 360.802, 362.482, 356.704, 366.091, 354.850.

Raw changed seconds: 138.448, 125.842, 126.657, 124.467, 123.759, 117.878, 116.751, 114.518, 114.689, 119.998.

@azure-pipelines

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

@Evangelink
Evangelink marked this pull request as ready for review August 31, 2026 17:00
@Evangelink
Evangelink requested review from a team, lbussell and mthalman as code owners August 31, 2026 17:00
Copilot AI lite review requested due to automatic review settings August 31, 2026 17:00
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 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

🔵 Needs a closer look

Review tier: Lite
Findings: 2 Low severity

New issues introduced by this change (2)
Severity Finding
Low severity src/​Microsoft.CodeAnalysis.NetAnalyzers/​tests/​Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/​Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.csproj — The justification comment hard-codes a Windows-only temp path ("%TEMP%\test-packages") and asserts…
Low severity src/​Microsoft.CodeAnalysis.NetAnalyzers/​AGENTS.md — AGENTS.md says "the unit-test assembly" uses method-level parallelization, but this doc applies to…
What changed in this PR

Enables MSTest method-level parallelization for the NetAnalyzers unit-test assembly (overriding the repo-wide default that disables parallel execution) and updates area guidance to reflect the new concurrency requirement.

Changes:

  • Set MSTestParallelizeScope to MethodLevel for Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.
  • Document the method-level parallelization expectation in src/Microsoft.CodeAnalysis.NetAnalyzers/AGENTS.md.
File Description
src/​Microsoft.CodeAnalysis.NetAnalyzers/​tests/​Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/​Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.csproj Opts the NetAnalyzers unit-test project into method-level MSTest parallelization via MSTestParallelizeScope.
src/​Microsoft.CodeAnalysis.NetAnalyzers/​AGENTS.md Notes that the unit-test assembly runs with method-level parallelization and that new additions must remain concurrency-safe.

@Evangelink
Evangelink enabled auto-merge (squash) September 1, 2026 08:11
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4a0fad96-150a-46b2-a506-ea3a47fc0c1b
@Evangelink
Evangelink merged commit 49519ab into main Sep 1, 2026
28 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/parallelize-netanalyzers-tests branch September 1, 2026 14:14
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 2, 2026

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 31f8ffec Deployed Sep 1, 2026 by Evangelink via pre_activation #2223
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