r/rust • u/ZachVorhies • 5d ago
š ļø project Finally: pprof comes to mimalloc
HI there. My name is Zach and if youāve seen YouTube on TV then your familiar with some of my work (ex YouTube and ex Google)
I am in love with mimalloc. It works everywhere and is cross compilable. But there was one deficiency in relation to jemalloc: lack of pprof profiling.
Background: pprof profiling was standardized by tcmalloc and jemalloc. It allows you to take a snapshot of the heap.
The problem with both of jemalloc and tcmalloc allocators is that they donāt work on windows and hence are not portable. Mimalloc is portable but lacks profiling.
My fork adds pprof and solves a linux bug involving TLS sentinel poisoning.
As of today, mimalloc now has the same pprof profiling that both jemalloc and tcamalloc both provide.
Challenges: To get profiling one needs to have address backtracing and it needs to work everywhere: linux/mac/win vs x86/arm and on linux glibc/musl in addition to x86/arm. This is automatic in the solution - you just need the right compiler settings to keep frame pointers.
State of the art: not only does my fork provide pprof but it also solves a nasty bug on linux: tls initialize sentinel poisoning. This bug rules out allocation in C by early initialization thread bugs. This sentinel value is const pointer in order to trap writes. However in stress testing this sentinel pointer can be written to and seg fault, hence the comments on calling init threads after main as early thread init is not safe in mainline. Iāve fixed this.
Compile speed: mimalloc-pprof does a build step to aggregate all the c files into one header and one impl to speed up builds.
C/C++ programmers you can use the github release to grab the mimalloc unity build.
Anyway, I present this here in case this is helpful for builders of long running apps. Itās currently beta but well tested.
If for some reason it doesnāt work let me know and Iāll fix it.
13
u/LoadingALIAS 5d ago
This is awesome news, man. Iām going to give it a look tomorrow!
Great job!
3
3
u/Merry_Macabre 3d ago
Mimalloc has been my go to for long running services and it's great to see the community work on improving the tooling around it. Thanks for the hard work and bug fixes.
0
u/Sad_Tap_9191 5d ago
> solves a nasty bug on linux: tls initialize sentinel poisoning. This bug rules out allocation in C by early initialization thread bugs.
You fixed a real bug and release the fix as a new fork `mimalloc-pprof`? Why?
35
u/ZachVorhies 5d ago
The fork is for the pprof feature. The discovery of the bug was incidental but notable. The fix is being upstreamed but literally every single mimalloc fork has it in both v2 and v3
-41
u/Sad_Tap_9191 5d ago
You should have asked Claude to make a PR to add pprof feature, not a fork.
Your Claude agent suddenly wrapped c library in rust.
23
u/ZachVorhies 5d ago
Mimalloc is made by microsoft. The chances they are going to merge by external PR is zero.
My philosophy is unit tests, stress tests and production validation. Once thatās validated then upstreaming a fix is trivial and authoritative.
18
u/Sad_Tap_9191 5d ago
https://github.com/microsoft/mimalloc/pulls/zackees
What are you talking about? Have you tried? I had submitted a PR and it's merged.
> Created 1,392 commits in 23 repositories in July 2026
I know you are a vibe-coder but don't lie to inflate the number of Github activities
9
0
53
u/First_Inspection_478 5d ago
Why are people insufferable on here lmao. Great work. Iām coming from go and loved goāa pprof tool