This is an automated email from the ASF dual-hosted git repository.
mrhhsg 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 8d9eab21858 [fix](be) Restore time-sharing scan pool queue capacity
metric (#68472)
8d9eab21858 is described below
commit 8d9eab218583ee9249ab50270691ccd758889306
Author: HappenLee <[email protected]>
AuthorDate: Thu Sep 24 15:02:55 2026 +0800
[fix](be) Restore time-sharing scan pool queue capacity metric (#68472)
### What problem does this PR solve?
Time-sharing scan pools do not expose `thread_pool_max_queue_size`.
Their initialization registers `thread_pool_max_threads` twice, and the
update hook writes the queue capacity to that same gauge before
overwriting it with the thread limit.
Register and update the existing queue-capacity gauge, following the
regular `ThreadPool` implementation. Add a BE unit test that checks
registration and distinct values for both capacity metrics, then changes
the thread limit and verifies that the queue capacity remains unchanged.
### Release note
Fix the missing `thread_pool_max_queue_size` metric for time-sharing
scan pools.
### Check List (For Author)
- Test: Added
`TimeSharingTaskExecutorTest.test_thread_pool_capacity_metrics`.
- Passed clang-format 16 formatting/check, build hygiene checks, and
`git diff --check`.
- Attempted `./run-be-ut.sh -j 48 --run
--filter=TimeSharingTaskExecutorTest.test_thread_pool_capacity_metrics`;
local CMake configuration failed because OpenMP headers are unavailable
(`omp.h` not found), with faiss/openblas submodules still initializing
at the time. The test has not run locally.
- clang-tidy could not run because the failed configuration did not
generate `compile_commands.json`.
- Behavior changed: Yes, time-sharing scan pools now report their
configured queue capacity.
- Does this need documentation: No, restores an existing thread-pool
metric.
---
.../time_sharing/time_sharing_task_executor.cpp | 4 ++--
.../time_sharing_task_executor_test.cpp | 26 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git
a/be/src/exec/scan/task_executor/time_sharing/time_sharing_task_executor.cpp
b/be/src/exec/scan/task_executor/time_sharing/time_sharing_task_executor.cpp
index 05d07263d0c..e6377e5cd86 100644
--- a/be/src/exec/scan/task_executor/time_sharing/time_sharing_task_executor.cpp
+++ b/be/src/exec/scan/task_executor/time_sharing/time_sharing_task_executor.cpp
@@ -249,7 +249,7 @@ Status TimeSharingTaskExecutor::init() {
INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_active_threads);
INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_max_threads);
INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_queue_size);
- INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_max_threads);
+ INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_max_queue_size);
INT_COUNTER_METRIC_REGISTER(_metric_entity,
thread_pool_task_execution_time_ns_total);
INT_COUNTER_METRIC_REGISTER(_metric_entity,
thread_pool_task_execution_count_total);
INT_COUNTER_METRIC_REGISTER(_metric_entity,
thread_pool_task_wait_worker_time_ns_total);
@@ -266,7 +266,7 @@ Status TimeSharingTaskExecutor::init() {
thread_pool_active_threads->set_value(num_active_threads());
thread_pool_queue_size->set_value(get_queue_size());
- thread_pool_max_threads->set_value(get_max_queue_size());
+ thread_pool_max_queue_size->set_value(get_max_queue_size());
thread_pool_max_threads->set_value(max_threads());
});
return Status::OK();
diff --git
a/be/test/exec/executor/time_sharing/time_sharing_task_executor_test.cpp
b/be/test/exec/executor/time_sharing/time_sharing_task_executor_test.cpp
index 792c01b3b23..2892ed424a5 100644
--- a/be/test/exec/executor/time_sharing/time_sharing_task_executor_test.cpp
+++ b/be/test/exec/executor/time_sharing/time_sharing_task_executor_test.cpp
@@ -30,6 +30,7 @@
#include <thread>
#include "common/exception.h"
+#include "common/metrics/metrics.h"
#include "exec/scan/task_executor/ticker.h"
#include "exec/scan/task_executor/time_sharing/multilevel_split_queue.h"
#include "exec/scan/task_executor/time_sharing/prioritized_split_runner.h"
@@ -387,6 +388,31 @@ protected:
}
};
+TEST_F(TimeSharingTaskExecutorTest, test_thread_pool_capacity_metrics) {
+ TimeSharingTaskExecutor::ThreadConfig thread_config;
+ thread_config.thread_name = "capacity_metrics";
+ thread_config.workload_group = "normal";
+ thread_config.min_thread_num = 0;
+ thread_config.max_thread_num = 4;
+ thread_config.max_queue_size = 17;
+ TimeSharingTaskExecutor executor(thread_config, 0, 1, 1,
std::make_shared<TestingTicker>());
+ ASSERT_TRUE(executor.init().ok());
+
+ auto* max_queue_size =
executor._metric_entity->get_metric("thread_pool_max_queue_size");
+ auto* max_threads =
executor._metric_entity->get_metric("thread_pool_max_threads");
+ ASSERT_NE(max_queue_size, nullptr);
+ ASSERT_NE(max_threads, nullptr);
+
+ executor._metric_entity->trigger_hook_unlocked(true);
+ EXPECT_EQ(max_queue_size->to_string(), "17");
+ EXPECT_EQ(max_threads->to_string(), "4");
+
+ ASSERT_TRUE(executor.set_max_threads(8).ok());
+ executor._metric_entity->trigger_hook_unlocked(true);
+ EXPECT_EQ(max_queue_size->to_string(), "17");
+ EXPECT_EQ(max_threads->to_string(), "8");
+}
+
TEST_F(TimeSharingTaskExecutorTest, test_remove_task_clears_queued_task_count)
{
auto ticker = std::make_shared<TestingTicker>();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]