Increase Helix work item chunk size for NetAnalyzer tests#53930
Closed
MichaelSimons wants to merge 7 commits intodotnet:mainfrom
Closed
Increase Helix work item chunk size for NetAnalyzer tests#53930MichaelSimons wants to merge 7 commits intodotnet:mainfrom
MichaelSimons wants to merge 7 commits intodotnet:mainfrom
Conversation
The NetAnalyzer unit tests were being split into ~197 tiny work items (avg 40s each) due to the default methodLimit of 16. This creates excessive per-item overhead in Helix (payload download, setup, results upload) and consumes machine slots that could serve longer-running tests. Use a 5x larger methodLimit for NetAnalyzer assemblies, reducing the ~197 items to ~39 items averaging ~3-4 minutes each. This better matches the available machine count and amortizes per-item overhead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Helix xUnit work item partitioning to reduce Helix overhead caused by excessive fragmentation of the Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.dll test run.
Changes:
- Introduce a
methodLimitvariable forAssemblySchedulerinstead of inlining the conditional. - Detect NetAnalyzers test assemblies and increase the
AssemblySchedulermethodLimitby 5x to produce fewer, larger work items.
| } | ||
|
|
||
| var scheduler = new AssemblyScheduler(methodLimit: !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TestFullMSBuild")) ? 32 : 16); | ||
| int methodLimit = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TestFullMSBuild")) ? 32 : 16; |
Introduce HelixSchedulingConfig.xml (embedded resource) that specifies per-assembly MethodLimitMultiplier and EstimatedSecondsPerMethod. - MethodLimitMultiplier controls chunk size: oversharded assemblies (NetAnalyzers 5x, StaticWebAssets 4x, TemplateEngine.Cli 11x, etc.) get consolidated into fewer, larger work items. - EstimatedSecondsPerMethod enables longest-first (LPT) scheduling: after all work items are created, they are sorted by estimated duration descending so Helix machines pick up heavy items first. This reduces the chance of long items stacking on the same machine. Based on analysis of build 1382230 (TestBuild: linux x64) where 475 work items ran on 39 machines with 40min wall-clock despite a 17min longest item — caused by machine load imbalance and 197 tiny NetAnalyzer items consuming scheduling overhead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Skip RunFileTests_CscOnlyAndApi.CscOnly to eliminate retry amplification and get a clean measurement of Helix scheduling optimizations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 17, 2026
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.
Summary
Introduces config-driven Helix work item scheduling to reduce CI wall-clock time by:
MethodLimitMultiplierin a checked-in XML configProblem
Analysis of build 1382230 (TestBuild: linux x64) showed:
a00FR27got 3 heavy items stacked (30 min total) while others had <5 min — load imbalance from FIFO dispatchTemplateEngine.Cli,Build.Tasks,ApiDiff, etc.) were also oversharded into 8-11 tiny itemsChanges
HelixSchedulingConfig.xml(new, embedded resource)Per-assembly configuration with two knobs:
MethodLimitMultiplier: Controls chunk size. NetAnalyzers 5×, StaticWebAssets 4×, TemplateEngine.Cli 11×, etc.EstimatedSecondsPerMethod: Enables LPT scheduling. Publish.Tests (22s/method) gets dispatched before NetAnalyzers (2.5s/method).HelixSchedulingConfig.cs(new)Loads the embedded XML and provides lookup methods for multiplier and estimated duration.
SDKCustomCreateXUnitWorkItemsWithTestExclusion.cs(modified)Expected impact
How to validate
Compare the TestBuild linux (x64) leg of this PR's CI run against the baseline:
Run TestBuild Testsstep