From adb1038b26f8b79cb70d429246d7c3690d726a65 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Sun, 28 Jun 2020 12:13:10 +0200 Subject: [PATCH] Add a `jobs` parameter to set the number of threads the indexer uses --- src/bin/indexer.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/indexer.rs b/src/bin/indexer.rs index c8f95797f..07d1cd28d 100644 --- a/src/bin/indexer.rs +++ b/src/bin/indexer.rs @@ -46,6 +46,10 @@ struct Opt { #[structopt(long, default_value = "100000")] arc_cache_size: usize, + /// Number of parallel jobs, defaults to # of CPUs. + #[structopt(short, long)] + jobs: Option, + /// CSV file to index. csv_file: PathBuf, } @@ -468,6 +472,10 @@ fn open_env_index(path: impl AsRef) -> anyhow::Result<(Env, Index)> { fn main() -> anyhow::Result<()> { let opt = Opt::from_args(); + if let Some(jobs) = opt.jobs { + rayon::ThreadPoolBuilder::new().num_threads(jobs).build_global()?; + } + std::fs::create_dir_all(&opt.database)?; let (env, index) = open_env_index(&opt.database)?;