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

Merge branch 'completer-thread-priority' into 'master'

[GlobalIoContext] Add CompleterSchedParam option

See merge request !236
parents 829b9529 c0cf0f8d
No related branches found
No related tags found
1 merge request!236[GlobalIoContext] Add CompleterSchedParam option
Pipeline #67136 passed
......@@ -163,4 +163,15 @@ static const bool HAS_FS_PATH =
#endif
;
enum class CompleterSchedParam {
unchanged,
normal,
nice_10,
nice_19,
idle,
};
static const CompleterSchedParam COMPLETER_SCHED_PARAM =
CompleterSchedParam::EMPER_IO_COMPLETER_SCHED_PARAM;
} // namespace emper
......@@ -4,6 +4,7 @@
#include <liburing.h>
#include <liburing/io_uring.h>
#include <sched.h>
#include <unistd.h>
#include <cassert>
......@@ -193,6 +194,34 @@ void GlobalIoContext::startCompleter() {
if (unlikely(errno)) {
DIE_MSG_ERRNO("Creating completer thread failed");
}
int sched_priority = 0, sched_policy;
switch (emper::COMPLETER_SCHED_PARAM) {
case CompleterSchedParam::unchanged:
return;
case CompleterSchedParam::normal:
sched_policy = SCHED_OTHER;
break;
case CompleterSchedParam::nice_10:
sched_policy = SCHED_OTHER;
sched_priority = 10;
break;
case CompleterSchedParam::nice_19:
sched_policy = SCHED_OTHER;
sched_priority = 19;
break;
case CompleterSchedParam::idle:
sched_policy = SCHED_IDLE;
break;
}
const struct sched_param param = {sched_priority};
errno = pthread_setschedparam(completer, sched_policy, &param);
if (unlikely(errno)) {
DIE_MSG_ERRNO("Setting scheduler parameter on completer thread failed");
}
}
void GlobalIoContext::initiateTermination() {
......
......@@ -5,6 +5,7 @@
{ include: ["<bits/cxxabi_forced.h>", "private", "<ctime>", "public" ] },
{ include: ["<bits/this_thread_sleep.h>", "private", "<thread>", "public" ] },
{ include: ["<ext/alloc_traits.h>", "private", "<memory>", "public" ] },
{ include: ["<bits/types/struct_sched_param.h>", "private", "<sched.h>", "public" ] },
{ symbol: ["__kernel_timespec", "private", "<liburing.h>", "public" ] },
{ symbol: ["std::filesystem", "private", "<filesystem>", "public" ] },
......
......@@ -42,6 +42,7 @@ 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'))
conf_data.set('EMPER_SET_AFFINITY_ON_BLOCK', get_option('set_affinity_on_block'))
conf_data.set('EMPER_IO_COMPLETER_SCHED_PARAM', get_option('io_completer_sched_param'))
semaphore_impl = get_option('wakeup_semaphore_implementation')
conf_data.set('EMPER_' + semaphore_impl.to_upper() + '_WAKEUP_SEMAPHORE', true)
......
......@@ -160,3 +160,10 @@ option(
value: false,
description: 'Set the affinity when blocking',
)
option(
'io_completer_sched_param',
type: 'combo',
description: 'The scheduling parmaters used for the completer thread',
choices: ['unchanged', 'normal', 'nice_10', 'nice_19', 'idle'],
value: 'unchanged',
)
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