Repository: meilisearch/meilisearch
File: crates/milli/src/update/indexer_config.rs (Rust)

Code before:
    pub skip_index_budget: bool,
}

impl IndexerConfig {
    pub fn grenad_parameters(&self) -> GrenadParameters {
        GrenadParameters {
            chunk_compression_type: self.chunk_compression_type,
            chunk_compression_level: self.chunk_compression_level,
            max_memory: self.max_memory,
            max_nb_chunks: self.max_nb_chunks,
        }
    }

    pub fn clone_no_threadpool(other: &IndexerConfig) -> Self {
        Self {
            log_every_n: other.log_every_n,
            max_nb_chunks: other.max_nb_chunks,
            documents_chunk_size: other.documents_chunk_size,
            max_memory: other.max_memory,
            chunk_compression_type: other.chunk_compression_type,
            chunk_compression_level: other.chunk_compression_level,
            max_positions_per_attributes: other.max_positions_per_attributes,
            skip_index_budget: other.skip_index_budget,
            thread_pool: None,
        }
    }
}

impl Default for IndexerConfig {
    fn default() -> Self {
        Self {
            log_every_n: None,
            max_nb_chunks: None,
            documents_chunk_size: None,
            max_memory: None,
            chunk_compression_type: CompressionType::None,
            chunk_compression_level: None,
            thread_pool: None,
            max_positions_per_attributes: None,
            skip_index_budget: false,
        }
    }
}


Review comment (suggestion):
```suggestion
    pub fn clone_no_threadpool(&self) -> Self {
        Self {
            log_every_n: self.log_every_n,
            max_nb_chunks: self.max_nb_chunks,
            documents_chunk_size: self.documents_chunk_size,
            max_memory: self.max_memory,
            chunk_compression_type: self.chunk_compression_type,
            chunk_compression_level: self.chunk_compression_level,
            max_positions_per_attributes: self.max_positions_per_attributes,
            skip_index_budget: self.skip_index_budget,
            thread_pool: None,
        }
    }
```

Code after:
    pub max_positions_per_attributes: Option<u32>,
    pub skip_index_budget: bool,
}

impl IndexerConfig {
    pub fn grenad_parameters(&self) -> GrenadParameters {
        GrenadParameters {
            chunk_compression_type: self.chunk_compression_type,
            chunk_compression_level: self.chunk_compression_level,
            max_memory: self.max_memory,
            max_nb_chunks: self.max_nb_chunks,
        }
    }
}

/// By default use only 1 thread for indexing in tests
#[cfg(test)]
pub fn default_thread_pool_and_threads() -> (ThreadPoolNoAbort, Option<usize>) {
    let pool = ThreadPoolNoAbortBuilder::new_for_indexing()
        .num_threads(1)
        .build()
        .expect("failed to build default rayon thread pool");

    (pool, Some(1))
}

#[cfg(not(test))]
pub fn default_thread_pool_and_threads() -> (ThreadPoolNoAbort, Option<usize>) {
    let pool = ThreadPoolNoAbortBuilder::new_for_indexing()
        .build()
        .expect("failed to build default rayon thread pool");

    (pool, None)
}

impl Default for IndexerConfig {
    fn default() -> Self {
        let (thread_pool, max_threads) = default_thread_pool_and_threads();

        Self {
            max_threads,
            thread_pool,
            log_every_n: None,
            max_nb_chunks: None,
            documents_chunk_size: None,
            max_memory: None,
            chunk_compression_type: CompressionType::None,
            chunk_compression_level: None,
            max_positions_per_attributes: None,
            skip_index_budget: false,
        }