249: Use half of the computer threads for the indexing process by default r=Kerollmops a=irevoire

closes #241 
By default, we use only half of the CPU threads when indexing documents; this allows the user to use the search while indexing. Also, the machine will not appear unresponsive when indexing a large batch of documents.

On the special case where a user only has one core, we use it entirely 😄 

Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
bors[bot] 2021-06-28 15:25:11 +00:00 committed by GitHub
commit b0f399a51d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

1
Cargo.lock generated
View File

@ -1631,6 +1631,7 @@ dependencies = [
"milli",
"mime",
"mockall",
"num_cpus",
"obkv",
"once_cell",
"oxidized-json-checker",

View File

@ -53,6 +53,7 @@ meilisearch-tokenizer = { git = "https://github.com/meilisearch/tokenizer.git",
memmap = "0.7.0"
milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.6.0" }
mime = "0.3.16"
num_cpus = "1.13.0"
once_cell = "1.5.2"
oxidized-json-checker = "0.3.2"
parking_lot = "0.11.1"

View File

@ -23,7 +23,7 @@ pub struct UpdateHandler {
impl UpdateHandler {
pub fn new(opt: &IndexerOpts) -> anyhow::Result<Self> {
let thread_pool = rayon::ThreadPoolBuilder::new()
.num_threads(opt.indexing_jobs.unwrap_or(0))
.num_threads(opt.indexing_jobs.unwrap_or(num_cpus::get() / 2))
.build()?;
Ok(Self {
max_nb_chunks: opt.max_nb_chunks,