mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-29 16:37:07 +00:00
perf(ecstore): add Vec<u8> buffer pool for EC operations (#6538)
* feat(mimalloc): add arena diagnostics and configuration Based on mimalloc maintainer feedback (microsoft/mimalloc#1372), add diagnostics to check mimalloc arena configuration at runtime. Changes: - Add rustfs-mimalloc-sys to workspace dependencies - Add log_mimalloc_diagnostics() function to check: - arena_max_object_size - pagemap_commit status - mimalloc version - Add memory_observability module with mimalloc diagnostics This helps diagnose why allocations might be going outside arenas, which is the suspected root cause of futex contention. Ref: rustfs/backlog#2005 Ref: microsoft/mimalloc#1372 Co-Authored-By: heihutu <heihutu@gmail.com> * perf(ecstore): add Vec<u8> buffer pool for EC operations Add a general-purpose buffer pool to reduce Vec<u8> allocations in hot paths like EC encoding/decoding. Changes: - Add BufferPool struct in crates/ecstore/src/erasure/codec/buffer_pool.rs - Thread-safe pool with capacity-based bucketing (power-of-two) - Global EC_BUFFER_POOL instance with 16 buffers per bucket - Add buffer_pool module to codec/mod.rs Expected impact: - Reduce heap allocations in EC encode/decode paths - Avoid memzero overhead (proven 4.8% CPU saving in ShardBufferPool) - Reduce mimalloc lock contention Note: Main bottleneck remains mimalloc internal synchronization (futex 98.64% time). Buffer pool provides modest improvement (+2-5%). Ref: rustfs/backlog#2005 Co-Authored-By: heihutu <heihutu@gmail.com> * style: apply cargo fmt to buffer pool and related files Co-Authored-By: heihutu <heihutu@gmail.com> * fix(ecstore): add #[allow(dead_code)] to buffer pool The BufferPool infrastructure is ready but not yet integrated into the EC hot paths. Add #[allow(dead_code)] with clear documentation about integration status. Co-Authored-By: heihutu <heihutu@gmail.com> * perf(ecstore): integrate BufferPool into bitrot verify path Replace vec![0; shard_size] with get_ec_buffer() in the bitrot verification hot path to reduce heap allocations and avoid memzero. Co-Authored-By: heihutu <heihutu@gmail.com> * style: apply cargo fmt to buffer pool and bitrot changes Co-Authored-By: heihutu <heihutu@gmail.com> * refactor(ecstore): clean up buffer pool code - Remove unnecessary #[allow(dead_code)] attributes - Update module documentation to reflect current integration status - Simplify code structure Co-Authored-By: heihutu <heihutu@gmail.com> * perf(runtime): cap default worker threads at 16 Testing showed 16 worker threads outperforms 32+ for 1KiB PUT workloads due to reduced mimalloc lock contention. A/B test results (testing 4-node cluster, c=64): - worker_threads=32: 740 obj/s (baseline) - worker_threads=16: 785 obj/s (+6.1%) The default was detect_cores() which returned 32 on our testing nodes. Cap at 16 for optimal small-object performance. Ref: rustfs/backlog#2005 Co-Authored-By: heihutu <heihutu@gmail.com> * style: apply cargo fmt to buffer pool and runtime changes Co-Authored-By: heihutu <heihutu@gmail.com> * fix(ecstore): remove unused BufferPool::new() function The new() function was never used since EC_BUFFER_POOL initializes directly with with_limits(16). Co-Authored-By: heihutu <heihutu@gmail.com> * fix(ecstore): update buffer_pool tests to use with_limits Replace BufferPool::new() with BufferPool::with_limits(16) in tests since new() was removed in favor of with_limits(). Co-Authored-By: heihutu <heihutu@gmail.com> --------- Co-authored-by: hector <hetor@rustfs.com> Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
|
||||
/// Check mimalloc arena configuration and log diagnostics
|
||||
pub fn log_mimalloc_diagnostics() {
|
||||
#[cfg(feature = "mimalloc")]
|
||||
{
|
||||
use rustfs_mimalloc::MiMalloc;
|
||||
|
||||
// Check arena_max_object_size
|
||||
let arena_max_obj_size = MiMalloc::option_get_size(
|
||||
rustfs_mimalloc_sys::mi_option_t::mi_option_arena_max_object_size
|
||||
);
|
||||
tracing::info!(
|
||||
arena_max_object_size_bytes = arena_max_obj_size,
|
||||
"mimalloc arena_max_object_size"
|
||||
);
|
||||
|
||||
// Check if pagemap is enabled
|
||||
let pagemap_commit = MiMalloc::option_is_enabled(
|
||||
rustfs_mimalloc_sys::mi_option_t::mi_option_pagemap_commit
|
||||
);
|
||||
tracing::info!(
|
||||
pagemap_commit = pagemap_commit,
|
||||
"mimalloc pagemap_commit"
|
||||
);
|
||||
|
||||
// Log version
|
||||
let version = MiMalloc::version();
|
||||
tracing::info!(
|
||||
mimalloc_version = version,
|
||||
"mimalloc version"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user