diff --git a/emper/Emper.hpp b/emper/Emper.hpp index aae699525a2e3b77520e83ba1a4ecad7f3ae092e..3fb17133be9e6005e35c926f2ef5c364d4e0e9b7 100644 --- a/emper/Emper.hpp +++ b/emper/Emper.hpp @@ -78,6 +78,14 @@ static const bool OVERFLOW_QUEUE = #endif ; +static const bool CHECK_ANYWHERE_QUEUE_WHILE_STEALING = +#ifdef EMPER_CHECK_ANYWHERE_QUEUE_WHILE_STEALING + true +#else + false +#endif + ; + auto getFullVersion() -> std::string; static const bool BLOCKED_CONTEXT_SET = diff --git a/emper/strategies/AbstractWorkStealingScheduler.cpp b/emper/strategies/AbstractWorkStealingScheduler.cpp index 09fc49b89ca4a5fc6aac13e524a9ffb0d05851ee..891295d41c9ee700d18bcbcc7531ed7089a323c0 100644 --- a/emper/strategies/AbstractWorkStealingScheduler.cpp +++ b/emper/strategies/AbstractWorkStealingScheduler.cpp @@ -67,7 +67,7 @@ auto AbstractWorkStealingScheduler::maybeRecycle(Fiber* fiber) -> bool { auto AbstractWorkStealingScheduler::nextFiberViaAnywhereQueue() -> std::optional<std::pair<Fiber*, FiberSource>> { const size_t KEEP_FREE_SLOTS = 64; - const size_t DEQUEUE_FROM_ANYWHERE_MAX = 128; + const size_t DEQUEUE_FROM_ANYWHERE_MAX = 512; const uintptr_t remainingCapacityLocalWsQueue = queue.freeSlots(); size_t maxFiberCount; @@ -206,6 +206,8 @@ popBottom: auto stolenFiber = tryStealFiberFrom(victim); if (stolenFiber) return *stolenFiber; + if constexpr (!emper::CHECK_ANYWHERE_QUEUE_WHILE_STEALING) continue; + // If we failed to steal from a certain number of victims, check // the anywhere queue for new fibers. if (i == checkAnywhereQueueAt) { diff --git a/meson.build b/meson.build index 1256b288d8b3350db70bafc13826ddacfeca5ce6..52f6063fd6a84b964f1014b5f31b8eeb095ab50c 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,7 @@ conf_data.set('EMPER_WORKER_WAKEUP_STRATEGY', get_option('worker_wakeup_strategy conf_data.set('EMPER_LOCKED_WS_QUEUE', get_option('locked_ws_queue')) conf_data.set('EMPER_LOCKED_MPSC_QUEUE', get_option('locked_mpsc_queue')) conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue')) +conf_data.set('EMPER_CHECK_ANYWHERE_QUEUE_WHILE_STEALING', get_option('check_anywhere_queue_while_stealing')) conf_data.set('EMPER_STATS', get_option('stats')) conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue')) conf_data.set('EMPER_BLOCKED_CONTEXT_SET', get_option('blocked_context_set')) diff --git a/meson_options.txt b/meson_options.txt index 1a719c0e279865439e58c101403e199edca6c0f4..a9fb626603202da68b2f324bb9119fc690edc3a4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -98,6 +98,12 @@ option( value: true, description: 'Use an overflow queue in case scheduling queues become full', ) +option( + 'check_anywhere_queue_while_stealing', + type: 'boolean', + value: true, + description: 'Check the anywhere queue after some failed stealed attempts', +) option( 'io', type: 'boolean',