This is an automated email from the ASF dual-hosted git repository.
gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 4e4f3613a6d [opt](cloud) Set thread name for all background thread
workers to improve observability (#49366)
4e4f3613a6d is described below
commit 4e4f3613a6deeb6b73a147696dfb1ad08f1b45fd
Author: Gavin Chou <[email protected]>
AuthorDate: Tue Apr 29 23:59:24 2025 +0800
[opt](cloud) Set thread name for all background thread workers to improve
observability (#49366)
---
cloud/src/common/metric.cpp | 1 +
cloud/src/common/simple_thread_pool.h | 10 +++++++++-
cloud/src/main.cpp | 1 +
cloud/src/meta-service/meta_server.cpp | 1 +
cloud/src/meta-service/txn_kv.cpp | 1 +
cloud/src/meta-service/txn_lazy_committer.cpp | 5 +++--
cloud/src/recycler/recycler.cpp | 14 ++++++++------
cloud/src/recycler/recycler_service.cpp | 1 +
cloud/src/recycler/s3_accessor.cpp | 3 ++-
9 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/cloud/src/common/metric.cpp b/cloud/src/common/metric.cpp
index 9f796cd3f49..2425ae0e48b 100644
--- a/cloud/src/common/metric.cpp
+++ b/cloud/src/common/metric.cpp
@@ -259,6 +259,7 @@ int FdbMetricExporter::start() {
[this]() { return
!running_.load(std::memory_order_acquire); });
}
});
+ pthread_setname_np(thread_->native_handle(), "fdb_metrics_exporter");
return 0;
}
diff --git a/cloud/src/common/simple_thread_pool.h
b/cloud/src/common/simple_thread_pool.h
index 37a4cedbdad..0e3b472346a 100644
--- a/cloud/src/common/simple_thread_pool.h
+++ b/cloud/src/common/simple_thread_pool.h
@@ -17,11 +17,14 @@
#pragma once
+#include <pthread.h>
+
#include <atomic>
#include <condition_variable>
#include <iostream>
#include <memory>
#include <mutex>
+#include <string>
#include <thread>
#include <vector>
@@ -38,9 +41,11 @@ private:
std::vector<std::thread> _worker_thread_group; // multi thread pool
std::atomic<bool> _is_running;
size_t _pool_size;
+ std::string _pool_name;
public:
- SimpleThreadPool(size_t size) : _is_running(false), _pool_size(size) {
+ SimpleThreadPool(size_t size, const std::string& name = "")
+ : _is_running(false), _pool_size(size), _pool_name(name) {
_job_queue = std::make_shared<SimpleSyncQueue<JobType>>(_pool_size *
2);
}
@@ -86,8 +91,11 @@ public:
int start() {
_is_running = true;
_worker_thread_group.clear();
+ _pool_name = _pool_name.empty() ? "simple_thread_pool" : _pool_name;
for (size_t i = 0; i < _pool_size; ++i) {
_worker_thread_group.emplace_back(&SimpleThreadPool::work, this);
+ std::string name = _pool_name + "_" + std::to_string(i);
+ pthread_setname_np(_worker_thread_group.back().native_handle(),
name.c_str());
}
return 0;
}
diff --git a/cloud/src/main.cpp b/cloud/src/main.cpp
index bb1c2c3441c..9115158743f 100644
--- a/cloud/src/main.cpp
+++ b/cloud/src/main.cpp
@@ -310,6 +310,7 @@ int main(int argc, char** argv) {
}
};
periodiccally_log_thread = std::thread {periodiccally_log};
+ pthread_setname_np(periodiccally_log_thread.native_handle(),
"recycler_periodically_log");
}
// start service
brpc::ServerOptions options;
diff --git a/cloud/src/meta-service/meta_server.cpp
b/cloud/src/meta-service/meta_server.cpp
index 47b688d6dad..4762c55d812 100644
--- a/cloud/src/meta-service/meta_server.cpp
+++ b/cloud/src/meta-service/meta_server.cpp
@@ -176,6 +176,7 @@
MetaServerRegister::MetaServerRegister(std::shared_ptr<TxnKv> txn_kv)
}
LOG(INFO) << "register thread quits";
}));
+ pthread_setname_np(register_thread_->native_handle(),
"ms_register_thread");
}
MetaServerRegister::~MetaServerRegister() {
diff --git a/cloud/src/meta-service/txn_kv.cpp
b/cloud/src/meta-service/txn_kv.cpp
index 89781c68649..a328538ed78 100644
--- a/cloud/src/meta-service/txn_kv.cpp
+++ b/cloud/src/meta-service/txn_kv.cpp
@@ -259,6 +259,7 @@ int Network::init() {
bool expected = true;
Network::working.compare_exchange_strong(expected, false);
});
+ pthread_setname_np(network_thread_->native_handle(), "fdb_network_thread");
return 0;
}
diff --git a/cloud/src/meta-service/txn_lazy_committer.cpp
b/cloud/src/meta-service/txn_lazy_committer.cpp
index 9859c2b0ed1..2260ea1ff23 100644
--- a/cloud/src/meta-service/txn_lazy_committer.cpp
+++ b/cloud/src/meta-service/txn_lazy_committer.cpp
@@ -499,7 +499,8 @@ std::pair<MetaServiceCode, std::string>
TxnLazyCommitTask::wait() {
}
TxnLazyCommitter::TxnLazyCommitter(std::shared_ptr<TxnKv> txn_kv) :
txn_kv_(txn_kv) {
- worker_pool_ =
std::make_unique<SimpleThreadPool>(config::txn_lazy_commit_num_threads);
+ worker_pool_ =
std::make_unique<SimpleThreadPool>(config::txn_lazy_commit_num_threads,
+ "txn_lazy_commiter");
worker_pool_->start();
}
@@ -541,4 +542,4 @@ void TxnLazyCommitter::remove(int64_t txn_id) {
running_tasks_.erase(txn_id);
}
-} // namespace doris::cloud
\ No newline at end of file
+} // namespace doris::cloud
diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp
index 6f11455ce00..a074e3dc667 100644
--- a/cloud/src/recycler/recycler.cpp
+++ b/cloud/src/recycler/recycler.cpp
@@ -174,12 +174,14 @@ static inline void check_recycle_task(const std::string&
instance_id, const std:
Recycler::Recycler(std::shared_ptr<TxnKv> txn_kv) : txn_kv_(std::move(txn_kv))
{
ip_port_ = std::string(butil::my_ip_cstr()) + ":" +
std::to_string(config::brpc_listen_port);
- auto s3_producer_pool =
std::make_shared<SimpleThreadPool>(config::recycle_pool_parallelism);
+ auto s3_producer_pool =
std::make_shared<SimpleThreadPool>(config::recycle_pool_parallelism,
+
"s3_producer_pool");
s3_producer_pool->start();
- auto recycle_tablet_pool =
std::make_shared<SimpleThreadPool>(config::recycle_pool_parallelism);
+ auto recycle_tablet_pool =
std::make_shared<SimpleThreadPool>(config::recycle_pool_parallelism,
+
"recycle_tablet_pool");
recycle_tablet_pool->start();
- auto group_recycle_function_pool =
-
std::make_shared<SimpleThreadPool>(config::recycle_pool_parallelism);
+ auto group_recycle_function_pool = std::make_shared<SimpleThreadPool>(
+ config::recycle_pool_parallelism, "group_recycle_function_pool");
group_recycle_function_pool->start();
_thread_pool_group =
RecyclerThreadPoolGroup(std::move(s3_producer_pool),
std::move(recycle_tablet_pool),
@@ -1927,8 +1929,8 @@ int InstanceRecycler::recycle_rowsets() {
// Store keys of rowset recycled by background workers
std::mutex async_recycled_rowset_keys_mutex;
std::vector<std::string> async_recycled_rowset_keys;
- auto worker_pool =
-
std::make_unique<SimpleThreadPool>(config::instance_recycler_worker_pool_size);
+ auto worker_pool = std::make_unique<SimpleThreadPool>(
+ config::instance_recycler_worker_pool_size, "recycle_rowsets");
worker_pool->start();
auto delete_rowset_data_by_prefix = [&](std::string key, const
std::string& resource_id,
int64_t tablet_id, const
std::string& rowset_id) {
diff --git a/cloud/src/recycler/recycler_service.cpp
b/cloud/src/recycler/recycler_service.cpp
index 08e937a4106..8f3a736671c 100644
--- a/cloud/src/recycler/recycler_service.cpp
+++ b/cloud/src/recycler/recycler_service.cpp
@@ -208,6 +208,7 @@ void recycle_copy_jobs(const std::shared_ptr<TxnKv>&
txn_kv, const std::string&
std::lock_guard lock(s_worker_mtx);
s_worker.erase(instance_id);
});
+ pthread_setname_np(worker.native_handle(), "recycler_worker");
worker.detach();
}
diff --git a/cloud/src/recycler/s3_accessor.cpp
b/cloud/src/recycler/s3_accessor.cpp
index b206dc62651..9d365cffa04 100644
--- a/cloud/src/recycler/s3_accessor.cpp
+++ b/cloud/src/recycler/s3_accessor.cpp
@@ -240,7 +240,8 @@ int S3Accessor::init() {
static std::once_flag log_annotated_tags_key_once;
std::call_once(log_annotated_tags_key_once, [&]() {
LOG_INFO("start s3 accessor parallel worker pool");
- worker_pool =
std::make_shared<SimpleThreadPool>(config::recycle_pool_parallelism);
+ worker_pool =
+
std::make_shared<SimpleThreadPool>(config::recycle_pool_parallelism,
"s3_accessor");
worker_pool->start();
});
switch (conf_.provider) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]