diff --git a/Cargo.lock b/Cargo.lock index 6eb09d58d8..e0e1058a56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1221,16 +1221,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "dispatch2" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" -dependencies = [ - "bitflags 2.13.0", - "objc2", -] - [[package]] name = "displaydoc" version = "0.2.6" @@ -2745,15 +2735,6 @@ dependencies = [ "libc", ] -[[package]] -name = "objc2" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f" -dependencies = [ - "objc2-encode", -] - [[package]] name = "objc2-core-foundation" version = "0.3.2" @@ -2761,24 +2742,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags 2.13.0", - "dispatch2", - "objc2", -] - -[[package]] -name = "objc2-encode" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" - -[[package]] -name = "objc2-foundation" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" -dependencies = [ - "bitflags 2.13.0", - "objc2", ] [[package]] @@ -2791,17 +2754,6 @@ dependencies = [ "objc2-core-foundation", ] -[[package]] -name = "objc2-open-directory" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb82bed227edf5201dfedf072bba4015a33d3d4a98519837295a90f0a23f676d" -dependencies = [ - "objc2", - "objc2-core-foundation", - "objc2-foundation", -] - [[package]] name = "object" version = "0.37.3" @@ -4708,16 +4660,15 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.39.6" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2071df9448915b71c4fe6d25deaf1c22f12bd234f01540b77312bb8e41361e6" +checksum = "0e8a3edbe0394ce115f3917a00349dd242be09eb5a091ed509eaf67b55cfb8a8" dependencies = [ "libc", "memchr", "ntapi", "objc2-core-foundation", "objc2-io-kit", - "objc2-open-directory", "windows", ] diff --git a/Cargo.toml b/Cargo.toml index 5802b57f51..8bab123d4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,7 +71,10 @@ syn = { version = "2", default-features = false, features = ["full", "parsing", # acceptable cost for a preflight check. Unlisted mounts are detected by the # device-ID cross-check in `rocm-core::disk_space` and reported as unknown, # which never blocks an install. -sysinfo = { version = "0.39", features = ["linux-tmpfs"] } +# Default features are off because 0.40's `gpu` feature calls `statx` directly, +# which glibc 2.17 (the manylinux2014 release build) does not provide, so the +# link fails. Only CPU, memory and disk figures are used. +sysinfo = { version = "0.40", default-features = false, features = ["system", "disk", "linux-tmpfs"] } tokio = { version = "1.48", features = ["macros", "net", "rt-multi-thread", "signal", "sync", "time"] } [workspace.lints.rust] diff --git a/MANIFEST.md b/MANIFEST.md index 89b563b410..b29423ee2f 100644 --- a/MANIFEST.md +++ b/MANIFEST.md @@ -152,7 +152,6 @@ repository. | directories | 6.0.0 | MIT OR Apache-2.0 | | dirs | 7.0.0 | MIT OR Apache-2.0 | | dirs-sys | 0.5.0 | MIT OR Apache-2.0 | -| dispatch2 | 0.3.1 | Zlib OR Apache-2.0 OR MIT | | displaydoc | 0.2.6 | MIT OR Apache-2.0 | | document-features | 0.2.12 | MIT OR Apache-2.0 | | downcast-rs | 1.2.1 | MIT/Apache-2.0 | @@ -307,12 +306,8 @@ repository. | num-traits | 0.2.19 | MIT OR Apache-2.0 | | num_cpus | 1.17.0 | MIT OR Apache-2.0 | | num_threads | 0.1.7 | MIT OR Apache-2.0 | -| objc2 | 0.6.4 | MIT | | objc2-core-foundation | 0.3.2 | Zlib OR Apache-2.0 OR MIT | -| objc2-encode | 4.1.0 | MIT | -| objc2-foundation | 0.3.2 | MIT | | objc2-io-kit | 0.3.2 | Zlib OR Apache-2.0 OR MIT | -| objc2-open-directory | 0.3.2 | Zlib OR Apache-2.0 OR MIT | | object | 0.37.3 | Apache-2.0 OR MIT | | once_cell | 1.21.4 | MIT OR Apache-2.0 | | once_cell_polyfill | 1.70.2 | MIT OR Apache-2.0 | @@ -470,7 +465,7 @@ repository. | synthez | 0.4.0 | BlueOak-1.0.0 | | synthez-codegen | 0.4.0 | BlueOak-1.0.0 | | synthez-core | 0.4.0 | BlueOak-1.0.0 | -| sysinfo | 0.39.6 | MIT | +| sysinfo | 0.40.1 | MIT | | system-configuration | 0.7.0 | MIT OR Apache-2.0 | | system-configuration-sys | 0.6.0 | MIT OR Apache-2.0 | | tar | 0.4.46 | MIT OR Apache-2.0 | diff --git a/THIRD_PARTY_NOTICES.txt b/THIRD_PARTY_NOTICES.txt index a189de6d96..9fadd37ad1 100644 --- a/THIRD_PARTY_NOTICES.txt +++ b/THIRD_PARTY_NOTICES.txt @@ -8379,7 +8379,6 @@ The following component(s) are licensed under Apache License 2.0: - num-conv 0.2.2 - objc2-core-foundation 0.3.2 - objc2-io-kit 0.3.2 - - objc2-open-directory 0.3.2 - pin-project-internal 1.1.13 - pin-project-lite 0.2.17 - pin-project 1.1.13 @@ -10794,9 +10793,6 @@ The following component(s) are licensed under MIT License: - async-stream-impl 0.3.6 - async-stream 0.3.6 - libm 0.2.16 - - objc2-encode 4.1.0 - - objc2-foundation 0.3.2 - - objc2 0.6.4 - peg-macros 0.6.3 - peg-runtime 0.6.3 @@ -11167,7 +11163,7 @@ MIT License ================================================================================ The following component(s) are licensed under MIT License: - - sysinfo 0.39.6 + - sysinfo 0.40.1 The MIT License (MIT) diff --git a/crates/rocm-core/src/disk_space.rs b/crates/rocm-core/src/disk_space.rs index 9134010120..b24157d724 100644 --- a/crates/rocm-core/src/disk_space.rs +++ b/crates/rocm-core/src/disk_space.rs @@ -230,11 +230,20 @@ pub fn mount_for_path(path: &Path) -> Option<(PathBuf, u64)> { /// `/proc/diskstats` and `/sys/block/*/queue/rotational`, neither of which this /// module uses. fn listed_mounts() -> Vec<(PathBuf, u64)> { - let disks = sysinfo::Disks::new_with_refreshed_list_specifics( + mounts_of(sysinfo::Disks::new_with_refreshed_list_specifics( sysinfo::DiskRefreshKind::nothing().with_storage(), - ); + )) +} + +/// Flatten a disk listing into mount points, or an empty list when the +/// platform could not enumerate disks at all. An empty list leaves +/// `mount_for_path` with nothing to match, so callers get "unknown" and never +/// block the operation. +fn mounts_of(disks: Result) -> Vec<(PathBuf, u64)> { + let Ok(disks) = disks else { + return Vec::new(); + }; disks - .list() .iter() .map(|disk| (disk.mount_point().to_path_buf(), disk.available_space())) .collect() @@ -892,6 +901,21 @@ mod tests { ); } + #[test] + fn a_failed_disk_enumeration_reports_unknown_space_and_never_blocks() { + // sysinfo 0.40 made listing disks fallible. The failure must surface as + // "no mounts", which `select_mount` cannot match and `classify_space` + // reports as unknown, rather than as a panic or an invented figure. + let mounts = mounts_of::<&str>(Err("the platform could not list disks")); + assert!(mounts.is_empty(), "{mounts:?}"); + let selected = select_mount(Path::new("/var/cache/rocm"), &mounts); + assert_eq!(selected, None); + assert!(matches!( + classify_space(u64::MAX, selected.map(|(_, available)| available)), + SpaceCheck::Unknown + )); + } + #[test] fn insufficient_space_refuses_and_sufficient_space_allows() { // The refusal path itself, driven by a synthetic figure rather than diff --git a/crates/rocm-dash-collectors/src/host.rs b/crates/rocm-dash-collectors/src/host.rs index 478de12aee..5f10b8f4a8 100644 --- a/crates/rocm-dash-collectors/src/host.rs +++ b/crates/rocm-dash-collectors/src/host.rs @@ -8,7 +8,9 @@ use rocm_dash_core::metrics::SystemMetrics; use sysinfo::{MemoryRefreshKind, RefreshKind, System}; pub struct HostCollector { - sys: System, + // `None` when sysinfo could not initialise on this platform; `tick` then + // reports empty metrics instead of failing the whole dashboard. + sys: Option, } impl Default for HostCollector { @@ -22,30 +24,39 @@ impl HostCollector { let refresh = RefreshKind::nothing() .with_cpu(sysinfo::CpuRefreshKind::everything()) .with_memory(MemoryRefreshKind::everything()); - let mut sys = System::new_with_specifics(refresh); - // First refresh primes CPU deltas; the very first read is meaningless. - sys.refresh_cpu_all(); - sys.refresh_memory(); - Self { sys } + Self::from_system(System::new_with_specifics(refresh)) + } + + fn from_system(sys: Result) -> Self { + match sys { + Ok(mut sys) => { + // First refresh primes CPU deltas; the very first read is meaningless. + sys.refresh_cpu_all(); + sys.refresh_memory(); + Self { sys: Some(sys) } + } + Err(error) => { + tracing::warn!(%error, "host metrics unavailable: sysinfo failed to initialise"); + Self { sys: None } + } + } } pub fn tick(&mut self) -> SystemMetrics { - self.sys.refresh_cpu_all(); - self.sys.refresh_memory(); + let Some(sys) = self.sys.as_mut() else { + return SystemMetrics::default(); + }; + sys.refresh_cpu_all(); + sys.refresh_memory(); - let cpu_overall_pct = self.sys.global_cpu_usage(); - let cpu_per_core_pct: Vec = self - .sys - .cpus() - .iter() - .map(sysinfo::Cpu::cpu_usage) - .collect(); + let cpu_overall_pct = sys.global_cpu_usage(); + let cpu_per_core_pct: Vec = sys.cpus().iter().map(sysinfo::Cpu::usage).collect(); // sysinfo reports memory in bytes. - let memory_used_mb = self.sys.used_memory() / 1024 / 1024; - let memory_total_mb = self.sys.total_memory() / 1024 / 1024; - let swap_used_mb = self.sys.used_swap() / 1024 / 1024; - let swap_total_mb = self.sys.total_swap() / 1024 / 1024; + let memory_used_mb = sys.used_memory() / 1024 / 1024; + let memory_total_mb = sys.total_memory() / 1024 / 1024; + let swap_used_mb = sys.used_swap() / 1024 / 1024; + let swap_total_mb = sys.total_swap() / 1024 / 1024; SystemMetrics { cpu_overall_pct, @@ -74,4 +85,15 @@ mod tests { assert!(!m.cpu_per_core_pct.is_empty(), "expected at least one CPU"); assert!(m.memory_total_mb > 0, "expected nonzero total memory"); } + + #[test] + fn a_collector_whose_sysinfo_failed_to_initialise_reports_empty_metrics() { + // sysinfo 0.40 made `System` construction fallible. The dashboard must + // keep ticking, with nothing to show for the host, rather than panic. + let mut c = HostCollector::from_system::<&str>(Err("unsupported platform")); + let m = c.tick(); + assert!(m.cpu_per_core_pct.is_empty(), "{m:?}"); + assert_eq!(m.memory_total_mb, 0, "{m:?}"); + assert_eq!(m.swap_total_mb, 0, "{m:?}"); + } } diff --git a/docs/architecture.md b/docs/architecture.md index fbd94b8757..c92da53ee4 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -429,7 +429,7 @@ The I/O-heavy collector implementations behind `rocm-dash-core`'s traits (amd-sm | [`cgroup.rs`](../crates/rocm-dash-collectors/src/cgroup.rs) | Attributes GPU processes to Docker containers by reading the 64-hex container id from `/proc//cgroup`. | flat | | [`docker.rs`](../crates/rocm-dash-collectors/src/docker.rs) | `DockerDiscovery`: finds vLLM containers through `bollard` and builds a `DiscoveredService` from each container's environment and command line. | flat | | [`engine_registry.rs`](../crates/rocm-dash-collectors/src/engine_registry.rs) | `EngineKind`: maps a serving engine (vLLM, Lemonade) to its label, conventional port and sample parser. | flat | -| [`host.rs`](../crates/rocm-dash-collectors/src/host.rs) | `HostCollector`: CPU, memory and swap from `sysinfo`, sampled once per tick into `SystemMetrics`. Disk and network rates are not collected yet and stay 0. | flat | +| [`host.rs`](../crates/rocm-dash-collectors/src/host.rs) | `HostCollector`: CPU, memory and swap from `sysinfo`, sampled once per tick into `SystemMetrics`. Disk and network rates are not collected yet and stay 0. If `sysinfo` cannot initialise, it logs one warning and every tick reports empty metrics. | flat | | [`lemonade.rs`](../crates/rocm-dash-collectors/src/lemonade.rs) | The Lemonade Server collector: pure parsers over its stats and health endpoints, and discovery of a running server. | flat | | [`parallel.rs`](../crates/rocm-dash-collectors/src/parallel.rs) | `parallel_scrape`: runs an async scrape against many targets concurrently on a `JoinSet`. | flat | | [`vllm_prom.rs`](../crates/rocm-dash-collectors/src/vllm_prom.rs) | The vLLM Prometheus `/metrics` scraper: request gauges, KV-cache usage, the generation-token counter and the latency histogram sums. | flat |