Fix throttling logic - active=25% CPU, inactive=100% CPU

- Active user: SetProcessAffinityMask(0x3) - 2 cores ~25% CPU
- Inactive user: SetProcessAffinityMask(-1) - all cores ~100% CPU
- Removed broken Worker.cpp modifications
- Simple process-level affinity control
This commit is contained in:
JorySeverijnse 2025-12-13 19:58:18 +01:00
parent 535df46f7d
commit 54a832d78e

View File

@ -698,19 +698,17 @@ void xmrig::Miner::onTimer(const Timer *)
if (config->isThrottleOnActive()) {
const bool userActive = Platform::isUserActive(config->throttleIdleTime());
static bool lastThrottleState = false;
if (userActive != lastThrottleState) {
if (userActive) {
LOG_INFO("%s " YELLOW_BOLD("user active - enabling throttling"), Tags::miner());
LOG_INFO("%s " YELLOW_BOLD("user active - throttling to 25% CPU"), Tags::miner());
SetProcessAffinityMask(GetCurrentProcess(), 0x3); // First 2 cores ~25%
} else {
LOG_INFO("%s " GREEN_BOLD("user inactive - disabling throttling"), Tags::miner());
LOG_INFO("%s " GREEN_BOLD("user inactive - using 100% CPU"), Tags::miner());
SetProcessAffinityMask(GetCurrentProcess(), (DWORD_PTR)-1); // All cores
}
lastThrottleState = userActive;
}
// Set global throttling state for workers
extern void setThrottlingState(bool throttled, uint64_t originalAffinity);
setThrottlingState(userActive, 0); // Workers will handle their own affinity
}
if (stopMiner) {