From 7a9382b115374ee8aa6e5d07a6b160eff4ebf4a2 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Thu, 30 Jan 2025 11:29:41 +0100 Subject: [PATCH] Better document the rayon limitation condition --- crates/milli/src/vector/ollama.rs | 4 ++++ crates/milli/src/vector/openai.rs | 4 ++++ crates/milli/src/vector/rest.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/crates/milli/src/vector/ollama.rs b/crates/milli/src/vector/ollama.rs index ef5cfd937..d2a80d6b5 100644 --- a/crates/milli/src/vector/ollama.rs +++ b/crates/milli/src/vector/ollama.rs @@ -118,6 +118,8 @@ impl Embedder { text_chunks: Vec>, threads: &ThreadPoolNoAbort, ) -> Result>, EmbedError> { + // This condition helps reduce the number of active rayon jobs + // so that we avoid consuming all the LMDB rtxns and avoid stack overflows. if threads.active_operations() >= REQUEST_PARALLELISM { text_chunks.into_iter().map(move |chunk| self.embed(&chunk, None)).collect() } else { @@ -137,6 +139,8 @@ impl Embedder { texts: &[&str], threads: &ThreadPoolNoAbort, ) -> Result>, EmbedError> { + // This condition helps reduce the number of active rayon jobs + // so that we avoid consuming all the LMDB rtxns and avoid stack overflows. if threads.active_operations() >= REQUEST_PARALLELISM { let embeddings: Result>, _> = texts .chunks(self.prompt_count_in_chunk_hint()) diff --git a/crates/milli/src/vector/openai.rs b/crates/milli/src/vector/openai.rs index afb48bdcd..c7aec5d93 100644 --- a/crates/milli/src/vector/openai.rs +++ b/crates/milli/src/vector/openai.rs @@ -255,6 +255,8 @@ impl Embedder { text_chunks: Vec>, threads: &ThreadPoolNoAbort, ) -> Result>, EmbedError> { + // This condition helps reduce the number of active rayon jobs + // so that we avoid consuming all the LMDB rtxns and avoid stack overflows. if threads.active_operations() >= REQUEST_PARALLELISM { text_chunks.into_iter().map(move |chunk| self.embed(&chunk, None)).collect() } else { @@ -274,6 +276,8 @@ impl Embedder { texts: &[&str], threads: &ThreadPoolNoAbort, ) -> Result>, EmbedError> { + // This condition helps reduce the number of active rayon jobs + // so that we avoid consuming all the LMDB rtxns and avoid stack overflows. if threads.active_operations() >= REQUEST_PARALLELISM { let embeddings: Result>, _> = texts .chunks(self.prompt_count_in_chunk_hint()) diff --git a/crates/milli/src/vector/rest.rs b/crates/milli/src/vector/rest.rs index 49be155c1..58d805aaf 100644 --- a/crates/milli/src/vector/rest.rs +++ b/crates/milli/src/vector/rest.rs @@ -188,6 +188,8 @@ impl Embedder { text_chunks: Vec>, threads: &ThreadPoolNoAbort, ) -> Result>, EmbedError> { + // This condition helps reduce the number of active rayon jobs + // so that we avoid consuming all the LMDB rtxns and avoid stack overflows. if threads.active_operations() >= REQUEST_PARALLELISM { text_chunks.into_iter().map(move |chunk| self.embed(chunk, None)).collect() } else { @@ -207,6 +209,8 @@ impl Embedder { texts: &[&str], threads: &ThreadPoolNoAbort, ) -> Result, EmbedError> { + // This condition helps reduce the number of active rayon jobs + // so that we avoid consuming all the LMDB rtxns and avoid stack overflows. if threads.active_operations() >= REQUEST_PARALLELISM { let embeddings: Result>, _> = texts .chunks(self.prompt_count_in_chunk_hint())