Skip to content

Commit 28e672c

Browse files
sjuddConvex, Inc.
authored andcommitted
Log the number of segments searched in search2 (#26927)
GitOrigin-RevId: ef282052728ad834472515349fa5ac1d5b72910a
1 parent db8d910 commit 28e672c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

crates/search/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pub use self::{
150150
use crate::{
151151
aggregation::TokenMatchAggregator,
152152
constants::MAX_UNIQUE_QUERY_TERMS,
153+
metrics::log_num_segments_searched_total,
153154
ranking::Ranker,
154155
searcher::{
155156
Bm25Stats,
@@ -446,6 +447,8 @@ impl TantivySearchIndexSchema {
446447
disk_index_ts: Timestamp,
447448
searcher: Arc<dyn Searcher>,
448449
) -> anyhow::Result<RevisionWithKeys> {
450+
log_num_segments_searched_total(segments.len());
451+
449452
// Step 1: Map the old `CompiledQuery` struct onto `TokenQuery`s.
450453
let mut token_queries = vec![];
451454
let num_text_query_terms = compiled_query.text_query.len() as u32;

crates/search/src/metrics.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,3 +580,11 @@ register_convex_counter!(
580580
pub fn log_vector_prefetch_expiration() {
581581
log_counter(&VECTOR_PREFETCH_EXPIRATIONS_TOTAL, 1);
582582
}
583+
584+
register_convex_histogram!(
585+
TEXT_SEARCH_NUMBER_OF_SEGMENTS_TOTAL,
586+
"Number of text segments searched for a multi segment text index"
587+
);
588+
pub fn log_num_segments_searched_total(num_segments: usize) {
589+
log_distribution(&TEXT_SEARCH_NUMBER_OF_SEGMENTS_TOTAL, num_segments as f64);
590+
}

0 commit comments

Comments
 (0)