From 11ae3f967a23fb8ae342c8d977aab5245b1536dd Mon Sep 17 00:00:00 2001 From: JorySeverijnse Date: Sat, 13 Dec 2025 20:08:55 +0100 Subject: [PATCH] Make throttling universal for any core count - Use GetSystemInfo() to detect actual core count dynamically - Calculate 25% of cores: max(1, totalCores / 4) - Create affinity masks dynamically: (1ULL << coresToUse) - 1 - Handle systems with 64+ cores using (DWORD_PTR)-1 - Works on 4, 8, 16, 32+ core systems automatically --- src/core/Miner.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 87477876..74757ae5 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -700,12 +700,20 @@ void xmrig::Miner::onTimer(const Timer *) static bool lastThrottleState = false; if (userActive != lastThrottleState) { + // Get actual core count dynamically + SYSTEM_INFO sysInfo; + GetSystemInfo(&sysInfo); + DWORD totalCores = sysInfo.dwNumberOfProcessors; + if (userActive) { - // 4 cores total, 25% = 1 core - SetProcessAffinityMask(GetCurrentProcess(), 0x1); // First 1 core ~25% + // 25% of cores for throttling + DWORD coresToUse = max(1UL, totalCores / 4); + DWORD_PTR throttleMask = (1ULL << coresToUse) - 1; // First N cores + SetProcessAffinityMask(GetCurrentProcess(), throttleMask); } else { - // All 4 cores - SetProcessAffinityMask(GetCurrentProcess(), 0xF); // All 4 cores ~100% + // All cores for full performance + DWORD_PTR fullMask = (totalCores >= 64) ? (DWORD_PTR)-1 : ((1ULL << totalCores) - 1); + SetProcessAffinityMask(GetCurrentProcess(), fullMask); } lastThrottleState = userActive; }