Repository navigation
Offer mimalloc as the process allocator of the solo stub - #14
Open
buyemune-sys wants to merge 2 commits into
Open
buyemune-sys wants to merge 2 commits into
buyemune-sys wants to merge 2 commits into
Conversation
Author
|
This one is meh, I'll understand if you'll close it as 'wontfix'. |
Security updates replaced libapparmor1 4.0.1really4.0.1-0ubuntu0.24.04.7 with .9 and libexpat1 2.6.1-2ubuntu0.4 with ubuntu0.6, and the pool kept only the new files, so the cold-cache Fetch x86_64 job answers 404 and every x86-64 job behind it is skipped. Both pins move to the versions noble-updates ships now; their SHA256s match the archive's Packages index. The other twelve pins are still served.
With -Dmimalloc the stub links the vendored mimalloc 3.5.3 in place of musl's mallocng. It replaces malloc for the whole process: musl's own callers, the glibc bridge and every guest share one heap, so memory still crosses the bridge in either direction — which an allocator linked into a guest could not offer, since musl's internal allocations (strdup, realpath, asprintf, getaddrinfo) would bypass it and come back to its free(). mallocng takes one lock for every call. On a glibc program that churns malloc/free from N threads, 4M operations per thread on two cores: threads glibc native solo, mallocng solo, mimalloc 1 0.153 s 0.283 s 0.048 s 2 0.158 s 1.103 s 0.051 s 4 0.323 s 1.799 s 0.097 s mimalloc compiles as C++ (upstream's MI_USE_CXX) so its atomics come from the vendored libc++ rather than a compiler <stdatomic.h> the -nostdinc world cannot see. Transparent huge pages stay off, the host's decision. The default build is unchanged. The guest test now frees memory musl allocated for it and memory another thread allocated, which must hold for any allocator the stub links, and the Alpine job runs the tests once more with -Dmimalloc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buyemune-sys
force-pushed
the
feat/mimalloc
branch
from
October 20, 2026 08:11
5490448 to
1511487
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Under solo, all of the process's
mallocis served by musl's mallocng, which takes a single lock for every call. Multithreaded guests hit it first. Measured on a glibc program with N threads, 4M malloc/free per thread, 2 cores:On Tarantool 3.8.1 (a glibc binary in a solo bundle), an
ffimalloc/free loop is 2× slower than native with mallocng and 4× faster than native with mimalloc. Other workloads (memtx, net.box, LuaJIT) stay within noise either way.Why in the stub and not in the guest
An allocator linked into the guest (
MI_OVERRIDEinside a glibc program) breaks under solo. musl's internal allocations (strdup,realpath(NULL),asprintf,getaddrinfo, …) bypass it and later reach itsfree():Natively on glibc this works, because glibc itself calls
mallocthrough the PLT. When mimalloc replacesmallocin the stub itself, musl, the bridge and every guest share one heap.What's done
-Dmimalloc(opt-in; the default build is unchanged) links the vendored mimalloc 3.5.3 (ext/mimalloc, tagv3.5.3=d4881d33) into the stub in place of mallocng.MI_USE_CXXmode). Its atomics then come from the vendored libc++<atomic>, so the-nostdincworld does not need the compiler's<stdatomic.h>.MI_DEFAULT_ALLOW_THP=0): that is the host's decision.Test
tst/glibc_guest_test.cgains a check of a property that must hold for any allocator the stub links: the guest frees memory musl allocated on its behalf (realpath(NULL),asprintf) and memory allocated by another thread. Needle:guest heap shared. It passes onmaintoo (one mallocng there); its job is to catch a wrongly wired allocator.Test with mimallocstep (./build -Dmimalloc test)../build testand./build -Dmimalloc testpass. In the stub,nmshowsmalloc==mi_mallocand no mallocng symbols.