diff --git a/Common/Thread/ThreadManager.cpp b/Common/Thread/ThreadManager.cpp index acfcab7040..428f7ff438 100644 --- a/Common/Thread/ThreadManager.cpp +++ b/Common/Thread/ThreadManager.cpp @@ -207,14 +207,14 @@ void ThreadManager::Init(int numRealCores, int numLogicalCoresPerCpu) { Teardown(); } - numComputeThreads_ = numRealCores * numLogicalCoresPerCpu; + numComputeThreads_ = std::min(32, numRealCores * numLogicalCoresPerCpu); // Double it for the IO blocking threads. - int numThreads = numComputeThreads_ + std::max(MIN_IO_BLOCKING_THREADS, numComputeThreads_); - numThreads_ = numThreads; + const int numIOThreads = std::min(32, std::max(MIN_IO_BLOCKING_THREADS, numComputeThreads_) * 2); + numThreads_ = numComputeThreads_ + numIOThreads; INFO_LOG(Log::System, "ThreadManager::Init(compute threads: %d, all: %d)", numComputeThreads_, numThreads_); - for (int i = 0; i < numThreads; i++) { + for (int i = 0; i < numThreads_; i++) { TaskThreadContext *thread = new TaskThreadContext(); thread->cancelled.store(false); thread->type = i < numComputeThreads_ ? TaskType::CPU_COMPUTE : TaskType::IO_BLOCKING;