Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f073375

Browse files
committed
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.
1 parent d1cdfa1 commit f073375

3 files changed

Lines changed: 1 addition & 70 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ open = { version = "3.0", optional = true }
3838
wild = "2.0.4"
3939
owo-colors = "3.5.0"
4040

41-
[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies]
42-
sysinfo = { version = "0.27.0", default-features = false }
43-
4441
[[bin]]
4542
name="dua"
4643
path="src/main.rs"

src/main.rs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,12 @@ fn stderr_if_tty() -> Option<io::Stderr> {
1717
}
1818
}
1919

20-
#[cfg(not(all(target_os = "macos", target_arch = "aarch64"),))]
21-
fn derive_default_threads(threads: usize) -> usize {
22-
threads
23-
}
24-
25-
/// On Apple Silicon, high-efficiency cores make file accesses slower over all, so avoid over committing for
26-
/// this one.
27-
///
28-
/// On macos with apple silicon, the IO subsystem is entirely different and one thread can mostly max it out.
29-
/// Thus using more threads just burns energy unnecessarily.
30-
/// It's notable that `du` is very fast even on a single core and more power efficient than dua with a single core.
31-
/// The default of '4' seems related to the amount of performance cores present in the system.
32-
/// On everything else, it's usually a good idea to use as many threads as possible for noticeable speedups.
33-
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
34-
fn derive_default_threads(threads: usize) -> usize {
35-
use sysinfo::{CpuExt, CpuRefreshKind};
36-
use sysinfo::{RefreshKind, SystemExt};
37-
if threads == 0 {
38-
let system = sysinfo::System::new_with_specifics(
39-
RefreshKind::new().with_cpu(CpuRefreshKind::default()),
40-
);
41-
if system.global_cpu_info().brand().starts_with("Apple M") {
42-
4
43-
} else {
44-
eprintln!(
45-
"Couldn't auto-configure correct amount of threads for {}. Create an issue here: https://github.com/byron/dua-cli/issues",
46-
system.global_cpu_info().brand()
47-
);
48-
0
49-
}
50-
} else {
51-
threads
52-
}
53-
}
54-
5520
fn main() -> Result<()> {
5621
use options::Command::*;
5722

5823
let opt: options::Args = options::Args::parse_from(wild::args_os());
59-
let threads = derive_default_threads(opt.threads);
6024
let walk_options = dua::WalkOptions {
61-
threads,
25+
threads: opt.threads,
6226
byte_format: opt.format.into(),
6327
apparent_size: opt.apparent_size,
6428
count_hard_links: opt.count_hard_links,

0 commit comments

Comments
 (0)