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

Merge branch 'configurable_io_completer' into 'master'

[IO] make the behavior of the completer thread configurable

See merge request !143
parents bc899a38 5ea44519
No related branches found
No related tags found
No related merge requests found
......@@ -97,4 +97,13 @@ static const bool IO_URING_SHARED_WQ =
false
#endif
;
enum class IoCompleterBehavior {
schedule,
wakeup,
none,
};
static const enum IoCompleterBehavior IO_COMPLETER_BEHAVIOR =
IoCompleterBehavior::EMPER_IO_COMPLETER_BEHAVIOR;
} // namespace emper
......@@ -92,7 +92,9 @@ Runtime::Runtime(workerid_t workerCount, RuntimeStrategyFactory& strategyFactory
// for each worker's IoContext one eventfd read is prepared before the
// globalCompleter is started and submits all previously prepared sqes.
globalIo = new GlobalIoContext(*this, workerCount);
globalIo->startGlobalCompleter();
if constexpr (emper::IO_COMPLETER_BEHAVIOR != emper::IoCompleterBehavior::none) {
globalIo->startGlobalCompleter();
}
if constexpr (emper::STATS) {
globalIo->stats.workerId = -1;
......@@ -196,8 +198,10 @@ auto Runtime::workerLoop(Worker* worker) -> void* {
if constexpr (emper::IO) {
auto* workerIo = new IoContext(*this);
// submit the workers' CQ eventfds to the global IoContext
globalIo->registerWorkerIo(*workerIo);
if constexpr (emper::IO_COMPLETER_BEHAVIOR != emper::IoCompleterBehavior::none) {
// submit the workers' CQ eventfds to the global IoContext
globalIo->registerWorkerIo(*workerIo);
}
// notify the globalCompleter that we have registered our eventfd
ioReadySem.notify();
......
......@@ -14,6 +14,7 @@
#include "CallerEnvironment.hpp"
#include "Common.hpp"
#include "Emper.hpp"
#include "Runtime.hpp"
#include "io/Future.hpp"
#include "io/IoContext.hpp"
......@@ -82,7 +83,7 @@ auto GlobalIoContext::globalCompleterFunc(void* arg) -> void* {
// -> there are completions on this worker IoContext
switch (tag) {
// clang-11 does not support [[likely]] yet
// TODO: remove the preprocessor check if clang ass [[likely]] support
// TODO: remove the preprocessor check if clang has [[likely]] support
#if defined __has_attribute
#if __has_attribute(likely)
[[likely]] // NOLINT(clang-diagnostic-unknown-attributes)
......@@ -103,7 +104,13 @@ auto GlobalIoContext::globalCompleterFunc(void* arg) -> void* {
assert(submitted == 1);
worker_io->reapAndScheduleCompletions<CallerEnvironment::ANYWHERE>();
if constexpr (emper::IO_COMPLETER_BEHAVIOR == emper::IoCompleterBehavior::wakeup) {
// Only wakeup sleeping workers and hope that the worker which
// has ready cqes will reap them soon.
globalIoContext->runtime.wakeupSleepingWorkers<CallerEnvironment::ANYWHERE>();
} else {
worker_io->reapAndScheduleCompletions<CallerEnvironment::ANYWHERE>();
}
}
break;
......
......@@ -93,6 +93,16 @@ endforeach
io_cq_lock_impl = get_option('io_cq_lock_implementation')
conf_data.set('EMPER_IO_CQ_LOCK_' + io_cq_lock_impl.to_upper(), true)
io_completer_behavior = get_option('io_completer_behavior')
if io_completer_behavior == 'maybe_wakeup'
if get_option('worker_sleep')
io_completer_behavior = 'wakeup'
else
io_completer_behavior = 'none'
endif
endif
conf_data.set('EMPER_IO_COMPLETER_BEHAVIOR', io_completer_behavior)
subdir('emper')
subdir('tests')
subdir('apps')
......
......@@ -122,3 +122,10 @@ option(
choices: ['spin_lock', 'counting_try_lock', 'mutex'],
value: 'counting_try_lock',
)
option(
'io_completer_behavior',
type: 'combo',
description: 'The behaviour of the IO completer thread',
choices: ['schedule', 'maybe_wakeup'],
value: 'schedule',
)
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