perf: add a mimalloc allocation fast path - #15658
LingyuCoder wants to merge 5 commits into
Conversation
📦 Binary Size-limit
🎉 Size decreased by 31.95KB from 68.85MB to 68.82MB (⬇️0.05%) |
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Merging this PR will improve performance by 3.47%
|
This reverts commit f50eb40.
PR #15658's fast path calls libmimalloc_sys::mi_malloc directly for word-aligned layouts, relying on mimalloc's ordinary entry point to satisfy the requested alignment. mimalloc does not guarantee that contract across versions or build configurations, so the fast path cannot be relied upon for stability or accuracy. Restore the upstream mimalloc::MiMalloc global allocator.
Motivation
Avoid the overhead of mimalloc's aligned allocation API for allocations with ordinary alignment requirements, and make the cached-source hash benchmarks measure actual lookups.
Changes
Implement the shared mimalloc adapter in
rspack_allocator. Route requests with alignment up toalign_of::<usize>()and no larger than the allocation size throughmi_malloc/mi_zalloc, retaining the aligned fallback and existing deallocation and reallocation behavior. Register the binding's global allocator inrspack_binding_api, preserving its allocator selection, while benchmarks register their own wrapper around the shared implementation.Separate cached-source lookups from single and batched HashMap lifecycles. Execute both lookups and include allocation and destruction in the lifecycle measurements, using new benchmark names for the changed workloads.