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:
@@ -85,29 +85,26 @@ should_rebalance(const ThreadData* threadData)
|
|||||||
if (threadLoad >= coreLoad / 2)
|
if (threadLoad >= coreLoad / 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int32 coreNewLoad = coreLoad - threadLoad;
|
// Get the least loaded core.
|
||||||
|
|
||||||
ReadSpinLocker coreLocker(gCoreHeapsLock);
|
ReadSpinLocker coreLocker(gCoreHeapsLock);
|
||||||
CoreEntry* other = gCoreLoadHeap.PeekMinimum();
|
CoreEntry* other = gCoreLoadHeap.PeekMinimum();
|
||||||
if (other == NULL)
|
if (other == NULL)
|
||||||
other = gCoreHighLoadHeap.PeekMinimum();
|
other = gCoreHighLoadHeap.PeekMinimum();
|
||||||
coreLocker.Unlock();
|
coreLocker.Unlock();
|
||||||
|
|
||||||
ASSERT(other != NULL);
|
ASSERT(other != NULL);
|
||||||
int32 otherNewLoad = other->GetLoad() + threadLoad;
|
|
||||||
|
|
||||||
// If there is high load on this core but this thread does not contribute
|
if (other == threadData->Core())
|
||||||
// significantly consider giving it to someone less busy.
|
return false;
|
||||||
if (coreLoad > kHighLoad) {
|
|
||||||
if (coreNewLoad - otherNewLoad >= kLoadDifference)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No cpu bound threads - the situation is quite good. Make sure it
|
// If there are idle cores give them some work unless that will cause
|
||||||
// won't get much worse...
|
// the current core to become idle.
|
||||||
|
int32 coreNewLoad = coreLoad - threadLoad;
|
||||||
if (other->GetLoad() == 0 && coreNewLoad != 0)
|
if (other->GetLoad() == 0 && coreNewLoad != 0)
|
||||||
return true;
|
return true;
|
||||||
return coreNewLoad - otherNewLoad >= kLoadDifference * 2;
|
|
||||||
|
// Attempt to keep load balanced.
|
||||||
|
int32 otherNewLoad = other->GetLoad() + threadLoad;
|
||||||
|
return coreNewLoad - otherNewLoad >= kLoadDifference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user