-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a thread pool config var on Windows for choosing the number of IOCPs #105145
Conversation
Tagging subscribers to this area: @mangod9 |
#if TARGET_WINDOWS | ||
// Continuations of IO completions are dispatched to the ThreadPool from IO completion poller threads. This avoids | ||
// continuations blocking/stalling the IO completion poller threads. Setting UnsafeInlineIOCompletionCallbacks allows | ||
// continuations to run directly on the IO completion poller thread, but is inherently unsafe due to the potential for | ||
// those threads to become stalled due to blocking. Sometimes, setting this config value may yield better latency. The | ||
// config value is named for consistency with SocketAsyncEngine.Unix.cs. | ||
private static readonly bool UnsafeInlineIOCompletionCallbacks = | ||
Environment.GetEnvironmentVariable("DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS") == "1"; | ||
|
||
private static readonly short IOCompletionPortCount = DetermineIOCompletionPortCount(); | ||
private static readonly int IOCompletionPollerCount = DetermineIOCompletionPollerCount(); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are now used by the constructor, which runs when ThreadPoolInstance
is being initialized, so they need to be initialized before ThreadPoolInstance
to have the correct values, moved them here to ensure that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There were cases where using more than one IOCP was beneficial along with some other changes. Being able to configure the number would be useful for folks to do further testing without having to use private binaries.
There were cases where using more than one IOCP was beneficial along with some other changes. Being able to configure the number would be useful for folks to do further testing without having to use private binaries.