Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Increase workerThreads and completionPortThreads defaults for Helios #94
The default values for the thread pool seem really low under Helios. I personally get
An ASP.NET Web Forms app running IIS Express on the same machine comes with far higher default values:
You should consider increasing these values to get rid of these weird exceptions:
In the meantime, manually calling
changed the title
Increase workerThreads and completionPortThreads defaults
Jul 9, 2014
I've been running into the "There were not enough free threads in the ThreadPool to complete the operation" error a lot on a project at work.
This is likely the culprit:
Is there a recommendation for how to calculate those two values until a fix lands?
@crdeutsch you can simply add
If you find these values a bit high, you can also limit the worker threads to
// When webengine4.dll first starts, it sets the max thread pool size to an artificially low number, and it depends // on System.Web.dll to set it back. Since we're replacing System.Web.dll, we need to perform this fixup manually. // For now we'll use 100 * numCPUs. int newLimits = 100 * Environment.ProcessorCount; // this is actually # cores (including hyperthreaded cores) int existingMaxWorkerThreads; int existingMaxIocpThreads; ThreadPool.GetMaxThreads(out existingMaxWorkerThreads, out existingMaxIocpThreads); ThreadPool.SetMaxThreads(Math.Max(newLimits, existingMaxWorkerThreads), Math.Max(newLimits, existingMaxIocpThreads));