Expose a flag to enable the MDB_WRITEMAP flag

This commit is contained in:
Kerollmops 2023-05-15 11:23:58 +02:00
parent c4a40e7110
commit f759ec7fad
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
8 changed files with 80 additions and 10 deletions

View file

@ -48,6 +48,8 @@ const MEILI_IGNORE_DUMP_IF_DB_EXISTS: &str = "MEILI_IGNORE_DUMP_IF_DB_EXISTS";
const MEILI_DUMP_DIR: &str = "MEILI_DUMP_DIR";
const MEILI_LOG_LEVEL: &str = "MEILI_LOG_LEVEL";
const MEILI_EXPERIMENTAL_ENABLE_METRICS: &str = "MEILI_EXPERIMENTAL_ENABLE_METRICS";
const MEILI_EXPERIMENTAL_REDUCE_INDEXING_MEMORY_USAGE: &str =
"MEILI_EXPERIMENTAL_REDUCE_INDEXING_MEMORY_USAGE";
const DEFAULT_CONFIG_FILE_PATH: &str = "./config.toml";
const DEFAULT_DB_PATH: &str = "./data.ms";
@ -293,6 +295,20 @@ pub struct Opt {
#[serde(default)]
pub experimental_enable_metrics: bool,
/// Experimentally reduces the amount of RAM used by the engine when indexing documents.
///
/// You must not use this flag in production. It is experimental and can corrupt the database
/// or be removed in future versions. It can also be stabilized or directly integrated
/// into the engine later.
///
/// This flag enables the MDB_WRITEMAP option of LMDB, making the internal key-value store
/// use much less RAM than usual. Unfortunately, it can reduce the write speed of it and therefore
/// slow down the engine. You can read more and tell us about your experience on the dedicated
/// discussion: <https://github.com/meilisearch/product/discussions/652>.
#[clap(long, env = MEILI_EXPERIMENTAL_REDUCE_INDEXING_MEMORY_USAGE)]
#[serde(default)]
pub experimental_reduce_indexing_memory_usage: bool,
#[serde(flatten)]
#[clap(flatten)]
pub indexer_options: IndexerOpts,
@ -385,6 +401,7 @@ impl Opt {
#[cfg(all(not(debug_assertions), feature = "analytics"))]
no_analytics,
experimental_enable_metrics: enable_metrics_route,
experimental_reduce_indexing_memory_usage: reduce_indexing_memory_usage,
} = self;
export_to_env_if_not_present(MEILI_DB_PATH, db_path);
export_to_env_if_not_present(MEILI_HTTP_ADDR, http_addr);
@ -426,6 +443,10 @@ impl Opt {
MEILI_EXPERIMENTAL_ENABLE_METRICS,
enable_metrics_route.to_string(),
);
export_to_env_if_not_present(
MEILI_EXPERIMENTAL_REDUCE_INDEXING_MEMORY_USAGE,
reduce_indexing_memory_usage.to_string(),
);
indexer_options.export_to_env();
}