diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-12-16 11:43:55 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-12-16 11:43:55 +0800 |
commit | a1cf012f36269d97953baac9288b2fc5551bc6a0 (patch) | |
tree | 3626142d34011390d142d9ffd0daa016bf9423a6 | |
parent | 7c40f95b4e05eacfbdb0e3267d443f4642c9f80b (diff) |
Select better default thread count on Apple Silicon (M1)
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | src/options.rs | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 9313c26..9f1be5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ fn main() -> Result<()> { let opt: options::Args = options::Args::parse_from(wild::args_os()); let walk_options = dua::WalkOptions { - threads: opt.threads.unwrap_or(0), + threads: opt.threads, byte_format: opt.format.map(Into::into).unwrap_or(ByteFormat::Metric), apparent_size: opt.apparent_size, count_hard_links: opt.count_hard_links, diff --git a/src/options.rs b/src/options.rs index 9d8ab76..dc9a355 100644 --- a/src/options.rs +++ b/src/options.rs @@ -61,7 +61,20 @@ pub struct Args { /// The amount of threads to use. Defaults to the amount of logical processors. /// Set to 1 to use only a single thread. #[clap(short = 't', long = "threads")] - pub threads: Option<usize>, + // On macos with apple silicon, the IO subsystem is entirely different and one thread can mostly max it out. + // Thus using more threads just burns energy unnecessarily. + // It's notable that `du` is very fast even on a single core and more power efficient than dua with a single core. + // The default of '4' seems related to the amount of performance cores present in the system. + #[cfg_attr( + all(target_os = "macos", target_arch = "aarch64"), + clap(default_value = "4") + )] + // On everything else, it's usually a good idea to use as many threads as possible for noticeable speedups. + #[cfg_attr( + not(all(target_os = "macos", target_arch = "aarch64")), + clap(default_value = "0") + )] + pub threads: usize, /// The format with which to print byte counts. /// Metric - uses 1000 as base (default) |