summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2022-12-13 20:17:44 +0100
committerSebastian Thiel <sebastian.thiel@icloud.com>2022-12-13 20:17:44 +0100
commitf073375938f742db3259ec284c3c0d4a56fd0077 (patch)
treeb0639d3b1c910e98220e657391cc7542150da860 /src/main.rs
parentd1cdfa1d682962deea5a0c48b90589becd6e19dc (diff)
feat: Remove the handbrake on MacOS which can now deliver the expected performance.
Previously it would limit itself to only using 4 threads as it would use a lot of time in user space. This has changed now, and the traversal itself is much more efficient (even though it could definitely be more efficient when comparing to `pdu`). In any case, counting performance should now greatly improve on M1 MacOS machines.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs38
1 files changed, 1 insertions, 37 deletions
diff --git a/src/main.rs b/src/main.rs
index a7fd3eb..2aac48c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,48 +17,12 @@ fn stderr_if_tty() -> Option<io::Stderr> {
}
}
-#[cfg(not(all(target_os = "macos", target_arch = "aarch64"),))]
-fn derive_default_threads(threads: usize) -> usize {
- threads
-}
-
-/// On Apple Silicon, high-efficiency cores make file accesses slower over all, so avoid over committing for
-/// this one.
-///
-/// 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.
-/// On everything else, it's usually a good idea to use as many threads as possible for noticeable speedups.
-#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
-fn derive_default_threads(threads: usize) -> usize {
- use sysinfo::{CpuExt, CpuRefreshKind};
- use sysinfo::{RefreshKind, SystemExt};
- if threads == 0 {
- let system = sysinfo::System::new_with_specifics(
- RefreshKind::new().with_cpu(CpuRefreshKind::default()),
- );
- if system.global_cpu_info().brand().starts_with("Apple M") {
- 4
- } else {
- eprintln!(
- "Couldn't auto-configure correct amount of threads for {}. Create an issue here: https://github.com/byron/dua-cli/issues",
- system.global_cpu_info().brand()
- );
- 0
- }
- } else {
- threads
- }
-}
-
fn main() -> Result<()> {
use options::Command::*;
let opt: options::Args = options::Args::parse_from(wild::args_os());
- let threads = derive_default_threads(opt.threads);
let walk_options = dua::WalkOptions {
- threads,
+ threads: opt.threads,
byte_format: opt.format.into(),
apparent_size: opt.apparent_size,
count_hard_links: opt.count_hard_links,