This is a very quick gist I'm throwing together to get this info and discussion onto google in one place.
For years, people have been using jemalloc with ruby. There are various benchmarks and discussions. Some people say Jemalloc 5 doesn't work as well as Jemalloc 3.
Then, one day, hope appeared on the horizon. Someone offered a config for Jemalloc 5.
The recipe would be something like this (shown with official docker ruby image). I didn't try this yet, don't know if it will build!
FROM ruby:3.1.2-bullseye
RUN apt-get update ; \
apt-get install -y --no-install-recommends libjemalloc2 ;
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
# tradeoff between memory and performance
ENV MALLOC_CONF='narenas:2,background_thread:true,thp:never,dirty_decay_ms:1000,muzzy_decay_ms:0'
# more heavily memory-optimized, like jemalloc 3.6
# ENV MALLOC_CONF='narenas:2,background_thread:true,thp:never,dirty_decay_ms:0,muzzy_decay_ms:0'
- https://github.com/fullstaq-ruby/server-edition#vs-ld_preloading-jemalloc-yourself
- https://news.ycombinator.com/item?id=27873579
- https://bugs.ruby-lang.org/issues/14718
- comment from jemalloc dev: https://bugs.ruby-lang.org/issues/14718#note-86
- https://github.com/code-dot-org/code-dot-org/blob/staging/cookbooks/cdo-jemalloc/attributes/default.rb
- https://github.com/zooniverse/panoptes/pull/4027/files
- https://gist.github.com/jjb/81866452fd979cae81297cb28713b4bf
- https://www.paulashraf.com/blog/jemalloc-ruby
- https://github.com/SamSaffron/allocator_bench
- https://andresakata.medium.com/benchmark-of-memory-allocators-on-a-multi-threaded-ruby-program-354ec4dc2e7e
- https://engineering.appfolio.com/appfolio-engineering/2018/2/1/benchmarking-rubys-heap-malloc-tcmalloc-jemalloc
- https://twitter.com/wgjordan/status/1440574986264006659
- fullstaq-ruby/server-edition#98
- https://github.com/jemalloc/jemalloc/blob/dev/TUNING.md
- http://jemalloc.net/jemalloc.3.html
- https://bugs.ruby-lang.org/issues/15667
- bonus: building jemalloc 3 from source: jemalloc/jemalloc#2394