From 95685f1387b74e2bbd7c1e67d383cd5861aa3451 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 7 Jun 2019 08:25:14 +0530 Subject: Assure we don't keep threads around unnecessarily in interactive mode --- src/traverse.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/traverse.rs b/src/traverse.rs index d6ef957..dc28579 100644 --- a/src/traverse.rs +++ b/src/traverse.rs @@ -35,7 +35,7 @@ pub struct Traversal { impl Traversal { pub fn from_walk( - options: WalkOptions, + mut walk_options: WalkOptions, input: Vec, mut update: impl FnMut(&Traversal) -> Result<(), Error>, ) -> Result { @@ -73,10 +73,14 @@ impl Traversal { const INITIAL_CHECK_INTERVAL: usize = 500; let mut check_instant_every = INITIAL_CHECK_INTERVAL; let mut last_seen_eid; - + if walk_options.threads == 0 { + // avoid using the global rayon pool, as it will keep a lot of threads alive after we are done. + // Also means that we will spin up a bunch of threads per root path, instead of reusing them. + walk_options.threads = num_cpus::get_physical(); + } for path in input.into_iter() { last_seen_eid = 0; - for (eid, entry) in options + for (eid, entry) in walk_options .iter_from_path(path.as_ref()) .into_iter() .enumerate() -- cgit v1.2.3