summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2022-12-13 18:48:38 +0100
committerSebastian Thiel <sebastian.thiel@icloud.com>2022-12-13 19:02:05 +0100
commitbbd5c67342f9e5b509b0ab6e9ca2319c3c7605e2 (patch)
tree496205043ddea2fa66edf5c3c13cd1d5b03de0ea
parentbbd3a1ceaa15fb07c86ad9f4f5fcbaf991cb12af (diff)
upgrade sysinfo and make thread detection work for all Apple M series for now.
-rw-r--r--Cargo.lock8
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs25
3 files changed, 18 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b6bb259..a606192 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -396,9 +396,9 @@ dependencies = [
[[package]]
name = "ntapi"
-version = "0.3.7"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
+checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc"
dependencies = [
"winapi",
]
@@ -671,9 +671,9 @@ dependencies = [
[[package]]
name = "sysinfo"
-version = "0.23.13"
+version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3977ec2e0520829be45c8a2df70db2bf364714d8a748316a10c3c35d4d2b01c9"
+checksum = "0d08ba83d6dde63d053e42d7230f0dc7f8d8efeb8d30d3681580d158156461ba"
dependencies = [
"cfg-if",
"core-foundation-sys",
diff --git a/Cargo.toml b/Cargo.toml
index 2198777..d66aeea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -39,7 +39,7 @@ wild = "2.0.4"
owo-colors = "3.5.0"
[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies]
-sysinfo = { version = "0.23.2", default-features = false }
+sysinfo = { version = "0.27.0", default-features = false }
[[bin]]
name="dua"
diff --git a/src/main.rs b/src/main.rs
index c185d75..486aee8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -32,21 +32,21 @@ fn derive_default_threads(threads: usize) -> usize {
/// 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::{ProcessorExt, RefreshKind, SystemExt};
+ use sysinfo::{CpuExt, CpuRefreshKind};
+ use sysinfo::{RefreshKind, SystemExt};
if threads == 0 {
- sysinfo::System::new_with_specifics(RefreshKind::new().with_cpu())
- .processors()
- .get(0)
- .map_or(0, |p| match p.brand() {
- "Apple M1"|"Apple M1 Pro"|"Apple M1 Max"|"Apple M2" => 4,
- other => {
- eprintln!(
+ 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",
- other
+ system.global_cpu_info().brand()
);
- 0
- }
- })
+ 0
+ }
} else {
threads
}
@@ -57,6 +57,7 @@ fn main() -> Result<()> {
let opt: options::Args = options::Args::parse_from(wild::args_os());
let threads = derive_default_threads(opt.threads);
+ dbg!(threads);
let walk_options = dua::WalkOptions {
threads,
byte_format: opt.format.into(),