Skip to content

Limit MaxDegreeOfParallelism in RoslynParallel#80963

Merged
333fred merged 2 commits intodotnet:mainfrom
chiangvincent:dev/chiangvincent/parallellimit
Oct 31, 2025
Merged

Limit MaxDegreeOfParallelism in RoslynParallel#80963
333fred merged 2 commits intodotnet:mainfrom
chiangvincent:dev/chiangvincent/parallellimit

Conversation

@chiangvincent
Copy link
Contributor

@chiangvincent chiangvincent commented Oct 30, 2025

Description

This bug was found by Agent Kean, the VS PerfRel AI Agent. Please review this PR with extra care! For more information, visit our wiki. Please share feedback with TIP Insights

  • Issue: RoslynParallel.For calls Parallel.For with ParallelOptions that do not set MaxDegreeOfParallelism, permitting unbounded concurrency and contributing to high CPU via runaway thread pool usage.
  • Issue type: Rule 1 — DO NOT call Parallel.For/Parallel.ForEach/Parallel.Invoke without specifying ParallelOptions.MaxDegreeOfParallelism.
  • Proposed fix: Set MaxDegreeOfParallelism = Environment.ProcessorCount in both DefaultParallelOptions and the cancellation-aware ParallelOptions used by RoslynParallel.For. This is a small, single-file change in a leaf-frame method present in the call stack.

Best Practices Wiki
See related failure in PRISM
ADO work item

@chiangvincent chiangvincent requested a review from a team as a code owner October 30, 2025 16:45
@dotnet-policy-service dotnet-policy-service bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Oct 30, 2025
@333fred
Copy link
Member

333fred commented Oct 31, 2025

@dotnet/roslyn-compiler for a second review

@RikkiGibson
Copy link
Member

CI failure looks weird:

##[error](NETCORE_ENGINEERING_TELEMETRY=Test) Tests failed
PublicAccessNotPermittedPublic access is not permitted on this storage account.
RequestId:743eaea9-101e-005f-28f5-49ec70000000
Time:2025-10-30T23:34:38.8609499Z
System.Net.WebException: The remote server returned an error: (409) Conflict.
   at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
   at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
at Ensure-ProcDump, D:\a\_work\1\s\eng\build.ps1: line 660
at TestUsingRunTests, D:\a\_work\1\s\eng\build.ps1: line 449
at <ScriptBlock>, D:\a\_work\1\s\eng\build.ps1: line 780
at <ScriptBlock>, D:\a\_work\_temp\fd46ff11-732c-48c5-8cf9-818bd9b63d11.ps1: line 4
at <ScriptBlock>, <No file>: line 1

We'll see how it goes on re-run

@chiangvincent
Copy link
Contributor Author

Thanks @RikkiGibson and @333fred for the reviews -- looks like the CI is failing since there's a storage account permissions issue on the unit test suite. Tried requeuing but running into a Cannot read properties of undefined (reading 'replace') error. Could you guys requeue again, thanks!

Failing build run

image

@chiangvincent

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants