mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-10 05:57:48 +00:00
refactor: prefer helper over explicit pool construction
Co-authored-by: Many the fish <many@meilisearch.com>
This commit is contained in:
parent
865f24cfef
commit
79db2e67fb
@ -37,8 +37,9 @@ use index_scheduler::{IndexScheduler, IndexSchedulerOptions};
|
|||||||
use meilisearch_auth::{open_auth_store_env, AuthController};
|
use meilisearch_auth::{open_auth_store_env, AuthController};
|
||||||
use meilisearch_types::milli::constants::VERSION_MAJOR;
|
use meilisearch_types::milli::constants::VERSION_MAJOR;
|
||||||
use meilisearch_types::milli::documents::{DocumentsBatchBuilder, DocumentsBatchReader};
|
use meilisearch_types::milli::documents::{DocumentsBatchBuilder, DocumentsBatchReader};
|
||||||
use meilisearch_types::milli::update::{IndexDocumentsConfig, IndexDocumentsMethod, IndexerConfig};
|
use meilisearch_types::milli::update::{
|
||||||
use meilisearch_types::milli::ThreadPoolNoAbortBuilder;
|
default_thread_pool_and_threads, IndexDocumentsConfig, IndexDocumentsMethod, IndexerConfig,
|
||||||
|
};
|
||||||
use meilisearch_types::settings::apply_settings_to_builder;
|
use meilisearch_types::settings::apply_settings_to_builder;
|
||||||
use meilisearch_types::tasks::KindWithContent;
|
use meilisearch_types::tasks::KindWithContent;
|
||||||
use meilisearch_types::versioning::{
|
use meilisearch_types::versioning::{
|
||||||
@ -506,8 +507,7 @@ fn import_dump(
|
|||||||
let base_config = index_scheduler.indexer_config();
|
let base_config = index_scheduler.indexer_config();
|
||||||
|
|
||||||
let indexer_config = if base_config.max_threads.is_none() {
|
let indexer_config = if base_config.max_threads.is_none() {
|
||||||
let thread_pool =
|
let (thread_pool, _) = default_thread_pool_and_threads();
|
||||||
ThreadPoolNoAbortBuilder::new_for_indexing().num_threads(num_cpus::get()).build()?;
|
|
||||||
|
|
||||||
let _config = IndexerConfig { thread_pool, ..*base_config };
|
let _config = IndexerConfig { thread_pool, ..*base_config };
|
||||||
backup_config = _config;
|
backup_config = _config;
|
||||||
|
@ -30,7 +30,7 @@ impl IndexerConfig {
|
|||||||
|
|
||||||
/// By default use only 1 thread for indexing in tests
|
/// By default use only 1 thread for indexing in tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn default_thread_pool_and_threads() -> (ThreadPoolNoAbort, Option<usize>) {
|
pub fn default_thread_pool_and_threads() -> (ThreadPoolNoAbort, Option<usize>) {
|
||||||
let pool = ThreadPoolNoAbortBuilder::new_for_indexing()
|
let pool = ThreadPoolNoAbortBuilder::new_for_indexing()
|
||||||
.num_threads(1)
|
.num_threads(1)
|
||||||
.build()
|
.build()
|
||||||
@ -40,7 +40,7 @@ fn default_thread_pool_and_threads() -> (ThreadPoolNoAbort, Option<usize>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
fn default_thread_pool_and_threads() -> (ThreadPoolNoAbort, Option<usize>) {
|
pub fn default_thread_pool_and_threads() -> (ThreadPoolNoAbort, Option<usize>) {
|
||||||
let pool = ThreadPoolNoAbortBuilder::new_for_indexing()
|
let pool = ThreadPoolNoAbortBuilder::new_for_indexing()
|
||||||
.build()
|
.build()
|
||||||
.expect("failed to build default rayon thread pool");
|
.expect("failed to build default rayon thread pool");
|
||||||
|
@ -4,7 +4,7 @@ pub use self::concurrent_available_ids::ConcurrentAvailableIds;
|
|||||||
pub use self::facet::bulk::FacetsUpdateBulk;
|
pub use self::facet::bulk::FacetsUpdateBulk;
|
||||||
pub use self::facet::incremental::FacetsUpdateIncrementalInner;
|
pub use self::facet::incremental::FacetsUpdateIncrementalInner;
|
||||||
pub use self::index_documents::*;
|
pub use self::index_documents::*;
|
||||||
pub use self::indexer_config::IndexerConfig;
|
pub use self::indexer_config::{default_thread_pool_and_threads, IndexerConfig};
|
||||||
pub use self::new::ChannelCongestion;
|
pub use self::new::ChannelCongestion;
|
||||||
pub use self::settings::{validate_embedding_settings, Setting, Settings};
|
pub use self::settings::{validate_embedding_settings, Setting, Settings};
|
||||||
pub use self::update_step::UpdateIndexingStep;
|
pub use self::update_step::UpdateIndexingStep;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user