From 2c69af634b4c356a1afb9284573c70d42da4884a Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Thu, 7 Nov 2024 19:32:42 +0800 Subject: [PATCH 1/6] refine resource group task_count metric Signed-off-by: guo-shaoge --- dbms/src/Common/TiFlashMetrics.h | 5 ++++- dbms/src/Flash/EstablishCall.cpp | 2 -- dbms/src/Flash/FlashService.cpp | 11 ++++------- dbms/src/Flash/Mpp/MPPTask.cpp | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index cdecfc84bb5..4ebd27333de 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -840,7 +840,10 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva F(type_gac_req_acquire_tokens, {"type", "gac_req_acquire_tokens"}), \ F(type_gac_req_ru_consumption_delta, {"type", "gac_req_ru_consumption_delta"}), \ F(type_gac_resp_tokens, {"type", "gac_resp_tokens"}), \ - F(type_gac_resp_capacity, {"type", "gac_resp_capacity"}), \ + F(type_gac_resp_capacity, {"type", "gac_resp_capacity"})) \ + M(tiflash_resource_group_task_cnt, \ + "number of handling request for each resource group", \ + Counter, \ F(type_handling_mpp_task_dispatch, {"type", "handling_mpp_task_dispatch"}), \ F(type_handling_mpp_task_establish, {"type", "handling_mpp_task_establish"}), \ F(type_handling_mpp_task_cancel, {"type", "handling_mpp_task_cancel"}), \ diff --git a/dbms/src/Flash/EstablishCall.cpp b/dbms/src/Flash/EstablishCall.cpp index 8b4b00972de..99e8959a0d9 100644 --- a/dbms/src/Flash/EstablishCall.cpp +++ b/dbms/src/Flash/EstablishCall.cpp @@ -65,8 +65,6 @@ EstablishCallData::~EstablishCallData() if (stopwatch) { GET_METRIC(tiflash_coprocessor_handling_request_count, type_mpp_establish_conn).Decrement(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_establish, resource_group_name) - .Decrement(); GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_mpp_establish_conn) .Observe(stopwatch->elapsedSeconds()); } diff --git a/dbms/src/Flash/FlashService.cpp b/dbms/src/Flash/FlashService.cpp index 30e7bea9fa0..b9e300707cc 100644 --- a/dbms/src/Flash/FlashService.cpp +++ b/dbms/src/Flash/FlashService.cpp @@ -514,7 +514,7 @@ grpc::Status FlashService::DispatchMPPTask( GET_METRIC(tiflash_coprocessor_request_count, type_dispatch_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_dispatch_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_dispatch, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_dispatch, resource_group).Increment(); GET_METRIC(tiflash_thread_count, type_active_threads_of_dispatch_mpp).Increment(); GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Increment(); if (!tryToResetMaxThreadsMetrics()) @@ -534,7 +534,6 @@ grpc::Status FlashService::DispatchMPPTask( GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Decrement(); GET_METRIC(tiflash_thread_count, type_active_threads_of_dispatch_mpp).Decrement(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_dispatch_mpp_task).Decrement(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_dispatch, resource_group).Decrement(); GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_dispatch_mpp_task) .Observe(watch.elapsedSeconds()); GET_METRIC(tiflash_coprocessor_response_bytes, type_dispatch_mpp_task).Increment(response->ByteSizeLong()); @@ -613,7 +612,7 @@ grpc::Status AsyncFlashService::establishMPPConnectionAsync(EstablishCallData * GET_METRIC(tiflash_coprocessor_request_count, type_mpp_establish_conn).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_mpp_establish_conn).Increment(); GET_RESOURCE_GROUP_METRIC( - tiflash_resource_group, + tiflash_resource_group_task_cnt, type_handling_mpp_task_establish, call_data->getResourceGroupName()) .Increment(); @@ -659,7 +658,7 @@ grpc::Status FlashService::EstablishMPPConnection( GET_METRIC(tiflash_coprocessor_request_count, type_mpp_establish_conn).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_mpp_establish_conn).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_establish, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_establish, resource_group).Increment(); GET_METRIC(tiflash_thread_count, type_active_threads_of_establish_mpp).Increment(); GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Increment(); if (!tryToResetMaxThreadsMetrics()) @@ -678,7 +677,6 @@ grpc::Status FlashService::EstablishMPPConnection( GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Decrement(); GET_METRIC(tiflash_thread_count, type_active_threads_of_establish_mpp).Decrement(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_mpp_establish_conn).Decrement(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_establish, resource_group).Decrement(); GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_mpp_establish_conn) .Observe(watch.elapsedSeconds()); // TODO: update the value of metric tiflash_coprocessor_response_bytes. @@ -736,11 +734,10 @@ grpc::Status FlashService::CancelMPPTask( const auto & resource_group = request->meta().resource_group_name(); GET_METRIC(tiflash_coprocessor_request_count, type_cancel_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_cancel_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_cancel, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_cancel, resource_group).Increment(); Stopwatch watch; SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_handling_request_count, type_cancel_mpp_task).Decrement(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_cancel, resource_group).Decrement(); GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_cancel_mpp_task).Observe(watch.elapsedSeconds()); GET_METRIC(tiflash_coprocessor_response_bytes, type_cancel_mpp_task).Increment(response->ByteSizeLong()); }); diff --git a/dbms/src/Flash/Mpp/MPPTask.cpp b/dbms/src/Flash/Mpp/MPPTask.cpp index 8b9ca1dd879..8b6c714c2f3 100644 --- a/dbms/src/Flash/Mpp/MPPTask.cpp +++ b/dbms/src/Flash/Mpp/MPPTask.cpp @@ -513,11 +513,10 @@ void MPPTask::runImpl() const auto & resource_group = dag_context->getResourceGroupName(); GET_METRIC(tiflash_coprocessor_request_count, type_run_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_run_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_run, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_run, resource_group).Increment(); SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_handling_request_count, type_run_mpp_task).Decrement(); GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_run_mpp_task).Observe(stopwatch.elapsedSeconds()); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_run, resource_group).Decrement(); }); // set cancellation hook From 1712d4238a0cb62138f302739df16182dda58101 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Thu, 7 Nov 2024 19:36:20 +0800 Subject: [PATCH 2/6] fix Signed-off-by: guo-shaoge --- dbms/src/Common/TiFlashMetrics.h | 6 +++--- dbms/src/Flash/FlashService.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index 4ebd27333de..6acc02eecca 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -841,9 +841,9 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva F(type_gac_req_ru_consumption_delta, {"type", "gac_req_ru_consumption_delta"}), \ F(type_gac_resp_tokens, {"type", "gac_resp_tokens"}), \ F(type_gac_resp_capacity, {"type", "gac_resp_capacity"})) \ - M(tiflash_resource_group_task_cnt, \ - "number of handling request for each resource group", \ - Counter, \ + M(tiflash_resource_group_task_cnt, \ + "number of handling request for each resource group", \ + Counter, \ F(type_handling_mpp_task_dispatch, {"type", "handling_mpp_task_dispatch"}), \ F(type_handling_mpp_task_establish, {"type", "handling_mpp_task_establish"}), \ F(type_handling_mpp_task_cancel, {"type", "handling_mpp_task_cancel"}), \ diff --git a/dbms/src/Flash/FlashService.cpp b/dbms/src/Flash/FlashService.cpp index b9e300707cc..f6b7dfd355a 100644 --- a/dbms/src/Flash/FlashService.cpp +++ b/dbms/src/Flash/FlashService.cpp @@ -514,7 +514,8 @@ grpc::Status FlashService::DispatchMPPTask( GET_METRIC(tiflash_coprocessor_request_count, type_dispatch_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_dispatch_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_dispatch, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_dispatch, resource_group) + .Increment(); GET_METRIC(tiflash_thread_count, type_active_threads_of_dispatch_mpp).Increment(); GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Increment(); if (!tryToResetMaxThreadsMetrics()) @@ -658,7 +659,8 @@ grpc::Status FlashService::EstablishMPPConnection( GET_METRIC(tiflash_coprocessor_request_count, type_mpp_establish_conn).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_mpp_establish_conn).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_establish, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_establish, resource_group) + .Increment(); GET_METRIC(tiflash_thread_count, type_active_threads_of_establish_mpp).Increment(); GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Increment(); if (!tryToResetMaxThreadsMetrics()) @@ -734,7 +736,8 @@ grpc::Status FlashService::CancelMPPTask( const auto & resource_group = request->meta().resource_group_name(); GET_METRIC(tiflash_coprocessor_request_count, type_cancel_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_cancel_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_cancel, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_cancel, resource_group) + .Increment(); Stopwatch watch; SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_handling_request_count, type_cancel_mpp_task).Decrement(); From 4524923d7f9cebcf1aaf777181810689353fa661 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Fri, 8 Nov 2024 12:13:25 +0800 Subject: [PATCH 3/6] fix Signed-off-by: guo-shaoge --- dbms/src/Common/TiFlashMetrics.h | 10 +++++----- dbms/src/Flash/FlashService.cpp | 10 +++++----- dbms/src/Flash/Mpp/MPPTask.cpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index 6acc02eecca..edcf5ffe695 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -841,13 +841,13 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva F(type_gac_req_ru_consumption_delta, {"type", "gac_req_ru_consumption_delta"}), \ F(type_gac_resp_tokens, {"type", "gac_resp_tokens"}), \ F(type_gac_resp_capacity, {"type", "gac_resp_capacity"})) \ - M(tiflash_resource_group_task_cnt, \ + M(tiflash_request_count_per_resource_group, \ "number of handling request for each resource group", \ Counter, \ - F(type_handling_mpp_task_dispatch, {"type", "handling_mpp_task_dispatch"}), \ - F(type_handling_mpp_task_establish, {"type", "handling_mpp_task_establish"}), \ - F(type_handling_mpp_task_cancel, {"type", "handling_mpp_task_cancel"}), \ - F(type_handling_mpp_task_run, {"type", "handling_mpp_task_run"})) \ + F(type_mpp_task_dispatch, {"type", "mpp_task_dispatch"}), \ + F(type_mpp_task_establish, {"type", "mpp_task_establish"}), \ + F(type_mpp_task_cancel, {"type", "mpp_task_cancel"}), \ + F(type_mpp_task_run, {"type", "mpp_task_run"})) \ M(tiflash_compute_request_unit, \ "Request Unit used by tiflash compute for each resource group", \ Counter, \ diff --git a/dbms/src/Flash/FlashService.cpp b/dbms/src/Flash/FlashService.cpp index f6b7dfd355a..e3b2c67e34b 100644 --- a/dbms/src/Flash/FlashService.cpp +++ b/dbms/src/Flash/FlashService.cpp @@ -514,7 +514,7 @@ grpc::Status FlashService::DispatchMPPTask( GET_METRIC(tiflash_coprocessor_request_count, type_dispatch_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_dispatch_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_dispatch, resource_group) + GET_RESOURCE_GROUP_METRIC(tiflash_request_count_per_resource_group, type_mpp_task_dispatch, resource_group) .Increment(); GET_METRIC(tiflash_thread_count, type_active_threads_of_dispatch_mpp).Increment(); GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Increment(); @@ -613,8 +613,8 @@ grpc::Status AsyncFlashService::establishMPPConnectionAsync(EstablishCallData * GET_METRIC(tiflash_coprocessor_request_count, type_mpp_establish_conn).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_mpp_establish_conn).Increment(); GET_RESOURCE_GROUP_METRIC( - tiflash_resource_group_task_cnt, - type_handling_mpp_task_establish, + tiflash_request_count_per_resource_group, + type_mpp_task_establish, call_data->getResourceGroupName()) .Increment(); @@ -659,7 +659,7 @@ grpc::Status FlashService::EstablishMPPConnection( GET_METRIC(tiflash_coprocessor_request_count, type_mpp_establish_conn).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_mpp_establish_conn).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_establish, resource_group) + GET_RESOURCE_GROUP_METRIC(tiflash_request_count_per_resource_group, type_mpp_task_establish, resource_group) .Increment(); GET_METRIC(tiflash_thread_count, type_active_threads_of_establish_mpp).Increment(); GET_METRIC(tiflash_thread_count, type_total_threads_of_raw).Increment(); @@ -736,7 +736,7 @@ grpc::Status FlashService::CancelMPPTask( const auto & resource_group = request->meta().resource_group_name(); GET_METRIC(tiflash_coprocessor_request_count, type_cancel_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_cancel_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_cancel, resource_group) + GET_RESOURCE_GROUP_METRIC(tiflash_request_count_per_resource_group, type_mpp_task_cancel, resource_group) .Increment(); Stopwatch watch; SCOPE_EXIT({ diff --git a/dbms/src/Flash/Mpp/MPPTask.cpp b/dbms/src/Flash/Mpp/MPPTask.cpp index 8b6c714c2f3..f6d8aef55ba 100644 --- a/dbms/src/Flash/Mpp/MPPTask.cpp +++ b/dbms/src/Flash/Mpp/MPPTask.cpp @@ -513,7 +513,7 @@ void MPPTask::runImpl() const auto & resource_group = dag_context->getResourceGroupName(); GET_METRIC(tiflash_coprocessor_request_count, type_run_mpp_task).Increment(); GET_METRIC(tiflash_coprocessor_handling_request_count, type_run_mpp_task).Increment(); - GET_RESOURCE_GROUP_METRIC(tiflash_resource_group_task_cnt, type_handling_mpp_task_run, resource_group).Increment(); + GET_RESOURCE_GROUP_METRIC(tiflash_request_count_per_resource_group, type_mpp_task_run, resource_group).Increment(); SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_handling_request_count, type_run_mpp_task).Decrement(); GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_run_mpp_task).Observe(stopwatch.elapsedSeconds()); From 0bb18bebc08d86cc7a32c8739625e6a3bab59539 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Fri, 8 Nov 2024 12:16:37 +0800 Subject: [PATCH 4/6] fix Signed-off-by: guo-shaoge --- dbms/src/Common/TiFlashMetrics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index edcf5ffe695..aa6328e8677 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -842,7 +842,7 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva F(type_gac_resp_tokens, {"type", "gac_resp_tokens"}), \ F(type_gac_resp_capacity, {"type", "gac_resp_capacity"})) \ M(tiflash_request_count_per_resource_group, \ - "number of handling request for each resource group", \ + "number of mpp request count for each resource group", \ Counter, \ F(type_mpp_task_dispatch, {"type", "mpp_task_dispatch"}), \ F(type_mpp_task_establish, {"type", "mpp_task_establish"}), \ From 671e394309ba52410488ff1de24d886d6e795253 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Fri, 8 Nov 2024 13:11:49 +0800 Subject: [PATCH 5/6] fmt Signed-off-by: guo-shaoge --- dbms/src/Common/TiFlashMetrics.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index aa6328e8677..f404480f787 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -842,12 +842,12 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva F(type_gac_resp_tokens, {"type", "gac_resp_tokens"}), \ F(type_gac_resp_capacity, {"type", "gac_resp_capacity"})) \ M(tiflash_request_count_per_resource_group, \ - "number of mpp request count for each resource group", \ + "number of mpp request count for each resource group", \ Counter, \ - F(type_mpp_task_dispatch, {"type", "mpp_task_dispatch"}), \ - F(type_mpp_task_establish, {"type", "mpp_task_establish"}), \ - F(type_mpp_task_cancel, {"type", "mpp_task_cancel"}), \ - F(type_mpp_task_run, {"type", "mpp_task_run"})) \ + F(type_mpp_task_dispatch, {"type", "mpp_task_dispatch"}), \ + F(type_mpp_task_establish, {"type", "mpp_task_establish"}), \ + F(type_mpp_task_cancel, {"type", "mpp_task_cancel"}), \ + F(type_mpp_task_run, {"type", "mpp_task_run"})) \ M(tiflash_compute_request_unit, \ "Request Unit used by tiflash compute for each resource group", \ Counter, \ From fbce6f66ccbe403ba894c3dc079f81d69a06284a Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Fri, 8 Nov 2024 13:45:57 +0800 Subject: [PATCH 6/6] fix Signed-off-by: guo-shaoge --- dbms/src/Common/TiFlashMetrics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index f404480f787..1c578a5a119 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -842,7 +842,7 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva F(type_gac_resp_tokens, {"type", "gac_resp_tokens"}), \ F(type_gac_resp_capacity, {"type", "gac_resp_capacity"})) \ M(tiflash_request_count_per_resource_group, \ - "number of mpp request count for each resource group", \ + "mpp request count for each resource group", \ Counter, \ F(type_mpp_task_dispatch, {"type", "mpp_task_dispatch"}), \ F(type_mpp_task_establish, {"type", "mpp_task_establish"}), \