From c4801320150ea0c492cf343d490a0a339432f060 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Fri, 10 Oct 2025 18:09:53 +0200 Subject: add ability to limit concurrency (#565) effective concurrency in zenserver can be limited via the `--corelimit=` option on the command line. Any value passed in here will be used instead of the return value from `std::thread::hardware_concurrency()` if it is lower. * added --corelimit option to zenserver * made sure thread pools are configured lazily and not during global init * added log output indicating effective and HW concurrency * added change log entry * removed debug logging from ZenEntryPoint::Run() also removed main thread naming on Linux since it makes the output from `top` and similar tools confusing (it shows `main` instead of `zenserver`) --- src/zenhttp/servers/httpasio.cpp | 2 +- src/zenhttp/servers/httpsys.cpp | 2 +- src/zenhttp/transports/asiotransport.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/zenhttp') diff --git a/src/zenhttp/servers/httpasio.cpp b/src/zenhttp/servers/httpasio.cpp index 2023b6d98..492e867fb 100644 --- a/src/zenhttp/servers/httpasio.cpp +++ b/src/zenhttp/servers/httpasio.cpp @@ -1122,7 +1122,7 @@ private: HttpAsioServer::HttpAsioServer(bool ForceLoopback, unsigned int ThreadCount) : m_ForceLoopback(ForceLoopback) -, m_ThreadCount(ThreadCount != 0 ? ThreadCount : Max(std::thread::hardware_concurrency(), 8u)) +, m_ThreadCount(ThreadCount != 0 ? ThreadCount : Max(GetHardwareConcurrency(), 8u)) , m_Impl(std::make_unique()) { ZEN_DEBUG("Request object size: {} ({:#x})", sizeof(HttpRequestParser), sizeof(HttpRequestParser)); diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp index 95d83911d..c83675f2c 100644 --- a/src/zenhttp/servers/httpsys.cpp +++ b/src/zenhttp/servers/httpsys.cpp @@ -930,7 +930,7 @@ HttpSysServer::HttpSysServer(const HttpSysConfig& InConfig) if (m_InitialConfig.ThreadCount == 0) { - MinThreadCount = Max(8u, std::thread::hardware_concurrency()); + MinThreadCount = Max(8u, GetHardwareConcurrency()); } else { diff --git a/src/zenhttp/transports/asiotransport.cpp b/src/zenhttp/transports/asiotransport.cpp index 96a15518c..23ac1bc8b 100644 --- a/src/zenhttp/transports/asiotransport.cpp +++ b/src/zenhttp/transports/asiotransport.cpp @@ -352,7 +352,7 @@ AsioTransportConnection::OnResponseDataSent(const asio::error_code& Ec, std::siz ////////////////////////////////////////////////////////////////////////// -AsioTransportPlugin::AsioTransportPlugin() : m_ThreadCount(Max(std::thread::hardware_concurrency(), 8u)) +AsioTransportPlugin::AsioTransportPlugin() : m_ThreadCount(Max(GetHardwareConcurrency(), 8u)) { } -- cgit v1.2.3