Add spans

This commit is contained in:
Clément Renault 2024-09-26 17:20:32 +02:00
parent d6b3aae8a6
commit bdd363dd94
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -8,7 +8,7 @@ use std::mem;
pub use faceted::*; pub use faceted::*;
use grenad::MergeFunction; use grenad::MergeFunction;
use rayon::iter::IntoParallelIterator; use rayon::iter::{IntoParallelIterator, ParallelIterator as _};
use rayon::slice::ParallelSliceMut as _; use rayon::slice::ParallelSliceMut as _;
pub use searchable::*; pub use searchable::*;
use smallvec::SmallVec; use smallvec::SmallVec;
@ -50,13 +50,24 @@ impl IntoIterator for HashMapMerger {
type IntoIter = IntoIter; type IntoIter = IntoIter;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
let mut entries: Vec<_> = self.maps.into_iter().flat_map(|m| m.into_iter()).collect(); let mut entries = {
eprintln!("There are {} entries in the HashMapMerger", entries.len()); let span = tracing::trace_span!(target: "indexing::documents::merge", "into_par_iter");
entries.par_sort_unstable_by(|(ka, _), (kb, _)| ka.cmp(kb)); let _entered = span.enter();
IntoIter { let entries: Vec<_> =
sorted_entries: entries.into_iter(), self.maps.into_par_iter().flat_map(|m| m.into_par_iter()).collect();
current_key: None, eprintln!("There are {} entries in the HashMapMerger", entries.len());
current_deladd: cache::DelAddRoaringBitmap::default(), 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(),
}
} }
} }
} }