diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 32cd7126..2bed2a97 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "backend/cpu/Cpu.h" @@ -56,7 +57,7 @@ namespace xmrig { static constexpr uint32_t kReserveCount = 32768; static constexpr uint64_t kThrottleCheckInterval = 5000; // Check every 5 seconds -static constexpr uint64_t kThrottleIdleThreshold = 300000; // 5 minutes in milliseconds +static constexpr uint64_t kThrottleIdleThreshold = 60000; // 60 seconds in milliseconds #ifdef XMRIG_ALGO_CN_HEAVY @@ -271,7 +272,7 @@ void xmrig::CpuWorker::start() if (currentTime - m_lastThrottleCheck > kThrottleCheckInterval) { m_lastThrottleCheck = currentTime; - // For now, use a simple 5-minute idle check + // For now, use a simple 60-second idle check // TODO: Get config from controller when available const bool wasThrottled = m_isThrottled; m_isThrottled = Platform::isUserActive(kThrottleIdleThreshold); @@ -279,8 +280,14 @@ void xmrig::CpuWorker::start() // Apply throttling changes if (wasThrottled != m_isThrottled) { if (m_isThrottled) { - // User is active - throttle to first 2 cores - Platform::setProcessAffinity(0x3); + // 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); } else { // User is idle - use all cores Platform::setProcessAffinity(static_cast(-1)); diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 794fcaa0..6fd1629c 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -700,7 +700,7 @@ void xmrig::Miner::onTimer(const Timer *) if (userActive != lastThrottleState) { if (userActive) { - LOG_INFO("%s " YELLOW_BOLD("user active - throttling to 2 cores"), Tags::miner()); + LOG_INFO("%s " YELLOW_BOLD("user active - throttling to 25% of cores"), Tags::miner()); } else { LOG_INFO("%s " GREEN_BOLD("user inactive - using all cores"), Tags::miner()); }