From 7f6fb152cb68b30c4d38b9f69298eb6aec96278a Mon Sep 17 00:00:00 2001
From: Florian Fischer <florian.fischer@muhq.space>
Date: Sat, 22 Jan 2022 12:27:25 +0100
Subject: [PATCH] [meson] add option to ignore wakeup hints

I think wakeup hints should never be ignored but having the option
seams usefull to observe their benefits/cost.
---
 emper/Emper.hpp                                    | 8 ++++++++
 emper/strategies/AbstractWorkStealingScheduler.cpp | 5 +++++
 meson.build                                        | 1 +
 meson_options.txt                                  | 6 ++++++
 4 files changed, 20 insertions(+)

diff --git a/emper/Emper.hpp b/emper/Emper.hpp
index bffad3df..668660c8 100644
--- a/emper/Emper.hpp
+++ b/emper/Emper.hpp
@@ -61,6 +61,14 @@ enum class WorkerWakeupStrategy {
 static const enum WorkerWakeupStrategy WORKER_WAKEUP_STRATEGY =
 		WorkerWakeupStrategy::EMPER_WORKER_WAKEUP_STRATEGY;
 
+static const bool WORKER_IGNORE_WAKEUP_HINT =
+#ifdef EMPER_WORKER_IGNORE_WAKEUP_HINT
+		true
+#else
+		false
+#endif
+		;
+
 static const bool LIBURCU =
 #ifdef EMPER_LIBURCU
 		true
diff --git a/emper/strategies/AbstractWorkStealingScheduler.cpp b/emper/strategies/AbstractWorkStealingScheduler.cpp
index 028dd892..2814a417 100644
--- a/emper/strategies/AbstractWorkStealingScheduler.cpp
+++ b/emper/strategies/AbstractWorkStealingScheduler.cpp
@@ -184,6 +184,10 @@ popBottom:
 
 	auto* const currentWorker = Worker::getCurrentWorker();
 
+	if constexpr (emper::WORKER_IGNORE_WAKEUP_HINT) {
+		goto work_stealing;
+	}
+
 	// Try dispatch hint possibly set by the sleep strategy
 	if (currentWorker->dispatchHint) {
 		const emper::FiberHint dispatchHint = currentWorker->dispatchHint;
@@ -214,6 +218,7 @@ popBottom:
 		}
 	}
 
+work_stealing:
 	// Go into work stealing
 	// TODO: Determine if there is a better value than 1/3.
 	const float CHECK_ANYWHERE_QUEUE_AT_PERCENTAGE = 0.33;
diff --git a/meson.build b/meson.build
index 80b1df3f..71cb6c4a 100644
--- a/meson.build
+++ b/meson.build
@@ -49,6 +49,7 @@ endif
 
 conf_data.set('EMPER_WORKER_SLEEP', get_option('worker_sleep'))
 conf_data.set('EMPER_WORKER_WAKEUP_STRATEGY', get_option('worker_wakeup_strategy'))
+conf_data.set('EMPER_WORKER_IGNORE_WAKEUP_HINT', get_option('worker_ignore_wakeup_hint'))
 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'))
diff --git a/meson_options.txt b/meson_options.txt
index 115a5e55..1b54e3de 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -65,6 +65,12 @@ option(
   value: 'posix',
   description: 'Semaphore implementation to suspend/wakeup workers',
 )
+option(
+  'worker_ignore_wakeup_hint',
+  type: 'boolean',
+  description: 'Should possibly passed hints where to find new work be ignored',
+  value: false,
+)
 option(
   'locked_ws_queue',
   type: 'boolean',
-- 
GitLab