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

Skip to content

Commit bbd5c67

Browse files
committed
upgrade sysinfo and make thread detection work for all Apple M series for now.
1 parent bbd3a1c commit bbd5c67

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ wild = "2.0.4"
3939
owo-colors = "3.5.0"
4040

4141
[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies]
42-
sysinfo = { version = "0.23.2", default-features = false }
42+
sysinfo = { version = "0.27.0", default-features = false }
4343

4444
[[bin]]
4545
name="dua"

src/main.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ fn derive_default_threads(threads: usize) -> usize {
3232
/// On everything else, it's usually a good idea to use as many threads as possible for noticeable speedups.
3333
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
3434
fn derive_default_threads(threads: usize) -> usize {
35-
use sysinfo::{ProcessorExt, RefreshKind, SystemExt};
35+
use sysinfo::{CpuExt, CpuRefreshKind};
36+
use sysinfo::{RefreshKind, SystemExt};
3637
if threads == 0 {
37-
sysinfo::System::new_with_specifics(RefreshKind::new().with_cpu())
38-
.processors()
39-
.get(0)
40-
.map_or(0, |p| match p.brand() {
41-
"Apple M1"|"Apple M1 Pro"|"Apple M1 Max"|"Apple M2" => 4,
42-
other => {
43-
eprintln!(
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!(
4445
"Couldn't auto-configure correct amount of threads for {}. Create an issue here: https://github.com/byron/dua-cli/issues",
45-
other
46+
system.global_cpu_info().brand()
4647
);
47-
0
48-
}
49-
})
48+
0
49+
}
5050
} else {
5151
threads
5252
}
@@ -57,6 +57,7 @@ fn main() -> Result<()> {
5757

5858
let opt: options::Args = options::Args::parse_from(wild::args_os());
5959
let threads = derive_default_threads(opt.threads);
60+
dbg!(threads);
6061
let walk_options = dua::WalkOptions {
6162
threads,
6263
byte_format: opt.format.into(),

0 commit comments

Comments
 (0)