enhance: add metrics for random sample (#40634)

issue: #39541

Signed-off-by: SpadeA <tangchenjie1210@gmail.com>
This commit is contained in:
Spade A 2025-03-13 21:42:11 +08:00 committed by GitHub
parent bab30a41bf
commit f36d1562bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 5 deletions

View File

@ -101,6 +101,10 @@ PhyRandomSampleNode::GetOutput() {
return nullptr;
}
std::chrono::high_resolution_clock::time_point start =
std::chrono::high_resolution_clock::now();
RowVectorPtr result = nullptr;
if (!is_source_node_) {
auto input_col = GetColumnVector(input_);
TargetBitmapView input_data(input_col->GetRawData(), input_col->size());
@ -126,8 +130,7 @@ PhyRandomSampleNode::GetOutput() {
}
}
is_finished_ = true;
return std::make_shared<RowVector>(std::vector<VectorPtr>{input_col});
result = std::make_shared<RowVector>(std::vector<VectorPtr>{input_col});
} else {
auto sample_output = std::make_shared<ColumnVector>(
TargetBitmap(active_count_), TargetBitmap(active_count_));
@ -152,10 +155,18 @@ PhyRandomSampleNode::GetOutput() {
data.flip();
}
is_finished_ = true;
return std::make_shared<RowVector>(
std::vector<VectorPtr>{sample_output});
result =
std::make_shared<RowVector>(std::vector<VectorPtr>{sample_output});
}
std::chrono::high_resolution_clock::time_point end =
std::chrono::high_resolution_clock::now();
double duration =
std::chrono::duration<double, std::micro>(end - start).count();
monitor::internal_core_search_latency_random_sample.Observe(duration /
1000);
is_finished_ = true;
return result;
}
bool

View File

@ -208,6 +208,8 @@ std::map<std::string, std::string> retrieveGetTargetEntryLatencyLabels{
{"type", "retrieve_get_target_entry_latency"}};
std::map<std::string, std::string> searchGetTargetEntryLatencyLabels{
{"type", "search_get_target_entry_latency"}};
std::map<std::string, std::string> randomSampleLatencyLabels{
{"type", "random_sample_latency"}};
DEFINE_PROMETHEUS_HISTOGRAM_FAMILY(internal_core_search_latency,
"[cpp]latency(us) of search on segment")
@ -237,6 +239,10 @@ DEFINE_PROMETHEUS_HISTOGRAM(internal_core_retrieve_get_target_entry_latency,
DEFINE_PROMETHEUS_HISTOGRAM(internal_core_search_get_target_entry_latency,
internal_core_search_latency,
searchGetTargetEntryLatencyLabels)
DEFINE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_random_sample,
internal_core_search_latency,
randomSampleLatencyLabels)
// mmap metrics
std::map<std::string, std::string> mmapAllocatedSpaceAnonLabel = {
{"type", "anon"}};

View File

@ -141,6 +141,7 @@ DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_scalar_proportion);
DECLARE_PROMETHEUS_HISTOGRAM(internal_core_get_vector_latency);
DECLARE_PROMETHEUS_HISTOGRAM(internal_core_retrieve_get_target_entry_latency);
DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_get_target_entry_latency);
DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_random_sample);
// async cgo metrics
DECLARE_PROMETHEUS_HISTOGRAM_FAMILY(internal_cgo_queue_duration_seconds);