From 4ffbddf21f42c3a5d171fd76d0c11a0a2f5f74e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 2 Dec 2020 11:36:38 +0100 Subject: [PATCH] Introduce debug info for the time it takes to fetch candidates --- src/search/facet/facet_condition.rs | 2 +- src/search/mod.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/search/facet/facet_condition.rs b/src/search/facet/facet_condition.rs index f0eb363f1..77e1de5ad 100644 --- a/src/search/facet/facet_condition.rs +++ b/src/search/facet/facet_condition.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use std::fmt::Debug; -use std::ops::Bound::{self, Unbounded, Included, Excluded}; +use std::ops::Bound::{self, Included, Excluded}; use std::str::FromStr; use heed::types::{ByteSlice, DecodeIgnore}; diff --git a/src/search/mod.rs b/src/search/mod.rs index 3ec05f485..652995f54 100644 --- a/src/search/mod.rs +++ b/src/search/mod.rs @@ -1,6 +1,7 @@ use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::fmt; +use std::time::Instant; use anyhow::{bail, Context}; use fst::{IntoStreamer, Streamer}; @@ -202,11 +203,14 @@ impl<'a> Search<'a> { }; // We create the original candidates with the facet conditions results. + let before = Instant::now(); let facet_candidates = match &self.facet_condition { Some(condition) => Some(condition.evaluate(self.rtxn, self.index)?), None => None, }; + debug!("facet candidates: {:?} took {:.02?}", facet_candidates, before.elapsed()); + let order_by_facet = { let criteria = self.index.criteria(self.rtxn)?; 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) { (Some(mut facet_candidates), Some(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 // solutions in the order of their proximities.