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