mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-29 03:45:46 +08:00
perf(runtime): mark Tokio threads as mimalloc threadpool (#6646)
Upgrade rustfs-mimalloc and rustfs-mimalloc-sys to 0.5.1, then call the new safe wrapper from Tokio worker thread startup so mimalloc can treat runtime threads as threadpool workers. Keep the hint no-op on Windows, matching RustFS allocator platform boundaries. Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
Generated
+4
-4
@@ -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",
|
||||
]
|
||||
|
||||
+2
-2
@@ -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" }
|
||||
|
||||
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user