mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-06 04:29:52 +00:00
bench: support mimalloc/jemalloc allocator in cpu_hotspot_ring example
Add #[global_allocator] behind feature flags so the bench can test different allocators. Previously the example used glibc malloc by default (easytier-core.rs sets jemalloc/mimalloc only for the bin target, not examples). Benchmark (4 threads, 1400B, 15s, clone mode): glibc: 246K pps, 3.13us/pkt jemalloc: 246K pps, 3.21us/pkt mimalloc: 242K pps, 3.25us/pkt All within noise. Single-threaded clone has low malloc contention; ~1500B small allocs are served efficiently by all tcaches.
This commit is contained in:
@@ -15,6 +15,14 @@
|
||||
//! Then in another terminal:
|
||||
//! hotpath console
|
||||
|
||||
#[cfg(feature = "mimalloc")]
|
||||
#[global_allocator]
|
||||
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
|
||||
#[cfg(feature = "jemalloc")]
|
||||
#[global_allocator]
|
||||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
use std::net::IpAddr;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user