diff --git a/Cargo.lock b/Cargo.lock index c0614289d..99683528b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9980,18 +9980,18 @@ dependencies = [ [[package]] name = "rustfs-mimalloc" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a406f4aa07084301d485beec873af6dccc8e3f8762da244743df92038b1db1a6" +checksum = "ed388b8a3d55818c32973ded41df5215d33ee0f574d9ca03f2731b3007c3284b" dependencies = [ "rustfs-mimalloc-sys", ] [[package]] name = "rustfs-mimalloc-sys" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3051b819175f58445d4c369a72f0ab88149f3885ba8bea2aff3be01f53fe7cd" +checksum = "1c507265df958f6b63f8ccdd21819374186bab5dbdcc3f9c5cf8bff4b2e3f5d0" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index a7d289245..2a2cdd7af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -365,8 +365,8 @@ russh-sftp = "2.4.0" dav-server = "0.11.0" # Performance Analysis and Memory Profiling -rustfs-mimalloc = { version = "0.5.0" } -rustfs-mimalloc-sys = { version = "0.5.0" } +rustfs-mimalloc = { version = "0.5.1" } +rustfs-mimalloc-sys = { version = "0.5.1" } hotpath = { version = "0.24.0", default-features = false } # Snapshot testing for output format regression detection insta = { version = "1.48" } diff --git a/rustfs/src/server/runtime.rs b/rustfs/src/server/runtime.rs index 57fabb4c9..a7e075d41 100644 --- a/rustfs/src/server/runtime.rs +++ b/rustfs/src/server/runtime.rs @@ -30,6 +30,12 @@ fn compute_default_thread_stack_size() -> usize { } } +#[inline] +fn mark_allocator_threadpool_thread() { + #[cfg(not(target_os = "windows"))] + rustfs_mimalloc::set_current_thread_in_threadpool(); +} + #[cfg(test)] mod tests { use super::*; @@ -160,15 +166,19 @@ pub fn tokio_runtime_builder() -> tokio::runtime::Builder { rustfs_utils::get_env_usize(rustfs_config::ENV_MAX_IO_EVENTS_PER_TICK, rustfs_config::DEFAULT_MAX_IO_EVENTS_PER_TICK); builder.enable_all().max_io_events_per_tick(max_io_events_per_tick); - // Optional: Simple log of thread start/stop - if print_tokio_thread_enable() { - builder - .on_thread_start(|| { - tracing::trace!(thread_id = ?std::thread::current().id(), "worker thread started"); - }) - .on_thread_stop(|| { - tracing::trace!(thread_id = ?std::thread::current().id(), "worker thread stopped"); - }); + let print_tokio_threads = print_tokio_thread_enable(); + builder.on_thread_start(move || { + mark_allocator_threadpool_thread(); + if print_tokio_threads { + tracing::trace!(thread_id = ?std::thread::current().id(), "worker thread started"); + } + }); + + // Optional: Simple log of thread stop + if print_tokio_threads { + builder.on_thread_stop(|| { + tracing::trace!(thread_id = ?std::thread::current().id(), "worker thread stopped"); + }); } if !rustfs_obs::is_production_environment() { println!(