-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Need Threadpool minThreads config setting #4819
Comments
@benaadams is this blocking Kestrel? @schellap, can you take a look? |
@piotrpMSFT depends, might block how users use Kestrel - if that's not too enigmatic 😁 @halter73 is probably better to comment on it. |
Not kestrel, it's server scenarios in general. |
Can you try specifying this as a workaround?
See ThreadPool_* here: @gkhanna79, the configuration knobs for CoreCLR need to be exposed by the corhost interface or through the PropertyKeys/PropertyValues to coreclr_initialize. Is someone working on this? Or is the host or the user supposed to set this as an env variable for own process? Cc @ericeil |
@schellap yep that works used
For 1024 of synchronous blocking type connections and it worked happily |
@gkhanna79 a config or api approach would be better than environment as its more likely to travel well with the component that has the constraint - whereas environment var feels like it needs to rely on good documentation/process and it being followed well. If I had to choose only one, config would probably be best; as it can be retro-actively be applied to a deployed app - without recompilation to include the increased threadpool count. (in a something's gone wrong in production panic moment) |
If exposing this setting via runtime config file works for ASP.NET then I would prefer to go with this approach. @kouvel, could you please take a closer look at this and see if there are any problems with exposing this option in the hosting APIs? |
In general, the trouble with SetMinThreads is that it depends on the underlying thread pool having a notion of "min threads" in the first place, which not all do. Which thread pool are we using in CoreRT? Maybe this would be fine as a config option as long as it was clear that it was configuring the CLR thread pool, and has no effect if a different thread pool is being used (i.e., if the runtime is not CoreCLR). |
For CoreRT we would have a separate set of nativeOptions and for CoreCLR runtimeOptions in the runtime.config.json. |
@kouvel, hopefully we can pass on other CLRConfigValues too (ints and strings) than the current startup flags approach for bool values ex: server_gc. |
Yea it should be fine to pass ints and strings as well. I'll take a look. |
Are the characteristics of these threadpools known? Will they be subject to jamming issues when too many interdependent things are blocked and their unblockers queued? |
CC @ericeil I just want to bring this up again. Why not add the APIs SetMinThreads and SetMaxThreads? My thoughts:
So, it seems to me like a fair piece of configuration to support for any thread pool. |
Also, not sure if this is done already, but perhaps the thread pool could be improved to track which of its scheduled threads are in a wait state and schedule new threads more quickly, to keep the CPU as busy as possible. When threads go out of the wait state, there may be more threads than is ideal, which are all CPU-bound, but as a heuristic it may work better than scheduling one thread per second. If all scheduled threads are not in a wait state and are long-running, I guess it would be a choice whether to start new threads to release waiting work items (perhaps one per second, or some other heuristic) or to block pending work items until a thread becomes available. |
MinThreads and MaxThreads are now exposed in the app config, see https://github.com/dotnet/cli/blob/rel/1.0.0/Documentation/specs/runtime-configuration-file.md and https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/clr-configuration-knobs.md. |
ThreadPool.SetMinThreads
doesn't exist as an api in coreclr and apparently its available and the responsibility of the hosting model https://github.com/dotnet/coreclr/issues/1606#issuecomment-144126757So this should be exposed via a config to the dotnet cli
The text was updated successfully, but these errors were encountered: