[*] Limit kThreadIdAny dequeues until one until we can preempt the work queues of threads within our local group

This commit is contained in:
Reece Wilson 2024-04-10 07:39:11 +01:00
parent a087595009
commit 13ddd42961
3 changed files with 12 additions and 9 deletions

View File

@ -66,20 +66,25 @@ namespace Aurora::Async
#endif
}
void GroupWorkQueue::Dequeue(AuList<WorkEntry_t> &queue, int maxPopCount, AuAsync::ThreadId_t id)
void GroupWorkQueue::Dequeue(AuList<WorkEntry_t> &queue,
AuUInt uMaxPopCount,
AuAsync::ThreadId_t id)
{
AU_LOCK_GUARD(this->mutex);
AuUInt uAnyCount {};
for (AU_ITERATE_N(i, AuAsync::kEWorkPriorityCount))
{
auto &group = this->sortedWork[(int)AuAsync::kEWorkPriorityMaxLegal - i];
for (auto itr = group.begin(); ((itr != group.end()) && (queue.size() < maxPopCount)); )
for (auto itr = group.begin(); ((itr != group.end()) && (queue.size() < uMaxPopCount)); )
{
if (itr->first == Async::kThreadIdAny)
if ((!uAnyCount) &&
(itr->first == Async::kThreadIdAny))
{
queue.push_back(*itr);
itr = group.erase(itr);
uAnyCount++;
continue;
}

View File

@ -26,6 +26,6 @@ namespace Aurora::Async
void AddWorkEntry(WorkEntry_t entry);
void Dequeue(AuList<WorkEntry_t> &queue, int maxPopCount, AuAsync::ThreadId_t idd);
void Dequeue(AuList<WorkEntry_t> &queue, AuUInt uMaxPopCount, AuAsync::ThreadId_t idd);
};
}

View File

@ -308,7 +308,9 @@ namespace Aurora::Async
do
{
group->workQueue.Dequeue(state->pendingWorkItems, state->stackState.uWorkMultipopCount, state->thread.id.second);
group->workQueue.Dequeue(state->pendingWorkItems,
state->stackState.uWorkMultipopCount,
state->thread.id.second);
state->sync.UpdateCVState(state.get());
@ -394,8 +396,6 @@ namespace Aurora::Async
// in the first task (or deeper)
if (InRunnerMode() && state->stackState.uStackCallDepth) // are we one call deep?
{
auto queue = ToKernelWorkQueue();
if ((this->uAtomicCounter == state->stackState.uStackCallDepth) &&
this->IsDepleted())
{
@ -459,8 +459,6 @@ namespace Aurora::Async
// in the top most task
if (InRunnerMode())
{
auto queue = ToKernelWorkQueue();
if ((runningTasks == 0) &&
(this->uAtomicCounter == 0) &&
this->IsDepleted())