summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-11-09 17:19:40 -0500
committerAndrew Gallant <jamslam@gmail.com>2016-11-09 17:19:40 -0500
commit5b73dcc8abc3133c98603c64339c35e0ed90c577 (patch)
tree770246e30328910618861fd938fe45b2567afcc7 /src
parent2dce0dc0df3c9ade3d89dd1ed673213d76760509 (diff)
Rework parallelism in directory iterator.
Previously, ignore::WalkParallel would invoke the callback for all *explicitly* given file paths in a single thread, which effectively meant that `rg pattern foo bar baz ...` didn't actually search foo, bar and baz in parallel. The code was structured that way to avoid spinning up workers if no directory paths were given. The original intention was probably to have a separate pool of threads responsible for searching, but ripgrep ended up just reusing the ignore::WalkParallel workers themselves for searching, and thereby subjected to its sub-par performance in this case. The code has been restructured so that file paths are sent to the workers, which brings back parallelism. Fixes #226
Diffstat (limited to 'src')
-rw-r--r--src/args.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/args.rs b/src/args.rs
index 4a3b1115..521dda84 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -1,3 +1,4 @@
+use std::cmp;
use std::env;
use std::io;
use std::path::{Path, PathBuf};
@@ -376,7 +377,7 @@ impl RawArgs {
};
let threads =
if self.flag_threads == 0 {
- num_cpus::get()
+ cmp::min(12, num_cpus::get())
} else {
self.flag_threads
};