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
This commit is contained in:
parent
af4c763d9a
commit
5f9c1bd885
@ -280,24 +280,19 @@ void xmrig::CpuWorker<N>::start()
|
|||||||
// Apply throttling changes
|
// Apply throttling changes
|
||||||
if (wasThrottled != m_isThrottled) {
|
if (wasThrottled != m_isThrottled) {
|
||||||
if (m_isThrottled) {
|
if (m_isThrottled) {
|
||||||
// User is active - throttle to 25% of total cores
|
// User is active - set throttling flag
|
||||||
const uint32_t totalCores = Cpu::info()->threads();
|
// No affinity changes needed, we'll use timing-based throttling
|
||||||
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 {
|
} else {
|
||||||
// User is idle - use all cores
|
// User is idle - clear throttling flag
|
||||||
Platform::setProcessAffinity(static_cast<uint64_t>(-1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add sleep when throttled
|
// Apply timing-based throttling when user is active
|
||||||
|
// This reduces effective hashrate to ~25% by adding delays
|
||||||
if (m_isThrottled) {
|
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();
|
const Job &job = m_job.currentJob();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user