From 37f742272b26f1ea828fe8ffcad9453b6ac3f77f Mon Sep 17 00:00:00 2001 From: fanyang Date: Sun, 28 Jun 2026 18:03:11 +0800 Subject: [PATCH] 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. --- easytier/examples/cpu_hotspot_ring.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/easytier/examples/cpu_hotspot_ring.rs b/easytier/examples/cpu_hotspot_ring.rs index 5548d9cb..490b6e14 100644 --- a/easytier/examples/cpu_hotspot_ring.rs +++ b/easytier/examples/cpu_hotspot_ring.rs @@ -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};