From 2c579aae62c8aabb7ebf6ee2cd867479f4ac538c Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Sat, 7 Jul 2018 07:31:10 +0200 Subject: [PATCH] Use a default ThreadCount that wont cause the number of threads to be a bottleneck. (#59) --- README.md | 2 +- .../TransportOptions.cs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bfb3ed4..d9fc6a7 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,6 @@ The Transport has these options: - **DeferSend**: This defers sends to the Transport Thread which increases chances for multiple sends to coalesce. This options defaults to true. -- **ThreadCount**: Specifies the number of Transport Threads. This defaults to the number of logical processors in the system divided by 4. +- **ThreadCount**: Specifies the number of Transport Threads. This defaults to the number of logical processors in the system, maxed to 16. - **AioSend/AioReceive**: Uses Linux AIO system calls to batch send and receive calls. AioSend implies DeferSend. These options default to true. diff --git a/src/RedHatX.AspNetCore.Server.Kestrel.Transport.Linux/TransportOptions.cs b/src/RedHatX.AspNetCore.Server.Kestrel.Transport.Linux/TransportOptions.cs index dc9eaa7..fed354c 100644 --- a/src/RedHatX.AspNetCore.Server.Kestrel.Transport.Linux/TransportOptions.cs +++ b/src/RedHatX.AspNetCore.Server.Kestrel.Transport.Linux/TransportOptions.cs @@ -20,11 +20,10 @@ public LinuxTransportOptions() AioSend = true; AioReceive = true; - // Benchmarking Techempower Json on 24-core machine with hyper threading (ProcessorCount = 48) - // shows best performance at ThreadCount 12. - // TODO: what happens if hyperthreading is disabled? Perhaps this should be half the cores? - // TODO: benchmark more scenarios to validate this is a good default. - ThreadCount = Math.Max((Environment.ProcessorCount + 2) / 4, 1); + // Use a default ThreadCount that wont cause the number of threads + // to be a bottleneck. + // Users that want to optimize, should do their own benchmarks. + ThreadCount = Math.Min(Environment.ProcessorCount, 16); } internal bool ReceiveOnIncomingCpu