18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-03 06:35:21 +01:00

perf(utilities): the worker pool reads the core count once

worker_pool::capacity() called std::thread::hardware_concurrency() each time, and every job asks for it,
several times a frame. On Windows that call asks the system for the processor layout
(GetLogicalProcessorInformationEx) each time: 0.39% of the main thread on Tomaszewo. The count is read
once now; the machine doesn't change its cores while the simulator runs.
This commit is contained in:
jerrrrycho
2026-12-02 07:04:31 +01:00
parent fdbf54ba15
commit 4038f186d6
+4 -1
View File
@@ -34,7 +34,10 @@ std::size_t worker_pool::capacity()
{
return 1;
}
return std::max<std::size_t>(1, std::thread::hardware_concurrency());
// read once: the count asks the system for the processors of the machine (GetLogicalProcessorInformationEx on Windows),
// and the pool is asked for it by every job, several times a frame
static std::size_t const cores{std::max<std::size_t>(1, std::thread::hardware_concurrency())};
return cores;
}
void worker_pool::grow(std::size_t const Workers)