scheduler/low_latency: Try harder to balance load

In low latency mode the scheduler would not attempt to balance load
on not heavily loaded cores unless difference in load exceeded
kLoadDifference * 2 (i.e. 40 percentage points), which does not seem
to be good enough.
This commit is contained in:
Pawel Dziepak
2014-03-09 19:58:11 +01:00
parent a57a7a8c6d
commit 0012ba6a87
+10 -13
View File
@@ -85,29 +85,26 @@ should_rebalance(const ThreadData* threadData)
if (threadLoad >= coreLoad / 2)
return false;
int32 coreNewLoad = coreLoad - threadLoad;
// Get the least loaded core.
ReadSpinLocker coreLocker(gCoreHeapsLock);
CoreEntry* other = gCoreLoadHeap.PeekMinimum();
if (other == NULL)
other = gCoreHighLoadHeap.PeekMinimum();
coreLocker.Unlock();
ASSERT(other != NULL);
int32 otherNewLoad = other->GetLoad() + threadLoad;
// If there is high load on this core but this thread does not contribute
// significantly consider giving it to someone less busy.
if (coreLoad > kHighLoad) {
if (coreNewLoad - otherNewLoad >= kLoadDifference)
return true;
}
if (other == threadData->Core())
return false;
// No cpu bound threads - the situation is quite good. Make sure it
// won't get much worse...
// If there are idle cores give them some work unless that will cause
// the current core to become idle.
int32 coreNewLoad = coreLoad - threadLoad;
if (other->GetLoad() == 0 && coreNewLoad != 0)
return true;
return coreNewLoad - otherNewLoad >= kLoadDifference * 2;
// Attempt to keep load balanced.
int32 otherNewLoad = other->GetLoad() + threadLoad;
return coreNewLoad - otherNewLoad >= kLoadDifference;
}