Introduce debug info for the time it takes to fetch candidates

This commit is contained in:
Clément Renault 2020-12-02 11:36:38 +01:00
parent 13217f072b
commit 4ffbddf21f
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::Debug; use std::fmt::Debug;
use std::ops::Bound::{self, Unbounded, Included, Excluded}; use std::ops::Bound::{self, Included, Excluded};
use std::str::FromStr; use std::str::FromStr;
use heed::types::{ByteSlice, DecodeIgnore}; use heed::types::{ByteSlice, DecodeIgnore};

View File

@ -1,6 +1,7 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::fmt; use std::fmt;
use std::time::Instant;
use anyhow::{bail, Context}; use anyhow::{bail, Context};
use fst::{IntoStreamer, Streamer}; use fst::{IntoStreamer, Streamer};
@ -202,11 +203,14 @@ impl<'a> Search<'a> {
}; };
// We create the original candidates with the facet conditions results. // We create the original candidates with the facet conditions results.
let before = Instant::now();
let facet_candidates = match &self.facet_condition { let facet_candidates = match &self.facet_condition {
Some(condition) => Some(condition.evaluate(self.rtxn, self.index)?), Some(condition) => Some(condition.evaluate(self.rtxn, self.index)?),
None => None, None => None,
}; };
debug!("facet candidates: {:?} took {:.02?}", facet_candidates, before.elapsed());
let order_by_facet = { let order_by_facet = {
let criteria = self.index.criteria(self.rtxn)?; let criteria = self.index.criteria(self.rtxn)?;
let result = criteria.into_iter().flat_map(|criterion| { let result = criteria.into_iter().flat_map(|criterion| {
@ -226,8 +230,7 @@ impl<'a> Search<'a> {
} }
}; };
debug!("facet candidates: {:?}", facet_candidates); let before = Instant::now();
let (candidates, derived_words) = match (facet_candidates, derived_words) { let (candidates, derived_words) = match (facet_candidates, derived_words) {
(Some(mut facet_candidates), Some(derived_words)) => { (Some(mut facet_candidates), Some(derived_words)) => {
let words_candidates = Self::compute_candidates(&derived_words); let words_candidates = Self::compute_candidates(&derived_words);
@ -261,7 +264,7 @@ impl<'a> Search<'a> {
}, },
}; };
debug!("candidates: {:?}", candidates); debug!("candidates: {:?} took {:.02?}", candidates, before.elapsed());
// The mana depth first search is a revised DFS that explore // The mana depth first search is a revised DFS that explore
// solutions in the order of their proximities. // solutions in the order of their proximities.