From 85f4423c3d0263b02ac9e3b73ed35ca8dac55c8a Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Thu, 21 Mar 2024 13:07:24 +0000 Subject: [PATCH] maint: Remove use of folly/system/ThreadName.h (#1446) #### Reference Issues/PRs Fixes one item of the folly replacement plan, issue #1412. #### What does this implement or fix? This removes use of `folly/system/ThreadName.h`. It was used in two places to obtain a `std::string` name of a thread, and here is replaced with conversion of unique thread ID to a string using `fmt` via ```c++ fmt::format("{}", arcticdb::get_thread_id()) ``` #### Any other comments? This is used in two places, the first in the termination handler in `python_module.cpp` which I have manually tested. The second use is in the [Remotery](https://github.com/Celtoys/Remotery) which, as far as I can tell, is not tested in CI so I am not sure of the status of the Remotery support. Signed-off-by: Ian Thomas --- cpp/arcticdb/entity/performance_tracing.cpp | 4 ++-- cpp/arcticdb/python/python_module.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/arcticdb/entity/performance_tracing.cpp b/cpp/arcticdb/entity/performance_tracing.cpp index 5d16bb8d16..c2587820a2 100644 --- a/cpp/arcticdb/entity/performance_tracing.cpp +++ b/cpp/arcticdb/entity/performance_tracing.cpp @@ -8,9 +8,9 @@ #include #include -#include #include #include +#include std::shared_ptr RemoteryInstance::instance(){ std::call_once(RemoteryInstance::init_flag_, &RemoteryInstance::init); @@ -63,7 +63,7 @@ namespace arcticdb::detail { std::unordered_map fqn_by_task_name_; std::string thread_name_; - ThreadNameCache():fqn_by_task_name_(),thread_name_(folly::getCurrentThreadName().value_or("Thread")){} + ThreadNameCache():fqn_by_task_name_(),thread_name_(fmt::format("{}", arcticdb::get_thread_id())){} std::string_view get_thread_name(const char * task_name){ if(auto fqn_it = fqn_by_task_name_.find(task_name); fqn_it != fqn_by_task_name_.end()){ diff --git a/cpp/arcticdb/python/python_module.cpp b/cpp/arcticdb/python/python_module.cpp index a4686d6661..cb8be77a8d 100644 --- a/cpp/arcticdb/python/python_module.cpp +++ b/cpp/arcticdb/python/python_module.cpp @@ -28,9 +28,9 @@ #include #include #include +#include #include -#include #include #include @@ -174,7 +174,7 @@ void register_termination_handler() { std::rethrow_exception(eptr); } catch (const std::exception &e) { arcticdb::log::root().error("Terminate called in thread {}: {}\n Aborting", - folly::getCurrentThreadName().value_or("Unknown"), e.what()); + arcticdb::get_thread_id(), e.what()); std::abort(); } });