SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Gate pprof dependency behind cfg(unix) to fix Windows build
Chris Lue29b685c2028
diff --git a/seaweed-volume/Cargo.toml b/seaweed-volume/Cargo.tomlindex 6d77586a94..0d7b9f5b78 100644--- a/seaweed-volume/Cargo.toml+++ b/seaweed-volume/Cargo.toml@@ -65,8 +65,6 @@ reed-solomon-erasure = "6"# Loggingtracing = "0.1"tracing-subscriber = { version = "0.3", features = ["env-filter"] }-pprof = { version = "0.15", features = ["prost-codec"] }-# Configtoml = "0.8"serde = { version = "1", features = ["derive"] }@@ -127,6 +125,10 @@ aws-sdk-s3 = { version = "1.125.0", default-features = false, features = ["sigv4aws-credential-types = "1"aws-types = "1"+# pprof is Unix-only (requires libc/nix APIs not available on Windows)+[target.'cfg(unix)'.dependencies]+pprof = { version = "0.15", features = ["prost-codec"] }+[dev-dependencies]tempfile = "3"diff --git a/seaweed-volume/src/main.rs b/seaweed-volume/src/main.rsindex a398dbf665..b7cbd22c82 100644--- a/seaweed-volume/src/main.rs+++ b/seaweed-volume/src/main.rs@@ -10,9 +10,11 @@ use seaweed_volume::security::tls::{GrpcClientAuthPolicy, TlsPolicy,};use seaweed_volume::security::{Guard, SigningKey};+#[cfg(unix)]use seaweed_volume::server::debug::build_debug_router;use seaweed_volume::server::grpc_client::load_outgoing_grpc_tls;use seaweed_volume::server::grpc_server::VolumeGrpcService;+#[cfg(unix)]use seaweed_volume::server::profiling::CpuProfileSession;use seaweed_volume::server::request_id::GrpcRequestIdLayer;use seaweed_volume::server::volume_server::{@@ -24,6 +26,11 @@ use seaweed_volume::storage::types::DiskType;use tokio_rustls::TlsAcceptor;+#[cfg(unix)]+type CpuProfileParam = Option<CpuProfileSession>;+#[cfg(not(unix))]+type CpuProfileParam = Option<()>;+const GRPC_MAX_MESSAGE_SIZE: usize = 1 << 30;const GRPC_KEEPALIVE_INTERVAL: std::time::Duration = std::time::Duration::from_secs(60);const GRPC_KEEPALIVE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(20);@@ -42,6 +49,7 @@ fn main() {let config = config::parse_cli();seaweed_volume::server::server_stats::init_process_start();+ #[cfg(unix)]let cpu_profile = match CpuProfileSession::start(&config) {Ok(session) => session,Err(e) => {@@ -49,6 +57,8 @@ fn main() {std::process::exit(1);}};+ #[cfg(not(unix))]+ let cpu_profile: Option<()> = None;info!("SeaweedFS Volume Server (Rust) v{}",seaweed_volume::version::full_version()@@ -257,7 +267,7 @@ whereasync fn run(config: VolumeServerConfig,- cpu_profile: Option<CpuProfileSession>,+ #[allow(unused_variables)] cpu_profile: CpuProfileParam,) -> Result<(), Box<dyn std::error::Error>> {// Initialize the storelet mut store = Store::new(config.index_type);@@ -435,6 +445,7 @@ async fn run(state.clone(),config.ui_enabled,);+ #[cfg(unix)]if config.pprof {admin_router = admin_router.merge(build_debug_router());}@@ -721,6 +732,7 @@ async fn run(None};+ #[cfg(unix)]let debug_handle = if config.debug {let debug_addr = format!("0.0.0.0:{}", config.debug_port);info!("Debug pprof server listening on {}", debug_addr);@@ -742,6 +754,8 @@ async fn run(} else {None};+ #[cfg(not(unix))]+ let debug_handle: Option<tokio::task::JoinHandle<()>> = None;let metrics_push_handle = {let push_state = state.clone();@@ -774,6 +788,7 @@ async fn run(// Close all volumes (flush and release file handles) matching Go's Shutdown()state.store.write().unwrap().close();+ #[cfg(unix)]if let Some(cpu_profile) = cpu_profile {cpu_profile.finish().map_err(std::io::Error::other)?;}diff --git a/seaweed-volume/src/server/mod.rs b/seaweed-volume/src/server/mod.rsindex 6103b49807..4056ccfcec 100644--- a/seaweed-volume/src/server/mod.rs+++ b/seaweed-volume/src/server/mod.rs@@ -1,9 +1,11 @@+#[cfg(unix)]pub mod debug;pub mod grpc_client;pub mod grpc_server;pub mod handlers;pub mod heartbeat;pub mod memory_status;+#[cfg(unix)]pub mod profiling;pub mod request_id;pub mod server_stats;