From bdd363dd94f5266ae907d18e8c007eac4c1d6aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 26 Sep 2024 17:20:32 +0200 Subject: [PATCH] Add spans --- milli/src/update/new/extract/mod.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/milli/src/update/new/extract/mod.rs b/milli/src/update/new/extract/mod.rs index 2f88831e6..a629f2859 100644 --- a/milli/src/update/new/extract/mod.rs +++ b/milli/src/update/new/extract/mod.rs @@ -8,7 +8,7 @@ use std::mem; pub use faceted::*; use grenad::MergeFunction; -use rayon::iter::IntoParallelIterator; +use rayon::iter::{IntoParallelIterator, ParallelIterator as _}; use rayon::slice::ParallelSliceMut as _; pub use searchable::*; use smallvec::SmallVec; @@ -50,13 +50,24 @@ impl IntoIterator for HashMapMerger { type IntoIter = IntoIter; fn into_iter(self) -> Self::IntoIter { - let mut entries: Vec<_> = self.maps.into_iter().flat_map(|m| m.into_iter()).collect(); - eprintln!("There are {} entries in the HashMapMerger", entries.len()); - entries.par_sort_unstable_by(|(ka, _), (kb, _)| ka.cmp(kb)); - IntoIter { - sorted_entries: entries.into_iter(), - current_key: None, - current_deladd: cache::DelAddRoaringBitmap::default(), + let mut entries = { + let span = tracing::trace_span!(target: "indexing::documents::merge", "into_par_iter"); + let _entered = span.enter(); + let entries: Vec<_> = + self.maps.into_par_iter().flat_map(|m| m.into_par_iter()).collect(); + eprintln!("There are {} entries in the HashMapMerger", entries.len()); + entries + }; + { + let span = + tracing::trace_span!(target: "indexing::documents::merge", "par_sort_unstable_by"); + let _entered = span.enter(); + entries.par_sort_unstable_by(|(ka, _), (kb, _)| ka.cmp(kb)); + IntoIter { + sorted_entries: entries.into_iter(), + current_key: None, + current_deladd: cache::DelAddRoaringBitmap::default(), + } } } }