From b50c4a797365ecd4b96ffc3897d74b07d9f4315d Mon Sep 17 00:00:00 2001 From: congqixia Date: Fri, 6 Jun 2025 16:26:32 +0800 Subject: [PATCH] enhance: Make segcore thread name set correctly (#42497) Previous PR: #42017 did not work due to following updated points by this PR: - Initialize the `name_map`, which not touched at all before - Trim the thread name under 15 characters to fit syscall limit --------- Signed-off-by: Congqi Xia --- internal/core/src/storage/ThreadPools.cpp | 4 ++-- internal/core/src/storage/ThreadPools.h | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/core/src/storage/ThreadPools.cpp b/internal/core/src/storage/ThreadPools.cpp index e6ecff3ea2..f0b6513726 100644 --- a/internal/core/src/storage/ThreadPools.cpp +++ b/internal/core/src/storage/ThreadPools.cpp @@ -14,12 +14,12 @@ // #include "ThreadPools.h" +#include namespace milvus { std::map> ThreadPools::thread_pool_map; -std::map ThreadPools::name_map; std::shared_mutex ThreadPools::mutex_; void @@ -50,7 +50,7 @@ ThreadPools::GetThreadPool(milvus::ThreadPoolPriority priority) { coefficient = LOW_PRIORITY_THREAD_CORE_COEFFICIENT; break; } - std::string name = name_map[priority]; + std::string name = name_map()[priority]; auto result = thread_pool_map.emplace( priority, std::make_unique(coefficient, name)); return *(result.first->second); diff --git a/internal/core/src/storage/ThreadPools.h b/internal/core/src/storage/ThreadPools.h index 4400a02097..8c6dd6e05f 100644 --- a/internal/core/src/storage/ThreadPools.h +++ b/internal/core/src/storage/ThreadPools.h @@ -42,15 +42,21 @@ class ThreadPools { private: ThreadPools() { - name_map[HIGH] = "high_priority_thread_pool"; - name_map[MIDDLE] = "middle_priority_thread_pool"; - name_map[LOW] = "low_priority_thread_pool"; } void ShutDown(); + + static std::map + name_map() { + static std::map name_map = { + {HIGH, "HIGH_SEGC_POOL"}, + {MIDDLE, "MIDD_SEGC_POOL"}, + {LOW, "LOW_SEGC_POOL"}}; + return name_map; + } + static std::map> thread_pool_map; - static std::map name_map; static std::shared_mutex mutex_; };