diff --git a/Cargo.lock b/Cargo.lock index cc5a154..b2f68ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,9 +276,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.6.0" +version = "4.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" dependencies = [ "clap_builder", "clap_derive", @@ -298,9 +298,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.6.0" +version = "4.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" dependencies = [ "heck", "proc-macro2", @@ -880,9 +880,9 @@ dependencies = [ [[package]] name = "io-uring" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd7bddefd0a8833b88a4b68f90dae22c7450d11b354198baee3874fd811b344" +checksum = "4d09b98f7eace8982db770e4408e7470b028ce513ac28fecdc6bf4c30fe92b62" dependencies = [ "bitflags", "cfg-if", @@ -1661,9 +1661,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" dependencies = [ "either", "rayon-core", @@ -2041,9 +2041,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.51.1" +version = "1.52.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f66bf9585cda4b724d3e78ab34b73fb2bbaba9011b9bfdf69dc836382ea13b8c" +checksum = "b67dee974fe86fd92cc45b7a95fdd2f99a36a6d7b0d431a231178d3d670bbcc6" dependencies = [ "bytes", "libc", diff --git a/Cargo.toml b/Cargo.toml index aedf3c1..b449431 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ thiserror = "2.0" crossbeam = "0.8" crc32fast = "1.3" libc = "0.2" -tokio = { version = "1.51", features = ["full"] } +tokio = { version = "1.52", features = ["full"] } futures = "0.3" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } @@ -61,7 +61,7 @@ opentelemetry_sdk = { version = "0.27", features = ["rt-tokio"] } opentelemetry-otlp = "0.27" tonic = "0.12" tempfile = "3.27" -rayon = "1.10" +rayon = "1.12" socket2 = "0.5" io-uring = "0.7" dashmap = "6.1" diff --git a/lnc-core/src/backpressure.rs b/lnc-core/src/backpressure.rs index 1447d0a..5003aed 100644 --- a/lnc-core/src/backpressure.rs +++ b/lnc-core/src/backpressure.rs @@ -167,11 +167,7 @@ impl BackpressureMonitor { let mem_bytes = self.memory_bytes.load(Ordering::Relaxed); let mem_total = self.memory_total.load(Ordering::Relaxed); #[allow(clippy::cast_possible_truncation)] - let mem_pct = if mem_total > 0 { - ((mem_bytes * 100) / mem_total) as u8 - } else { - 0 - }; + let mem_pct = (mem_bytes * 100).checked_div(mem_total).unwrap_or(0) as u8; // Check critical thresholds first if queue >= self.config.queue_depth_critical @@ -246,8 +242,7 @@ impl BackpressureMonitor { use std::time::{SystemTime, UNIX_EPOCH}; SystemTime::now() .duration_since(UNIX_EPOCH) - .map(|d| d.as_nanos() as u64) - .unwrap_or(0) + .map_or(0, |d| d.as_nanos() as u64) } /// Should we sample metrics now? (lock-free implementation) @@ -293,11 +288,7 @@ impl BackpressureSnapshot { #[must_use] #[allow(clippy::cast_possible_truncation)] pub fn memory_pct(&self) -> u8 { - if self.memory_total > 0 { - ((self.memory_bytes * 100) / self.memory_total) as u8 - } else { - 0 - } + (self.memory_bytes * 100).checked_div(self.memory_total).unwrap_or(0) as u8 } } diff --git a/lnc-core/src/hlc.rs b/lnc-core/src/hlc.rs index f62acad..c8d883b 100644 --- a/lnc-core/src/hlc.rs +++ b/lnc-core/src/hlc.rs @@ -290,12 +290,11 @@ impl HybridLogicalClock { fn wall_clock_ms() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) - .map(|d| { + .map_or(0, |d| { #[allow(clippy::cast_possible_truncation)] let ms = d.as_millis() as u64; ms }) - .unwrap_or(0) } } diff --git a/lnc-core/src/numa.rs b/lnc-core/src/numa.rs index 37b7747..39ddffb 100644 --- a/lnc-core/src/numa.rs +++ b/lnc-core/src/numa.rs @@ -74,8 +74,7 @@ impl NumaTopology { #[cfg(target_os = "linux")] fn detect_cpu_count() -> usize { std::thread::available_parallelism() - .map(std::num::NonZero::get) - .unwrap_or(1) + .map_or(1, std::num::NonZero::get) } #[cfg(target_os = "linux")]