Skip to content

Consolidate Helix shards for quick test assemblies via MethodLimitMultiplier#54115

Draft
MichaelSimons wants to merge 4 commits intodotnet:mainfrom
MichaelSimons:consolidate-helix-shards
Draft

Consolidate Helix shards for quick test assemblies via MethodLimitMultiplier#54115
MichaelSimons wants to merge 4 commits intodotnet:mainfrom
MichaelSimons:consolidate-helix-shards

Conversation

@MichaelSimons
Copy link
Copy Markdown
Member

@MichaelSimons MichaelSimons commented Apr 27, 2026

Summary

Adds a MethodLimitMultiplier metadata option for SDKCustomXUnitProject items to consolidate Helix test shards for assemblies that produce many very short work items. This reduces per-item overhead (payload download, setup, teardown) and makes us better citizens of the shared Helix queues.

How it works

AssemblyScheduler partitions each test assembly into shards based on a methodLimit threshold (default 16, or 32 for FullFramework). MethodLimitMultiplier simply multiplies that threshold, producing fewer, larger shards. It is set via MSBuild item metadata in UnitTests.proj — no new config files.

Changes

  • SDKCustomCreateXUnitWorkItemsWithTestExclusion.cs — Reads optional MethodLimitMultiplier metadata; warns on invalid values
  • UnitTests.proj — Applies multipliers to three assembly groups:
    • NetAnalyzers (x5)
    • TemplateEngine / TemplateSearch (x20)
    • Api — ApiCompatibility, ApiDiff, ApiSymbolExtensions, GenAPI (x10)

Results

Linux x64

Group Main Shards (Avg) PR Shards (Avg / Max) Saved Compute Saved
NetAnalyzers 197 (42s) 70 (2m12s / 5m05s) 127 TBD
TemplateEngine¹ 41 (19s) 15 (1m10s / 3m22s) 26 TBD
Api¹ 19 (17s) 5 (0m21s / 0m26s) 14 TBD
Total 514 334 180 TBD

Windows x64

Group Main Shards (Avg) PR Shards (Avg / Max) Saved Compute Saved
NetAnalyzers 197 (1m45s) 70 (2m24s / 4m03s) 127 TBD
TemplateEngine¹ 41 (1m50s) 15 (1m01s / 2m29s) 26 TBD
Api¹ 19 (1m50s) 5 (2m13s / 2m22s) 14 TBD
Total 517 337 180 TBD

macOS x64

Group Main Shards (Avg) PR Shards (Avg / Max) Saved Compute Saved
NetAnalyzers 197 (1m15s) 70 (1m30s / 2m23s) 127 TBD
TemplateEngine¹ 50 (50s) 15 (0m53s / 1m30s) 35 TBD
Api¹ 23 (45s) 5 (0m43s / 1m16s) 18 TBD
Total 514 334 180 TBD

FullFramework Windows

Group Main Shards (Avg) PR Shards (Avg / Max) Saved Compute Saved
NetAnalyzers 129 (2m13s) 40 (3m37s / 5m44s) 89 TBD
TemplateEngine¹ 33 (1m18s) 15 (2m20s / 2m46s) 18 TBD
Api¹ 20 (1m53s) 8 (2m24s / 2m54s) 12 TBD
Total 347 228 119 TBD

Overall

Leg Main Shards PR Shards Saved Compute Saved
Linux x64 514 334 180 TBD
Windows x64 517 337 180 TBD
macOS x64 514 334 180 TBD
FullFx Windows 347 228 119 TBD
Total 1892 1233 659 TBD

¹ TemplateEngine and Api assemblies are now at one shard per assembly — the minimum possible without cross-assembly consolidation. Further shard reduction for these groups would require changes to the Helix sharding model itself.

MichaelSimons and others added 2 commits April 27, 2026 20:27
…tiplier

Add per-assembly MethodLimitMultiplier metadata support to reduce wasted
Helix compute on assemblies whose shards all complete very quickly. The
multiplier increases the methods-per-shard threshold, producing fewer but
larger work items and reducing per-item setup overhead.

Applied to three assembly groups:
- Microsoft.CodeAnalysis.NetAnalyzers (x5)
- Microsoft.TemplateEngine.* / TemplateSearch.* (x10)
- Microsoft.DotNet.Api{Compatibility,Diff,SymbolExtensions} (x5)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TE assemblies are already single-shard on FullFramework at x10.
The x20 bump collapses the remaining 2-shard assemblies on TestBuild
legs (Cli.UnitTests, Core.UnitTests, Orchestrator) to single shards.

Api group bumped to x10 and expanded to include GenAPI.Tests and
PackageValidation.Tests for additional shard savings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MichaelSimons MichaelSimons force-pushed the consolidate-helix-shards branch from bbc8430 to db5ebf7 Compare April 28, 2026 13:13
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.

1 participant