From 5822764be9a9063eae40e692c99eff4ad3465b30 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Wed, 15 Feb 2023 12:31:14 +0100 Subject: [PATCH] Skip computing index budget in tests --- index-scheduler/src/lib.rs | 17 ++++++++++++++--- meilisearch/src/analytics/segment_analytics.rs | 3 ++- meilisearch/src/option.rs | 12 +++++++++++- meilisearch/tests/common/server.rs | 1 + milli/src/update/indexer_config.rs | 2 ++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index fbf172b20..094b5fc7b 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -366,11 +366,20 @@ impl IndexScheduler { std::fs::create_dir_all(&options.dumps_path)?; let task_db_size = clamp_to_page_size(options.task_db_size); - let budget = IndexBudget { + let budget = if options.indexer_config.skip_index_budget { + IndexBudget { map_size: options.index_base_map_size, index_count: options.index_count, task_db_size, - }; + } + } else { + Self::index_budget( + &options.tasks_path, + options.index_base_map_size, + task_db_size, + options.index_count, + ) + }; let env = heed::EnvOpenOptions::new() .max_dbs(10) @@ -1237,6 +1246,8 @@ mod tests { let tempdir = TempDir::new().unwrap(); let (sender, receiver) = crossbeam::channel::bounded(0); + let indexer_config = IndexerConfig { skip_index_budget: true, ..Default::default() }; + let options = IndexSchedulerOptions { version_file_path: tempdir.path().join(VERSION_FILE_NAME), auth_path: tempdir.path().join("auth"), @@ -1249,7 +1260,7 @@ mod tests { index_base_map_size: 1000 * 1000, // 1 MB, we don't use MiB on purpose. index_growth_amount: 1000 * 1000, // 1 MB index_count: 5, - indexer_config: IndexerConfig::default(), + indexer_config, autobatching_enabled, }; diff --git a/meilisearch/src/analytics/segment_analytics.rs b/meilisearch/src/analytics/segment_analytics.rs index 92ac4b1d5..472001004 100644 --- a/meilisearch/src/analytics/segment_analytics.rs +++ b/meilisearch/src/analytics/segment_analytics.rs @@ -292,7 +292,8 @@ impl From for Infos { ScheduleSnapshot::Enabled(interval) => Some(interval), }; - let IndexerOpts { max_indexing_memory, max_indexing_threads } = indexer_options; + let IndexerOpts { max_indexing_memory, max_indexing_threads, skip_index_budget: _ } = + indexer_options; // We're going to override every sensible information. // We consider information sensible if it contains a path, an address, or a key. diff --git a/meilisearch/src/option.rs b/meilisearch/src/option.rs index c0ac193eb..544827387 100644 --- a/meilisearch/src/option.rs +++ b/meilisearch/src/option.rs @@ -494,12 +494,21 @@ pub struct IndexerOpts { #[clap(long, env = MEILI_MAX_INDEXING_THREADS, default_value_t)] #[serde(default)] pub max_indexing_threads: MaxThreads, + + /// Whether or not we want to determine the budget of virtual memory address space we have available dynamically + /// (the default), or statically. + /// + /// Determining the budget of virtual memory address space dynamically takes some time on some systems (such as macOS) + /// and may make tests non-deterministic, so we want to skip it in tests. + #[clap(skip)] + #[serde(skip)] + pub skip_index_budget: bool, } impl IndexerOpts { /// Exports the values to their corresponding env vars if they are not set. pub fn export_to_env(self) { - let IndexerOpts { max_indexing_memory, max_indexing_threads } = self; + let IndexerOpts { max_indexing_memory, max_indexing_threads, skip_index_budget: _ } = self; if let Some(max_indexing_memory) = max_indexing_memory.0 { export_to_env_if_not_present( MEILI_MAX_INDEXING_MEMORY, @@ -527,6 +536,7 @@ impl TryFrom<&IndexerOpts> for IndexerConfig { max_memory: other.max_indexing_memory.map(|b| b.get_bytes() as usize), thread_pool: Some(thread_pool), max_positions_per_attributes: None, + skip_index_budget: other.skip_index_budget, ..Default::default() }) } diff --git a/meilisearch/tests/common/server.rs b/meilisearch/tests/common/server.rs index 8152edbd0..268b5c4b7 100644 --- a/meilisearch/tests/common/server.rs +++ b/meilisearch/tests/common/server.rs @@ -205,6 +205,7 @@ pub fn default_settings(dir: impl AsRef) -> Opt { indexer_options: IndexerOpts { // memory has to be unlimited because several meilisearch are running in test context. max_indexing_memory: MaxMemory::unlimited(), + skip_index_budget: true, ..Parser::parse_from(None as Option<&str>) }, #[cfg(feature = "metrics")] diff --git a/milli/src/update/indexer_config.rs b/milli/src/update/indexer_config.rs index af7211f90..ff7942fdb 100644 --- a/milli/src/update/indexer_config.rs +++ b/milli/src/update/indexer_config.rs @@ -11,6 +11,7 @@ pub struct IndexerConfig { pub chunk_compression_level: Option, pub thread_pool: Option, pub max_positions_per_attributes: Option, + pub skip_index_budget: bool, } impl Default for IndexerConfig { @@ -24,6 +25,7 @@ impl Default for IndexerConfig { chunk_compression_level: None, thread_pool: None, max_positions_per_attributes: None, + skip_index_budget: false, } } }