Skip to content
Myr

Use N-1 search threads, where N = # cores

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent 1268e98 · Browse files · 3 files+20 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+20 added−4 removed

  • other:+20 added−4 removed

3 files+20 added−4 removed

modified:src/main.rs+9 added-4 removed
2 unmodified lines
3extern crate ansi_term;4extern crate atty;5extern crate regex;6extern crate ignore;7extern crate num_cpus;89pub mod lscolors;10pub mod fshelper;11
55 unmodified lines
67 /// all files under subdirectories of the current directory, etc.68 max_depth: Option<usize>,6970 /// The number of threads to use.70 threads: Option<usize>,71 threads: usize,7273 /// Time to buffer results internally before streaming to the console. This is useful to74 /// provide a sorted output, in case the total execution time is shorter than75 /// `max_buffer_time`.
133 unmodified lines
209 .git_global(config.read_ignore)210 .git_exclude(config.read_ignore)211 .follow_links(config.follow_links)212 .max_depth(config.max_depth)212 .threads(config.threads.unwrap_or(0))213 .threads(config.threads)214 .build_parallel();215216 // Spawn the thread that receives all results through the channel.217 let rx_config = Arc::clone(&config);
215 unmodified lines
433 follow_links: matches.is_present("follow"),434 null_separator: matches.is_present("null_separator"),435 max_depth: matches.value_of("depth")436 .and_then(|n| usize::from_str_radix(n, 10).ok()),437 threads: std::cmp::max(436 threads: matches.value_of("threads")437 .and_then(|n| usize::from_str_radix(n, 10).ok()),438 matches.value_of("threads")439 .and_then(|n| usize::from_str_radix(n, 10).ok())440 .unwrap_or(num_cpus::get()),441 1442 ),443 max_buffer_time: matches.value_of("max-buffer-time")444 .and_then(|n| u64::from_str_radix(n, 10).ok())445 .map(time::Duration::from_millis),446 path_display: if matches.is_present("absolute-path") || root_dir_is_absolute {
20 unmodified lines
modified:Cargo.lock+10 added
4 unmodified lines
5 "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",6 "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",7 "clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)",8 "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",9 "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)",10 "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",11]1213[[package]]
109 unmodified lines
123 "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",124]125126[[package]]127name = "num_cpus"128version = "1.6.2"129source = "registry+https://github.com/rust-lang/crates.io-index"130dependencies = [131 "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",132]133134[[package]]135name = "regex"136version = "0.2.2"137source = "registry+https://github.com/rust-lang/crates.io-index"138dependencies = [
118 unmodified lines
257"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"258"checksum libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "2370ca07ec338939e356443dac2296f581453c35fe1e3a3ed06023c49435f915"259"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"260"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"261"checksum num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aec53c34f2d0247c5ca5d32cca1478762f301740468ee9ee6dcb7a0dd7a0c584"262"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"263"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"264"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"265"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
12 unmodified lines
modified:Cargo.toml+1 added