Skip to content

Fix Helix test sharding: parse TestFullMSBuild as boolean - #54000

Merged
MichaelSimons merged 1 commit into
dotnet:mainfrom
MichaelSimons:fix/helix-method-limit-parsing
Apr 21, 2026
Merged

MichaelSimons merged 1 commit into
dotnet:mainfrom
MichaelSimons:fix/helix-method-limit-parsing

Conversation

@MichaelSimons

Copy link
Copy Markdown
Member

Problem

The AssemblyScheduler methodLimit was determined by checking string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TestFullMSBuild")). The testFullMSBuild parameter defaults to false for all jobs (Windows, Linux, macOS).

However, only the Windows-conditional test step includes TestFullMSBuild in its env block (line 162), while the non-Windows test step does not set it at all (lines 168-178).

Since "false" is a non-empty string, IsNullOrEmpty returns false, and the code selects methodLimit=32 on Windows instead of the intended 16. On Linux/macOS the env var is absent (null), so methodLimit=16 is correctly used.

Impact

This caused an unintentional asymmetry in Helix work item counts (observed in build 1387124):

  • Windows TestBuild: 329 work items (methodLimit=32), max item ~16.3m
  • Linux TestBuild: 514 work items (methodLimit=16), max item ~15.9m

Because the Windows Helix pool is critical-path bound (276 agents, most running 1 item each), the larger shards made the longest work item the bottleneck. Fixing this should reduce the Windows Helix wall-clock by ~5-8 minutes.

Fix

Parse the environment variable as a boolean instead of checking for non-empty. This ensures:

  • TestBuild jobs (all platforms): methodLimit=16
  • FullFramework job (TestFullMSBuild=true): methodLimit=32 (unchanged)

The AssemblyScheduler methodLimit was using string.IsNullOrEmpty to check
the TestFullMSBuild environment variable. On Windows TestBuild jobs, the
pipeline YAML sets TestFullMSBuild to 'false' (a non-empty string), which
caused the check to use methodLimit=32 instead of the intended 16. On
Linux, the variable is not set at all, correctly resulting in methodLimit=16.

This meant Windows TestBuild produced ~329 Helix work items while Linux
produced ~514 for the same test assemblies, making Windows critical-path
bound on its longest ~16m work item.

Fix by properly parsing the env var as a boolean so both platforms
consistently use methodLimit=16 for TestBuild, and 32 only for the
FullFramework job where TestFullMSBuild is genuinely 'true'.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings April 20, 2026 16:25

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.

Pull request overview

This PR fixes Helix test sharding behavior in the custom MSBuild task that creates xUnit Helix work items by correctly interpreting the TestFullMSBuild environment variable as a boolean flag (instead of “non-empty string”).

Changes:

  • Determine isFullMSBuild by checking whether TestFullMSBuild equals "true" (case-insensitive).
  • Use that boolean to select the AssemblyScheduler methodLimit (32 for full MSBuild, otherwise 16), restoring intended cross-OS symmetry for TestBuild jobs.

@MichaelSimons
MichaelSimons merged commit e252a9b into dotnet:main Apr 21, 2026
29 checks passed
@MichaelSimons
MichaelSimons deleted the fix/helix-method-limit-parsing branch April 21, 2026 14:39
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