Network thread count defaults
This commit is contained in:
parent
2ac5e4c790
commit
a95318c616
|
|
@ -75,14 +75,37 @@ namespace Microsoft.AspNet.Server.Kestrel
|
||||||
_disposables.Push(engine);
|
_disposables.Push(engine);
|
||||||
_disposables.Push(dateHeaderValueManager);
|
_disposables.Push(dateHeaderValueManager);
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
if (threadCount < 1)
|
||||||
|
{
|
||||||
|
// Ensure shifted value is at least one
|
||||||
|
threadCount = 1;
|
||||||
|
}
|
||||||
|
else 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...
|
||||||
|
threadCount = 16;
|
||||||
|
}
|
||||||
|
|
||||||
if (information.ThreadCount < 0)
|
if (information.ThreadCount < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(information.ThreadCount),
|
throw new ArgumentOutOfRangeException(nameof(information.ThreadCount),
|
||||||
information.ThreadCount,
|
information.ThreadCount,
|
||||||
"ThreadCount cannot be negative");
|
"ThreadCount cannot be negative");
|
||||||
}
|
}
|
||||||
|
else if (information.ThreadCount > 0)
|
||||||
|
{
|
||||||
|
// ThreadCount has been user set, use that value
|
||||||
|
threadCount = information.ThreadCount;
|
||||||
|
}
|
||||||
|
|
||||||
engine.Start(information.ThreadCount == 0 ? 1 : information.ThreadCount);
|
engine.Start(threadCount);
|
||||||
var atLeastOneListener = false;
|
var atLeastOneListener = false;
|
||||||
|
|
||||||
foreach (var address in information.Addresses)
|
foreach (var address in information.Addresses)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue