Skip computing index budget in tests

This commit is contained in:
Louis Dureuil 2023-02-15 12:31:14 +01:00
parent c63294f331
commit 5822764be9
No known key found for this signature in database
5 changed files with 30 additions and 5 deletions

View File

@ -366,10 +366,19 @@ impl IndexScheduler {
std::fs::create_dir_all(&options.dumps_path)?; std::fs::create_dir_all(&options.dumps_path)?;
let task_db_size = clamp_to_page_size(options.task_db_size); 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, map_size: options.index_base_map_size,
index_count: options.index_count, index_count: options.index_count,
task_db_size, 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() let env = heed::EnvOpenOptions::new()
@ -1237,6 +1246,8 @@ mod tests {
let tempdir = TempDir::new().unwrap(); let tempdir = TempDir::new().unwrap();
let (sender, receiver) = crossbeam::channel::bounded(0); let (sender, receiver) = crossbeam::channel::bounded(0);
let indexer_config = IndexerConfig { skip_index_budget: true, ..Default::default() };
let options = IndexSchedulerOptions { let options = IndexSchedulerOptions {
version_file_path: tempdir.path().join(VERSION_FILE_NAME), version_file_path: tempdir.path().join(VERSION_FILE_NAME),
auth_path: tempdir.path().join("auth"), 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_base_map_size: 1000 * 1000, // 1 MB, we don't use MiB on purpose.
index_growth_amount: 1000 * 1000, // 1 MB index_growth_amount: 1000 * 1000, // 1 MB
index_count: 5, index_count: 5,
indexer_config: IndexerConfig::default(), indexer_config,
autobatching_enabled, autobatching_enabled,
}; };

View File

@ -292,7 +292,8 @@ impl From<Opt> for Infos {
ScheduleSnapshot::Enabled(interval) => Some(interval), 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're going to override every sensible information.
// We consider information sensible if it contains a path, an address, or a key. // We consider information sensible if it contains a path, an address, or a key.

View File

@ -494,12 +494,21 @@ pub struct IndexerOpts {
#[clap(long, env = MEILI_MAX_INDEXING_THREADS, default_value_t)] #[clap(long, env = MEILI_MAX_INDEXING_THREADS, default_value_t)]
#[serde(default)] #[serde(default)]
pub max_indexing_threads: MaxThreads, 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 { impl IndexerOpts {
/// Exports the values to their corresponding env vars if they are not set. /// Exports the values to their corresponding env vars if they are not set.
pub fn export_to_env(self) { 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 { if let Some(max_indexing_memory) = max_indexing_memory.0 {
export_to_env_if_not_present( export_to_env_if_not_present(
MEILI_MAX_INDEXING_MEMORY, 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), max_memory: other.max_indexing_memory.map(|b| b.get_bytes() as usize),
thread_pool: Some(thread_pool), thread_pool: Some(thread_pool),
max_positions_per_attributes: None, max_positions_per_attributes: None,
skip_index_budget: other.skip_index_budget,
..Default::default() ..Default::default()
}) })
} }

View File

@ -205,6 +205,7 @@ pub fn default_settings(dir: impl AsRef<Path>) -> Opt {
indexer_options: IndexerOpts { indexer_options: IndexerOpts {
// memory has to be unlimited because several meilisearch are running in test context. // memory has to be unlimited because several meilisearch are running in test context.
max_indexing_memory: MaxMemory::unlimited(), max_indexing_memory: MaxMemory::unlimited(),
skip_index_budget: true,
..Parser::parse_from(None as Option<&str>) ..Parser::parse_from(None as Option<&str>)
}, },
#[cfg(feature = "metrics")] #[cfg(feature = "metrics")]

View File

@ -11,6 +11,7 @@ pub struct IndexerConfig {
pub chunk_compression_level: Option<u32>, pub chunk_compression_level: Option<u32>,
pub thread_pool: Option<ThreadPool>, pub thread_pool: Option<ThreadPool>,
pub max_positions_per_attributes: Option<u32>, pub max_positions_per_attributes: Option<u32>,
pub skip_index_budget: bool,
} }
impl Default for IndexerConfig { impl Default for IndexerConfig {
@ -24,6 +25,7 @@ impl Default for IndexerConfig {
chunk_compression_level: None, chunk_compression_level: None,
thread_pool: None, thread_pool: None,
max_positions_per_attributes: None, max_positions_per_attributes: None,
skip_index_budget: false,
} }
} }
} }