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

add metric for search split affinity #4998

Merged
merged 6 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions quickwit/quickwit-search/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use quickwit_common::metrics::{
pub struct SearchMetrics {
pub leaf_searches_splits_total: IntCounter,
pub leaf_search_split_duration_secs: Histogram,
pub job_assigned_total: IntCounter,
trinity-1686a marked this conversation as resolved.
Show resolved Hide resolved
pub job_assigned_to_affinity_searcher: IntCounter,
}

impl Default for SearchMetrics {
Expand All @@ -45,6 +47,18 @@ impl Default for SearchMetrics {
"search",
exponential_buckets(0.005, 2.0, 10).unwrap(),
),
job_assigned_total: new_counter(
"job_assigned_total",
"Number of job assigned to searchers",
"search",
&[],
),
job_assigned_to_affinity_searcher: new_counter(
"job_assigned_to_affinity_searcher_total",
"Number of job assigned to the searcher of highest affinity",
"search",
&[],
),
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion quickwit/quickwit-search/src/search_job_placer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use quickwit_common::pubsub::EventSubscriber;
use quickwit_common::rendezvous_hasher::{node_affinity, sort_by_rendez_vous_hash};
use quickwit_proto::search::{ReportSplit, ReportSplitsRequest};

use crate::{SearchJob, SearchServiceClient, SearcherPool};
use crate::{SearchJob, SearchServiceClient, SearcherPool, SEARCH_METRICS};

/// Job.
/// The unit in which distributed search is performed.
Expand Down Expand Up @@ -185,6 +185,11 @@ impl SearchJobPlacer {
} else {
0
};
if chosen_node_idx == 0 {
SEARCH_METRICS.job_assigned_to_affinity_searcher.inc();
}
SEARCH_METRICS.job_assigned_total.inc();

let chosen_node = &mut candidate_nodes[chosen_node_idx];
chosen_node.load += job.cost();

Expand Down
Loading