Log the memory metrics only once

This commit is contained in:
Kerollmops 2025-01-29 15:21:52 +01:00
parent a9d0f4a002
commit cb1b7513af
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -21,6 +21,7 @@ use crate::progress::Progress;
use crate::update::GrenadParameters; use crate::update::GrenadParameters;
use crate::vector::{ArroyWrapper, EmbeddingConfigs}; use crate::vector::{ArroyWrapper, EmbeddingConfigs};
use crate::{FieldsIdsMap, GlobalFieldsIdsMap, Index, InternalError, Result, ThreadPoolNoAbort}; use crate::{FieldsIdsMap, GlobalFieldsIdsMap, Index, InternalError, Result, ThreadPoolNoAbort};
use std::sync::Once;
pub(crate) mod de; pub(crate) mod de;
pub mod document_changes; pub mod document_changes;
@ -33,6 +34,8 @@ mod post_processing;
mod update_by_function; mod update_by_function;
mod write; mod write;
static LOG_MEMORY_METRICS_ONCE: Once = Once::new();
/// This is the main function of this crate. /// This is the main function of this crate.
/// ///
/// Give it the output of the [`Indexer::document_changes`] method and it will execute it in the [`rayon::ThreadPool`]. /// Give it the output of the [`Indexer::document_changes`] method and it will execute it in the [`rayon::ThreadPool`].
@ -93,12 +96,14 @@ where
}, },
); );
LOG_MEMORY_METRICS_ONCE.call_once(|| {
tracing::debug!( tracing::debug!(
"Indexation allocated memory metrics - \ "Indexation allocated memory metrics - \
Total BBQueue size: {total_bbbuffer_capacity}, \ Total BBQueue size: {total_bbbuffer_capacity}, \
Total extractor memory: {:?}", Total extractor memory: {:?}",
grenad_parameters.max_memory, grenad_parameters.max_memory,
); );
});
let (extractor_sender, writer_receiver) = pool let (extractor_sender, writer_receiver) = pool
.install(|| extractor_writer_bbqueue(&mut bbbuffers, total_bbbuffer_capacity, 1000)) .install(|| extractor_writer_bbqueue(&mut bbbuffers, total_bbbuffer_capacity, 1000))