Skip to content
Snippets Groups Projects
Commit e244acd7 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'laws-simple-actor-test-timeout' into 'master'

[LAWS] Attempt to steal from all other workers instead of just one

Closes #6

See merge request i4/manycore/emper!66
parents 196e2b5e 41446763
No related branches found
No related tags found
No related merge requests found
......@@ -94,24 +94,29 @@ auto LawsScheduler::nextFiber() -> Fiber* {
return fiber;
}
// TODO: The code below is nearly duplicated, besides the statsk
// part, in WsScheduler, deduplicate.
const workerid_t myWorkerId = Runtime::getWorkerId();
const workerid_t workerCount = runtime.getWorkerCount();
workerid_t startWorkerId = Runtime::rand() % workerCount;
// TODO: See how reducing the loop bound affects things.
for (workerid_t i = 0; i < workerCount; ++i) {
workerid_t victim = (startWorkerId + i) % workerCount;
if (unlikely(startWorkerId == Runtime::getWorkerId())) startWorkerId++;
workerid_t victim = startWorkerId % workerCount;
// Don't steal from ourselves.
if (unlikely(victim == myWorkerId)) continue;
poped = queues[victim]->popTop(&fiber);
if (poped) {
if constexpr (emper::STATS) {
auto flag = static_cast<unsigned int>(LawsStrategy::FiberSource::stolen);
fiber->setFlag(flag);
}
poped = queues[victim]->popTop(&fiber);
if (poped) {
if constexpr (emper::STATS) {
auto flag = static_cast<unsigned int>(LawsStrategy::FiberSource::stolen);
fiber->setFlag(flag);
}
return fiber;
return fiber;
}
}
// TODO: Reduce pressure on mainThreadQueue by only checking every N-th time.
// Try the "scheduled from anywhere" queue to get work as last resort.
fiber = dequeFiberFromAnywhereQueue();
if (fiber) {
......
......@@ -54,6 +54,8 @@ auto WsScheduler::nextFiber() -> Fiber* {
return fiber;
}
// TODO: The code below is nearly duplicated, besides the stats
// part, in LawsScheduler, deduplicate.
const workerid_t myWorkerId = Runtime::getWorkerId();
const workerid_t workerCount = runtime.getWorkerCount();
workerid_t startWorkerId = Runtime::rand() % workerCount;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment