Limit Parallel.ForEach concurrency in SourcelinkTests#5373
Conversation
The VerifySourcelinks test launches hundreds of dotnet-sourcelink processes simultaneously with no concurrency limit. Under resource contention, some processes exceed the 60-second timeout in ExecuteHelper, get killed, and report false failures — the tool writes 'validated' to stdout but gets killed before exiting cleanly with exit code 0. Bound concurrency to Environment.ProcessorCount to prevent resource contention that causes timeout-driven false failures. Fixes #5259 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces flakiness in SourcelinkTests.VerifySourcelinks by bounding the number of concurrent dotnet-sourcelink process launches, preventing excessive resource contention that can trigger the existing 60-second per-process timeout and cause false failures.
Changes:
- Add
ParallelOptionswithMaxDegreeOfParallelism = Environment.ProcessorCountto theParallel.ForEachused for PDB validation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Failure is due to #5391 |
I don't think this is necessarily true, we should've still got a message in the log about the process being killed due to timeout: #5259 (comment) but it's possible this still helps or fixes the issue. |
Fix
The
VerifySourcelinkstest launches hundreds ofdotnet-sourcelinkprocesses simultaneously viaParallel.ForEachwith no concurrency limit. Under resource contention, some processes exceed the 60-second timeout inExecuteHelper.ExecuteProcess, get killed, and report false failures — the tool writes "validated" to stdout but gets killed before it can exit cleanly with code 0.Root Cause Analysis (from #5259 (comment))
Parallel.ForEachlaunchesdotnet-sourcelink test --offlinefor every PDB — potentially hundreds simultaneouslymillisecondTimeout: 60000)failedFilesChange
Add
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }to bound concurrent process launches to the number of CPU cores.Fixes #5259