From 6a2834f2b0059113e59397b5be8d56647841535c 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 0b1cb5977..5013a0ce9 100644 --- a/src/bin/indexer.rs +++ b/src/bin/indexer.rs @@ -40,6 +40,10 @@ struct Opt { #[structopt(long = "db", parse(from_os_str))] database: PathBuf, + /// Number of parallel jobs, defaults to # of CPUs. + #[structopt(short, long)] + jobs: Option, + /// Files to index in parallel. files_to_index: Vec, } @@ -388,6 +392,10 @@ fn compute_words_attributes_docids(wtxn: &mut heed::RwTxn, index: &Index) -> any 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 = EnvOpenOptions::new() .map_size(100 * 1024 * 1024 * 1024) // 100 GB