[dotnet] Raise ThreadPool min threads to avoid Kestrel stalls#7085
Merged
Conversation
Contributor
|
|
There was a problem hiding this comment.
Pull request overview
This PR aims to eliminate intermittent .NET integration test flakes caused by Kestrel response flush delays while the .NET ThreadPool ramps up under tracer/AppSec/IAST load, by forcing higher minimum ThreadPool worker and I/O completion thread counts in the Docker images used for these scenarios.
Changes:
- Set
DOTNET_ThreadPool_ForceMinWorkerThreads=32in the .NET Docker runtime images used by the tests. - Set the I/O completion thread minimum via a
DOTNET_ThreadPool_ForceMin*CompletionThreadsenvironment variable in the same images.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| utils/build/docker/dotnet/uds.Dockerfile | Adds ThreadPool minimum thread environment variables to reduce Kestrel stalls in UDS scenario images. |
| utils/build/docker/dotnet/poc.Dockerfile | Adds ThreadPool minimum thread environment variables to reduce Kestrel stalls in PoC scenario images. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Motivation
Test_SqlServiceNameSourceintermittently fails inINTEGRATIONS(~2% of runs indd-trace-dotnetmaster). Root cause: Kestrel response-flush stalls for ~5 s while the .NET ThreadPool grows — the request completes server-side in ~12 ms, but bytes don't reach the client until after the test's 5 s read timeout.The ThreadPool defaults its minimum to
Environment.ProcessorCountfor both worker and IOCP threads (so 2–4 onubuntu-latest), and grows by 1 thread every ~500 ms. Under cumulative tracer + AppSec + IAST background load in this scenario, Kestrel's I/O queues behind tracer activity until the pool grows — long enough to trip the client timeout.Changes
Set
DOTNET_ThreadPool_ForceMinWorkerThreads=32andDOTNET_ThreadPool_ForceMinIoCompletionThreads=32inpoc.Dockerfileanduds.Dockerfile. 32 is a comfortable floor above the burst; idle threads cost ~1 MB each, and on hosts with ≥32 vCPU the env vars are a no-op.Verification
2 CI runs × 50 INTEGRATIONS attempts = 100 fresh scenario runs, 0 stalls (prior baseline ≈ 2 / 100). Diagnostic branch
diag/dotnet-rasp-sqli-stallkept in case the flake reappears.