From ae77fe5a696058c600649a4c8f23f359909e3e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 10 Aug 2020 13:53:53 +0200 Subject: [PATCH] Introduce an option to specify the maximum database size --- src/bin/indexer.rs | 8 ++++++-- src/bin/search.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bin/indexer.rs b/src/bin/indexer.rs index 9cad5382d..8bfdeb80e 100644 --- a/src/bin/indexer.rs +++ b/src/bin/indexer.rs @@ -52,6 +52,11 @@ struct Opt { #[structopt(long = "db", parse(from_os_str))] database: PathBuf, + /// The maximum size the database can take on disk. It is recommended to specify + /// the whole disk space (value must be a multiple of a page size). + #[structopt(long = "db-size", default_value = "107374182400")] // 100 GB + database_size: usize, + /// Number of parallel jobs, defaults to # of CPUs. #[structopt(short, long)] jobs: Option, @@ -419,8 +424,7 @@ fn main() -> anyhow::Result<()> { std::fs::create_dir_all(&opt.database)?; let env = EnvOpenOptions::new() - .map_size(100 * 1024 * 1024 * 1024) // 100 GB - .max_readers(10) + .map_size(opt.database_size) .max_dbs(10) .open(&opt.database)?; diff --git a/src/bin/search.rs b/src/bin/search.rs index 9ecbc1676..bd1adfd65 100644 --- a/src/bin/search.rs +++ b/src/bin/search.rs @@ -20,6 +20,11 @@ struct Opt { #[structopt(long = "db", parse(from_os_str))] database: PathBuf, + /// The maximum size the database can take on disk. It is recommended to specify + /// the whole disk space (value must be a multiple of a page size). + #[structopt(long = "db-size", default_value = "107374182400")] // 100 GB + database_size: usize, + /// Verbose mode (-v, -vv, -vvv, etc.) #[structopt(short, long, parse(from_occurrences))] verbose: usize, @@ -39,8 +44,7 @@ fn main() -> anyhow::Result<()> { std::fs::create_dir_all(&opt.database)?; let env = EnvOpenOptions::new() - .map_size(100 * 1024 * 1024 * 1024) // 100 GB - .max_readers(10) + .map_size(opt.database_size) .max_dbs(10) .open(&opt.database)?;