JEmalloc is archived now
And will not be maintained going forward.
Are libc malloc's good enough yet ?
David Chisnall points to snmalloc (https://github.com/Microsoft/snmalloc) has anybody tried it ?
Should we also close #3867 as wont-fix? Between the jemalloc archival and #3873 ready to turn libvgz to a pristine zlib copy, I don't see a point pursuing #3867 (and haven't done so since my last unanswered comment).
I got David to elaborate a bit, and I think it sounds very interesting for us:
https://lists.freebsd.org/archives/freebsd-current/2025-June/007846.html
I was just made aware of this: https://jasone.github.io/2025/06/12/jemalloc-postmortem/
Info from ingvar:
phk: fyi, Red Hat plans to include a jemalloc checkout in their varnish package https://src.fedoraproject.org/rpms/varnish/pull-request/9#request_diff
If anybody feels like some benchmarking, it would be nice to see a comparison of:
- glibc::malloc
- jemalloc
- snmalloc
(in alphabetic order :-)
What about mimalloc?
I made a promise to run snmalloc against jemalloc after July 8th
FTR, because I did not mention it outside IRC: A relevant question should also be how much use of a generic memory allocator Varnish-Cache should really make. To summarize the most important places where we make allocations outside stevedores:
- session, req and busy obj via MPL
- objhead, objcore, ilck (struct lck), hcb_y (critbit)
In terms of numbers, that's really all of relevance. Anything else is important, too, but certainly not in terms of performance.
So while we will always need a "good enough" memory allocator for the generic case, and a memory allocator suitable for SMA (FWIW, I would actually expect those two not to be equivalent), I would actually propose to reduce the relevance of an external memory allocator by:
- Making MPL pluggable to allow integration with stevedores
- Moving the mentioned allocation cases to MPL
The advantages, in my mind, would be:
- Would allow a much more holistic view on memory management and make it easier to implement specific optimizations like NUMA. Ultimately, I would think that it should become possible to configure a fixed total amount of memory for varnish-cache to use no matter what, with that memory being used for "everything" (of relevance).
- This could, I think, improve efficiency of the respective operations.