mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	Do not create too many rayon tasks when processing the settings
This commit is contained in:
		| @@ -118,14 +118,18 @@ impl Embedder { | ||||
|         text_chunks: Vec<Vec<String>>, | ||||
|         threads: &ThreadPoolNoAbort, | ||||
|     ) -> Result<Vec<Vec<Embedding>>, EmbedError> { | ||||
|         threads | ||||
|             .install(move || { | ||||
|                 text_chunks.into_par_iter().map(move |chunk| self.embed(&chunk, None)).collect() | ||||
|             }) | ||||
|             .map_err(|error| EmbedError { | ||||
|                 kind: EmbedErrorKind::PanicInThreadPool(error), | ||||
|                 fault: FaultSource::Bug, | ||||
|             })? | ||||
|         if threads.active_operations() >= REQUEST_PARALLELISM { | ||||
|             text_chunks.into_iter().map(move |chunk| self.embed(&chunk, None)).collect() | ||||
|         } else { | ||||
|             threads | ||||
|                 .install(move || { | ||||
|                     text_chunks.into_par_iter().map(move |chunk| self.embed(&chunk, None)).collect() | ||||
|                 }) | ||||
|                 .map_err(|error| EmbedError { | ||||
|                     kind: EmbedErrorKind::PanicInThreadPool(error), | ||||
|                     fault: FaultSource::Bug, | ||||
|                 })? | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub(crate) fn embed_chunks_ref( | ||||
|   | ||||
| @@ -255,14 +255,18 @@ impl Embedder { | ||||
|         text_chunks: Vec<Vec<String>>, | ||||
|         threads: &ThreadPoolNoAbort, | ||||
|     ) -> Result<Vec<Vec<Embedding>>, EmbedError> { | ||||
|         threads | ||||
|             .install(move || { | ||||
|                 text_chunks.into_par_iter().map(move |chunk| self.embed(&chunk, None)).collect() | ||||
|             }) | ||||
|             .map_err(|error| EmbedError { | ||||
|                 kind: EmbedErrorKind::PanicInThreadPool(error), | ||||
|                 fault: FaultSource::Bug, | ||||
|             })? | ||||
|         if threads.active_operations() >= REQUEST_PARALLELISM { | ||||
|             text_chunks.into_iter().map(move |chunk| self.embed(&chunk, None)).collect() | ||||
|         } else { | ||||
|             threads | ||||
|                 .install(move || { | ||||
|                     text_chunks.into_par_iter().map(move |chunk| self.embed(&chunk, None)).collect() | ||||
|                 }) | ||||
|                 .map_err(|error| EmbedError { | ||||
|                     kind: EmbedErrorKind::PanicInThreadPool(error), | ||||
|                     fault: FaultSource::Bug, | ||||
|                 })? | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub(crate) fn embed_chunks_ref( | ||||
|   | ||||
| @@ -188,14 +188,18 @@ impl Embedder { | ||||
|         text_chunks: Vec<Vec<String>>, | ||||
|         threads: &ThreadPoolNoAbort, | ||||
|     ) -> Result<Vec<Vec<Embedding>>, EmbedError> { | ||||
|         threads | ||||
|             .install(move || { | ||||
|                 text_chunks.into_par_iter().map(move |chunk| self.embed(chunk, None)).collect() | ||||
|             }) | ||||
|             .map_err(|error| EmbedError { | ||||
|                 kind: EmbedErrorKind::PanicInThreadPool(error), | ||||
|                 fault: FaultSource::Bug, | ||||
|             })? | ||||
|         if threads.active_operations() >= REQUEST_PARALLELISM { | ||||
|             text_chunks.into_iter().map(move |chunk| self.embed(chunk, None)).collect() | ||||
|         } else { | ||||
|             threads | ||||
|                 .install(move || { | ||||
|                     text_chunks.into_par_iter().map(move |chunk| self.embed(chunk, None)).collect() | ||||
|                 }) | ||||
|                 .map_err(|error| EmbedError { | ||||
|                     kind: EmbedErrorKind::PanicInThreadPool(error), | ||||
|                     fault: FaultSource::Bug, | ||||
|                 })? | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub(crate) fn embed_chunks_ref( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user