Merge pull request #378 from benaadams/thread-count
Network thread count defaults
This commit is contained in:
commit
b8f01cf674
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
||||||
{
|
{
|
||||||
public class ThreadCountTests
|
public class ThreadCountTests
|
||||||
{
|
{
|
||||||
[Theory(Skip = "https://github.com/aspnet/KestrelHttpServer/issues/232"), MemberData(nameof(OneToTen))]
|
|
||||||
public async Task ZeroToTenThreads(int threadCount)
|
public async Task ZeroToTenThreads(int threadCount)
|
||||||
{
|
{
|
||||||
var config = new ConfigurationBuilder()
|
var config = new ConfigurationBuilder()
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
||||||
_logger = engine.Log;
|
_logger = engine.Log;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Waiting for adding support for multi loop in libuv")]
|
|
||||||
public void InitAndCloseServerPipe()
|
public void InitAndCloseServerPipe()
|
||||||
{
|
{
|
||||||
var loop = new UvLoopHandle(_logger);
|
var loop = new UvLoopHandle(_logger);
|
||||||
|
|
@ -39,7 +38,6 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "Waiting for adding support for multi loop in libuv")]
|
|
||||||
public void ServerPipeListenForConnections()
|
public void ServerPipeListenForConnections()
|
||||||
{
|
{
|
||||||
var loop = new UvLoopHandle(_logger);
|
var loop = new UvLoopHandle(_logger);
|
||||||
|
|
@ -112,7 +110,6 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Fact(Skip = "Waiting for adding support for multi loop in libuv")]
|
|
||||||
public void ServerPipeDispatchConnections()
|
public void ServerPipeDispatchConnections()
|
||||||
{
|
{
|
||||||
var pipeName = @"\\.\pipe\ServerPipeDispatchConnections" + Guid.NewGuid().ToString("n");
|
var pipeName = @"\\.\pipe\ServerPipeDispatchConnections" + Guid.NewGuid().ToString("n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue