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
Branches
Tags
No related merge requests found
...@@ -94,24 +94,29 @@ auto LawsScheduler::nextFiber() -> Fiber* { ...@@ -94,24 +94,29 @@ auto LawsScheduler::nextFiber() -> Fiber* {
return 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(); const workerid_t workerCount = runtime.getWorkerCount();
workerid_t startWorkerId = Runtime::rand() % workerCount; 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++; // Don't steal from ourselves.
workerid_t victim = startWorkerId % workerCount; if (unlikely(victim == myWorkerId)) continue;
poped = queues[victim]->popTop(&fiber); poped = queues[victim]->popTop(&fiber);
if (poped) { if (poped) {
if constexpr (emper::STATS) { if constexpr (emper::STATS) {
auto flag = static_cast<unsigned int>(LawsStrategy::FiberSource::stolen); auto flag = static_cast<unsigned int>(LawsStrategy::FiberSource::stolen);
fiber->setFlag(flag); 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. // Try the "scheduled from anywhere" queue to get work as last resort.
fiber = dequeFiberFromAnywhereQueue(); fiber = dequeFiberFromAnywhereQueue();
if (fiber) { if (fiber) {
......
...@@ -54,6 +54,8 @@ auto WsScheduler::nextFiber() -> Fiber* { ...@@ -54,6 +54,8 @@ auto WsScheduler::nextFiber() -> Fiber* {
return 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 myWorkerId = Runtime::getWorkerId();
const workerid_t workerCount = runtime.getWorkerCount(); const workerid_t workerCount = runtime.getWorkerCount();
workerid_t startWorkerId = Runtime::rand() % workerCount; workerid_t startWorkerId = Runtime::rand() % workerCount;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment