diff --git a/emper/strategies/AbstractWorkStealingScheduler.cpp b/emper/strategies/AbstractWorkStealingScheduler.cpp index 8e2bd3fd773c33a8ce1cbab62cba735e7925aaf4..e354a12688c05703954052e84a8b1571a70b0338 100644 --- a/emper/strategies/AbstractWorkStealingScheduler.cpp +++ b/emper/strategies/AbstractWorkStealingScheduler.cpp @@ -131,8 +131,13 @@ popBottom: } { + // TODO: Determine if there is a better value than 1/3. + const float CHECK_ANYWHERE_QUEUE_AT_PERCENTAGE = 0.33; const workerid_t myWorkerId = Runtime::getWorkerId(); const workerid_t workerCount = runtime.getWorkerCount(); + // NOLINTNEXTLINE(bugprone-narrowing-conversions) + const workerid_t checkAnywhereQueueAt = workerCount * CHECK_ANYWHERE_QUEUE_AT_PERCENTAGE; + workerid_t startWorkerId = Runtime::rand() % workerCount; // TODO: See how reducing the loop bound affects things. for (workerid_t i = 0; i < workerCount; ++i) { @@ -151,6 +156,13 @@ popBottom: fiberSource = FiberSource::stolen; goto out; } + + // If we failed to steal from a certain number of victims, check + // the anywhere queue for new fibers. + if (i == checkAnywhereQueueAt) { + auto anywhereQueueFiber = nextFiberViaAnywhereQueue(); + if (anywhereQueueFiber) return *anywhereQueueFiber; + } } }