Add thread names

This commit is contained in:
Robbert van der Helm
2021-06-06 23:45:47 +02:00
parent fe7f6eff96
commit a7496fae77
11 changed files with 41 additions and 3 deletions
+9 -1
View File
@@ -103,7 +103,11 @@ GroupBridge::GroupBridge(boost::filesystem::path group_socket_path)
logger.async_log_pipe_lines(stderr_redirect.pipe, stderr_buffer,
"[STDERR] ");
stdio_handler = Win32Thread([&]() { stdio_context.run(); });
stdio_handler = Win32Thread([&]() {
pthread_setname_np(pthread_self(), "group-stdio");
stdio_context.run();
});
}
GroupBridge::~GroupBridge() noexcept {
@@ -238,6 +242,10 @@ void GroupBridge::accept_requests() {
const size_t plugin_id = next_plugin_id.fetch_add(1);
active_plugins[plugin_id] = std::pair(
Win32Thread([this, plugin_id, plugin_ptr = bridge.get()]() {
const std::string thread_name =
"worker-" + std::to_string(plugin_id);
pthread_setname_np(pthread_self(), thread_name.c_str());
handle_plugin_run(plugin_id, plugin_ptr);
}),
std::move(bridge));
+2
View File
@@ -221,6 +221,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
parameters_handler = Win32Thread([&]() {
set_realtime_priority(true);
pthread_setname_np(pthread_self(), "parameters");
sockets.host_vst_parameters.receive_multi<Parameter>(
[&](Parameter& request, SerializationBufferBase& buffer) {
@@ -246,6 +247,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
process_replacing_handler = Win32Thread([&]() {
set_realtime_priority(true);
pthread_setname_np(pthread_self(), "audio");
// Most plugins will already enable FTZ, but there are a handful of
// plugins that don't that suffer from extreme DSP load increases when
+7
View File
@@ -1183,6 +1183,13 @@ size_t Vst3Bridge::register_object_instance(
.audio_processor_handler = Win32Thread([&, instance_id]() {
set_realtime_priority(true);
// XXX: Like with VST2 worker threads, when using plugin groups the
// thread names from different plugins will clash. Not a huge
// deal probably, since duplicate thread names are still more
// useful than no thread names.
const std::string thread_name = "audio-" + std::to_string(instance_id);
pthread_setname_np(pthread_self(), thread_name.c_str());
sockets.add_audio_processor_and_listen(
instance_id, socket_listening_latch,
overload{
+2
View File
@@ -117,6 +117,8 @@ __cdecl
// potentially unsafe events that should always be run from the UI thread
// will be posted to `main_context`.
Win32Thread worker_thread([&]() {
pthread_setname_np(pthread_self(), "worker");
bridge->run();
// // When the sockets get closed, this application should
+5 -1
View File
@@ -86,7 +86,11 @@ MainContext::MainContext()
// we'll run the timer on a 30 second interval.
async_handle_watchdog_timer(5s);
watchdog_handler = Win32Thread([&]() { watchdog_context.run(); });
watchdog_handler = Win32Thread([&]() {
pthread_setname_np(pthread_self(), "watchdog");
watchdog_context.run();
});
}
void MainContext::run() {