-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alpine has dropped jemalloc due to no support. #1443
Comments
I don't think there's much we can do here; the underlying issue is an incompatibility between jemalloc and the musl libc (that Alpine uses); musl would have to make a design decision to support replacing the allocator on its end. That would require extra work on musl's end, and it's not clear to me that the cost/benefit ratio is there for them; part of its pitch is its simplicity and lightweight design. If you persuade them that they should support malloc replacement as a feature, I'm willing to help with bootstrapping issues on our end; but making this work isn't really just a question of writing code. |
Thanks for the additional detail. |
No problem! Closing this for now, but happy to take a new issue if something changes that makes this feasible. |
FYI: Recently, I wrote on musl mainling list and they confirm that musl supports usage of external malloc function. |
OK, I'll add this to the queue. This is a very busy time for us, but I'll come back to it when I get a chance. |
For what it's worth, I was able to build jemalloc 5.2.1 on alpine 3.11 with no issues and ruby seems to use it just fine with Sample Dockerfile: FROM ruby:2.7-alpine AS builder
RUN apk add build-base
RUN wget -O - https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2 | tar -xj && \
cd jemalloc-5.2.1 && \
./configure && \
make && \
make install
FROM ruby:2.7-alpine
COPY --from=builder /usr/local/lib/libjemalloc.so.2 /usr/local/lib/
ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so.2 |
The only thing, and that's because I'm not an expert I can't see ruby using jemalloc with @thedanbob docker build running Perhaps I'm missing something else to make it work. |
Apparently, ruby can't see jemalloc (even though it's working) when you use MALLOC_CONF=stats_print:true ruby -e "exit" |
Can confirm and think that this issue could probably be closed (?) |
I believe that musl now supports malloc replacement, and my understanding is that jemalloc + musl now "just works". I was keeping this open until I had verified it myself, but I've seen enough people report it working that I figure it must be at least mostly OK. Closing, but still happy to field reports of breakages if they arise. |
try to execute |
On alpine 3.10 using docker image
Any command the output is always empty (unless CONFIG['LIBS']. I guess jemalloc is not loaded :( |
I tried the same and can confirm that trying to load jemalloc in |
What I did for now is use this docker image instead:
It has already ruby 2.5.7 compiled with jemalloc. It works like a charm, what I don't like however is taht is a much heavier image. But I just wanted to confirm if jamalloc offer me some performance improvement so it will work for now. |
Was trying to enable leak profiling using jemalloc on Alpine Linux 3.11.11, but it just hangs. Without "--enable-debug --enable-prof" configure options to jemalloc, the command completes. Is this expected? Even tried Alpine 3.13.5 without any success. Any helpful pointers much appreciated.
tried with ./configure --enable-debug --enable-prof --disable-prof-libgcc and the program segfaults. Issue seen in Alpine 3.13.5 as well
|
Wanted to follow up and ask if anyone has gotten jemalloc running on a baseimage without jemalloc precompiled into ruby? Based on this conversation, it doesn't sound like we have. I have tried thedanbob's suggestion and that doesn't work. I've also seen that solution provided elsewhere, and seems ruby doesn't recognize or acknowledge the LD_PRELOAD variable. |
I think there is still no support of Jemalloc and Alpine. |
There is support for Jemalloc in Alpine, at least on 3.18. Everything I read said it would be hard or near impossible but in reality it was as easy as this:
Version 5 no less!
|
Alpine restored support for jemalloc in 2022: https://gitlab.alpinelinux.org/alpine/aports/-/commit/e764db77406d02df1e6ee627daa808837c1a81ce Edit: there's some useful info in this gist: https://gist.github.com/jjb/9ff0d3f622c8bbe904fe7a82e35152fc apk add ruby jemalloc patchelf
patchelf --add-needed libjemalloc.so.2 /usr/bin/ruby
apk del patchelf
MALLOC_CONF=stats_print:true ruby -e "exit" |
There are related issues with alpine and libjemalloc running ruby.
I'd like to start using jemalloc on my ruby docker containers but it seems to be missing some engagement with the community over there.
The text was updated successfully, but these errors were encountered: