Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ public class Build : IntegrationTestBase
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext testContext)
{
// Increase the ThreadPool minimum threads to avoid starvation during parallel test
// execution. Each test class spawns vstest.console and testhost processes — the async
// process management and I/O redirection callbacks need ThreadPool threads to complete
// promptly.
var additionalThreadsCount = System.Environment.ProcessorCount * 4;
System.Threading.ThreadPool.GetMinThreads(out var workerThreads, out var completionPortThreads);
System.Threading.ThreadPool.SetMinThreads(workerThreads + additionalThreadsCount, completionPortThreads + additionalThreadsCount);

IntegrationTestBuild.BuildTestAssetsForIntegrationTests(testContext);
}
}
8 changes: 8 additions & 0 deletions test/Microsoft.TestPlatform.Library.IntegrationTests/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ public class Build : IntegrationTestBase
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext testContext)
{
// Increase the ThreadPool minimum threads to avoid starvation during parallel test
// execution. Each test class spawns vstest.console and testhost processes via the
// TranslationLayer — the socket-based communication blocks ThreadPool threads during
// connection setup, causing starvation with the default MinThreads.
var additionalThreadsCount = System.Environment.ProcessorCount * 4;
System.Threading.ThreadPool.GetMinThreads(out var workerThreads, out var completionPortThreads);
System.Threading.ThreadPool.SetMinThreads(workerThreads + additionalThreadsCount, completionPortThreads + additionalThreadsCount);

IntegrationTestBuild.BuildTestAssetsForIntegrationTests(testContext);
}
}
Loading