From 978ac13eb56b4506fc1f2f40301933cf1a224e31 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 16 Jul 2026 00:26:08 +0800 Subject: [PATCH] fix(rustfs): gate mimalloc JSON helpers off Windows (#4875) Avoid compiling the mimalloc JSON parsing helpers on non-test Windows builds so the platform-specific dead_code warnings disappear while tests keep coverage through #[cfg(test)]. Co-authored-by: heihutu --- rustfs/src/memory_observability.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rustfs/src/memory_observability.rs b/rustfs/src/memory_observability.rs index f0a7b5093..8a5e2aef7 100644 --- a/rustfs/src/memory_observability.rs +++ b/rustfs/src/memory_observability.rs @@ -17,6 +17,7 @@ use rustfs_io_metrics::{ record_cpu_usage, record_memory_usage, record_process_memory_split, }; use serde::Serialize; +#[cfg(any(test, not(target_os = "windows")))] use serde_json::Value; use std::collections::HashMap; #[cfg(not(target_os = "windows"))] @@ -213,6 +214,7 @@ fn read_cgroup_memory_snapshot() -> Option { read_cgroup_v2().or_else(read_cgroup_v1) } +#[cfg(any(test, not(target_os = "windows")))] fn numeric_json_value(value: &Value) -> Option { match value { Value::Number(number) => number @@ -223,6 +225,7 @@ fn numeric_json_value(value: &Value) -> Option { } } +#[cfg(any(test, not(target_os = "windows")))] fn numeric_json_field(value: &Value, field: &str) -> Option { match value { Value::Object(fields) => fields @@ -234,6 +237,7 @@ fn numeric_json_field(value: &Value, field: &str) -> Option { } } +#[cfg(any(test, not(target_os = "windows")))] fn mimalloc_stat_field(value: &Value, metric: &str, field: &str) -> Option { match value { Value::Object(fields) => { @@ -250,10 +254,12 @@ fn mimalloc_stat_field(value: &Value, metric: &str, field: &str) -> Option } } +#[cfg(any(test, not(target_os = "windows")))] fn mimalloc_stat_current(value: &Value, metric: &str) -> Option { mimalloc_stat_field(value, metric, "current") } +#[cfg(any(test, not(target_os = "windows")))] fn parse_mimalloc_stats_json(stats_json: &str) -> Option { let value = serde_json::from_str::(stats_json).ok()?; let observation = AllocatorMemoryObservation {