varnish-cache icon indicating copy to clipboard operation
varnish-cache copied to clipboard

JEmalloc is archived now

Open bsdphk opened this issue 8 months ago • 8 comments

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 ?

bsdphk avatar Jun 10 '25 09:06 bsdphk

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).

dridi avatar Jun 10 '25 09:06 dridi

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

bsdphk avatar Jun 10 '25 16:06 bsdphk

I was just made aware of this: https://jasone.github.io/2025/06/12/jemalloc-postmortem/

asadsa92 avatar Jun 13 '25 07:06 asadsa92

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

bsdphk avatar Jun 16 '25 13:06 bsdphk

If anybody feels like some benchmarking, it would be nice to see a comparison of:

  • glibc::malloc
  • jemalloc
  • snmalloc

(in alphabetic order :-)

bsdphk avatar Jun 16 '25 13:06 bsdphk

What about mimalloc?

jailbird777 avatar Jun 19 '25 01:06 jailbird777

I made a promise to run snmalloc against jemalloc after July 8th

nigoroll avatar Jun 19 '25 13:06 nigoroll

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:

  1. session, req and busy obj via MPL
  2. 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:

  1. Making MPL pluggable to allow integration with stevedores
  2. Moving the mentioned allocation cases to MPL

The advantages, in my mind, would be:

  1. 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).
  2. This could, I think, improve efficiency of the respective operations.

nigoroll avatar Jun 19 '25 13:06 nigoroll