From ed19b7c3c3ba5b4a116c560b445a34d7520a95a4 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 2 Sep 2024 13:52:18 +0200 Subject: [PATCH] Only reindex if the size increased --- milli/src/vector/settings.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/milli/src/vector/settings.rs b/milli/src/vector/settings.rs index 14e12da3e..b7ae90d89 100644 --- a/milli/src/vector/settings.rs +++ b/milli/src/vector/settings.rs @@ -196,11 +196,22 @@ impl SettingsDiff { ReindexAction::RegeneratePrompts, ); } + if document_template_max_bytes.apply(new_document_template_max_bytes) { - ReindexAction::push_action( - &mut reindex_action, - ReindexAction::RegeneratePrompts, - ) + let previous_document_template_max_bytes = + document_template_max_bytes.set().unwrap_or(default_max_bytes().get()); + let new_document_template_max_bytes = + new_document_template_max_bytes.set().unwrap_or(default_max_bytes().get()); + + // only reindex if the size increased. Reasoning: + // - size decrease is a performance optimization, so we don't reindex and we keep the more accurate vectors + // - size increase is an accuracy optimization, so we want to reindex + if new_document_template_max_bytes > previous_document_template_max_bytes { + ReindexAction::push_action( + &mut reindex_action, + ReindexAction::RegeneratePrompts, + ) + } } distribution.apply(new_distribution);