From 1edbf4059eed9b377e373e3277b1ff05e46ab6b6 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Tue, 14 Jul 2026 20:34:14 -0400 Subject: [PATCH] common: limit max number of threads to hardware limit --- common/util/SimpleThreadGroup.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/util/SimpleThreadGroup.cpp b/common/util/SimpleThreadGroup.cpp index aea1917a4d..bdb8c95bec 100644 --- a/common/util/SimpleThreadGroup.cpp +++ b/common/util/SimpleThreadGroup.cpp @@ -10,6 +10,8 @@ void SimpleThreadGroup::run(const std::function& func, int num_runs) void SimpleThreadGroup::run(const std::function& func, int num_runs, int num_workers) { ASSERT(m_joined); + num_workers = std::min(num_workers, (int)std::thread::hardware_concurrency()); + // copy the function, in case the user gives us a temporary function. m_func = func; @@ -39,4 +41,4 @@ void SimpleThreadGroup::join() { } m_threads.clear(); m_joined = true; -} \ No newline at end of file +}