Skip to content
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

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

kouvel
Copy link
Member

@kouvel kouvel commented Jul 19, 2024

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.

@kouvel kouvel added this to the 9.0.0 milestone Jul 19, 2024
@kouvel kouvel requested review from eduardo-vp and mangod9 July 19, 2024 13:44
@kouvel kouvel self-assigned this Jul 19, 2024
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Comment on lines +44 to +55
#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
Copy link
Member Author

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.

Copy link
Member

@eduardo-vp eduardo-vp left a 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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants