diff options
Diffstat (limited to 'src')
-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) |