Made ThreadCount configurable
This commit is contained in:
parent
75cfe2c3bb
commit
b6b8ea3c38
|
|
@ -42,23 +42,28 @@ namespace Microsoft.AspNet.Server.Kestrel
|
|||
|
||||
private static int GetThreadCount(IConfiguration configuration)
|
||||
{
|
||||
// Actual core count would be a better number
|
||||
// rather than logical cores which includes hyper-threaded cores.
|
||||
// Divide by 2 for hyper-threading, and good defaults (still need threads to do webserving).
|
||||
// Can be user overriden using IKestrelServerInformation.ThreadCount
|
||||
var threadCount = Environment.ProcessorCount >> 1;
|
||||
var threadCountString = configuration["server.threadCount"];
|
||||
|
||||
if (threadCount < 1)
|
||||
int threadCount;
|
||||
if (string.IsNullOrEmpty(threadCountString) || !int.TryParse(threadCountString, out threadCount))
|
||||
{
|
||||
// Ensure shifted value is at least one
|
||||
return 1;
|
||||
}
|
||||
// Actual core count would be a better number
|
||||
// rather than logical cores which includes hyper-threaded cores.
|
||||
// Divide by 2 for hyper-threading, and good defaults (still need threads to do webserving).
|
||||
threadCount = Environment.ProcessorCount >> 1;
|
||||
|
||||
if (threadCount > 16)
|
||||
{
|
||||
// Receive Side Scaling RSS Processor count currently maxes out at 16
|
||||
// would be better to check the NIC's current hardware queues; but xplat...
|
||||
return 16;
|
||||
if (threadCount < 1)
|
||||
{
|
||||
// Ensure shifted value is at least one
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (threadCount > 16)
|
||||
{
|
||||
// Receive Side Scaling RSS Processor count currently maxes out at 16
|
||||
// would be better to check the NIC's current hardware queues; but xplat...
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
return threadCount;
|
||||
|
|
|
|||
Loading…
Reference in New Issue