From cb1b7513af17b44370896e7ba031654e99d10fa3 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 29 Jan 2025 15:21:52 +0100 Subject: [PATCH] Log the memory metrics only once --- crates/milli/src/update/new/indexer/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/milli/src/update/new/indexer/mod.rs b/crates/milli/src/update/new/indexer/mod.rs index fd9e02b84..8b98bfba3 100644 --- a/crates/milli/src/update/new/indexer/mod.rs +++ b/crates/milli/src/update/new/indexer/mod.rs @@ -21,6 +21,7 @@ use crate::progress::Progress; use crate::update::GrenadParameters; use crate::vector::{ArroyWrapper, EmbeddingConfigs}; use crate::{FieldsIdsMap, GlobalFieldsIdsMap, Index, InternalError, Result, ThreadPoolNoAbort}; +use std::sync::Once; pub(crate) mod de; pub mod document_changes; @@ -33,6 +34,8 @@ mod post_processing; mod update_by_function; mod write; +static LOG_MEMORY_METRICS_ONCE: Once = Once::new(); + /// 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`]. @@ -93,12 +96,14 @@ where }, ); - tracing::debug!( - "Indexation allocated memory metrics - \ - Total BBQueue size: {total_bbbuffer_capacity}, \ - Total extractor memory: {:?}", - grenad_parameters.max_memory, - ); + LOG_MEMORY_METRICS_ONCE.call_once(|| { + tracing::debug!( + "Indexation allocated memory metrics - \ + Total BBQueue size: {total_bbbuffer_capacity}, \ + Total extractor memory: {:?}", + grenad_parameters.max_memory, + ); + }); let (extractor_sender, writer_receiver) = pool .install(|| extractor_writer_bbqueue(&mut bbbuffers, total_bbbuffer_capacity, 1000))