From eb09dfed04e377bf44cafe132458004af8222158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 7 Oct 2024 16:41:17 +0200 Subject: [PATCH] Avoid reallocation with the ThreadLocal pool --- milli/src/update/new/extract/faceted/extract_facets.rs | 2 +- milli/src/update/new/extract/searchable/extract_word_docids.rs | 2 +- milli/src/update/new/extract/searchable/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/milli/src/update/new/extract/faceted/extract_facets.rs b/milli/src/update/new/extract/faceted/extract_facets.rs index e6c3b02e6..8ca9a8b20 100644 --- a/milli/src/update/new/extract/faceted/extract_facets.rs +++ b/milli/src/update/new/extract/faceted/extract_facets.rs @@ -211,7 +211,7 @@ impl DocidsExtractor for FacetedDocidsExtractor { let attributes_to_extract = Self::attributes_to_extract(&rtxn, index)?; let attributes_to_extract: Vec<_> = attributes_to_extract.iter().map(|s| s.as_ref()).collect(); - let thread_local = ThreadLocal::new(); + let thread_local = ThreadLocal::with_capacity(rayon::current_num_threads()); { let span = diff --git a/milli/src/update/new/extract/searchable/extract_word_docids.rs b/milli/src/update/new/extract/searchable/extract_word_docids.rs index 6da793276..dde969614 100644 --- a/milli/src/update/new/extract/searchable/extract_word_docids.rs +++ b/milli/src/update/new/extract/searchable/extract_word_docids.rs @@ -342,7 +342,7 @@ impl WordDocidsExtractors { max_positions_per_attributes: MAX_POSITION_PER_ATTRIBUTE, }; - let thread_local = ThreadLocal::new(); + let thread_local = ThreadLocal::with_capacity(rayon::current_num_threads()); { let span = diff --git a/milli/src/update/new/extract/searchable/mod.rs b/milli/src/update/new/extract/searchable/mod.rs index 25f1eda14..a261efda3 100644 --- a/milli/src/update/new/extract/searchable/mod.rs +++ b/milli/src/update/new/extract/searchable/mod.rs @@ -60,7 +60,7 @@ pub trait SearchableExtractor { max_positions_per_attributes: MAX_POSITION_PER_ATTRIBUTE, }; - let thread_local = ThreadLocal::new(); + let thread_local = ThreadLocal::with_capacity(rayon::current_num_threads()); { let span =