From 5f9c1bd885ddb949223db8e878b3344f1c2ce87f Mon Sep 17 00:00:00 2001 From: JorySeverijnse Date: Sat, 13 Dec 2025 18:18:57 +0100 Subject: [PATCH] Fix throttling to use timing-based approach instead of affinity - Remove process affinity changes that weren't working - Use 100ms sleep to achieve ~25% CPU usage when active - Simplify throttling logic to be more reliable - Keep 60-second idle threshold and 5-second check interval --- src/backend/cpu/CpuWorker.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 2bed2a97..9cd2292b 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -280,24 +280,19 @@ void xmrig::CpuWorker::start() // Apply throttling changes if (wasThrottled != m_isThrottled) { if (m_isThrottled) { - // User is active - throttle to 25% of total cores - const uint32_t totalCores = Cpu::info()->threads(); - const uint32_t coresToUse = std::max(1u, totalCores / 4); - uint64_t affinityMask = 0; - for (uint32_t i = 0; i < coresToUse; ++i) { - affinityMask |= (1ULL << i); - } - Platform::setProcessAffinity(affinityMask); + // User is active - set throttling flag + // No affinity changes needed, we'll use timing-based throttling } else { - // User is idle - use all cores - Platform::setProcessAffinity(static_cast(-1)); + // User is idle - clear throttling flag } } } - // Add sleep when throttled + // Apply timing-based throttling when user is active + // This reduces effective hashrate to ~25% by adding delays if (m_isThrottled) { - std::this_thread::sleep_for(std::chrono::milliseconds(800)); + // Sleep for 75% of the time to achieve ~25% CPU usage + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } const Job &job = m_job.currentJob();