Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine resource group task_count metric #9594

Merged
merged 10 commits into from
Nov 8, 2024
13 changes: 8 additions & 5 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,14 @@ 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_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_gac_resp_capacity, {"type", "gac_resp_capacity"})) \
M(tiflash_request_count_per_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"}), \
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, \
Expand Down
2 changes: 0 additions & 2 deletions dbms/src/Flash/EstablishCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
16 changes: 8 additions & 8 deletions dbms/src/Flash/FlashService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, type_handling_mpp_task_dispatch, resource_group).Increment();
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();
if (!tryToResetMaxThreadsMetrics())
Expand All @@ -534,7 +535,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());
Expand Down Expand Up @@ -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,
type_handling_mpp_task_establish,
tiflash_request_count_per_resource_group,
type_mpp_task_establish,
call_data->getResourceGroupName())
.Increment();

Expand Down Expand Up @@ -659,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, type_handling_mpp_task_establish, resource_group).Increment();
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();
if (!tryToResetMaxThreadsMetrics())
Expand All @@ -678,7 +679,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.
Expand Down Expand Up @@ -736,11 +736,11 @@ 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_request_count_per_resource_group, type_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());
});
Expand Down
3 changes: 1 addition & 2 deletions dbms/src/Flash/Mpp/MPPTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_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());
GET_RESOURCE_GROUP_METRIC(tiflash_resource_group, type_handling_mpp_task_run, resource_group).Decrement();
});

// set cancellation hook
Expand Down