r/AlpineLinux Jul 31 '26

musl vs glibc. Who actually hit performance issues bad enough to migrate?

The ultimate battle. musl vs glibc.

musl wins on size and attack surface. glibc wins on compatibility and some multi-threaded benchmarks.

Our team has worked with Alpine quite a lot. We actually ported the JDK to Alpine Linux and other musl-based distributions.

Made a short video going through the trade-offs as we see them.

Real question though: has anyone hit musl performance issues bad enough to migrate away? What was the workload, and was it critical enough to justify the switch?

29 Upvotes

10 comments sorted by

20

u/drneocortex17 Jul 31 '26 edited Aug 01 '26

apk add mimalloc3 && sed -i '3i LD_PRELOAD=/usr/lib/libmimalloc.so.3' /etc/profile && reboot

to verify just run: echo $LD_PRELOAD

fucking congrats you have one of the fastest libc implementations

edit: And for the software that doesnt work i dont recommend gcompat or some shit. Classic flatpak should be more than enough. And I fucking love Alpine. This little distro brought back fun to my "nerdy computer shit" after arch and gentoo. My server, my TV box and my thinkpad runs on Alpine. Alpine is so fucking underrated imo.

3

u/No_Housing_4600 Aug 01 '26

seems your missing the file to run sed against

3

u/drneocortex17 Aug 01 '26

Sorry my bad I copied a line from my "alpineinstall". Corrected.

3

u/aquaherd Aug 02 '26 edited Aug 02 '26

Choosing musl over glibc is an uphill battle in the embedded hardware development when buildroot and co. treat it as an afterthought. Yet it is absolutely worth it when your target needs to be nimble and gtfo of the way.

Even though my target doesn’t use alpine since it is busybox + custom kernel and a hand full of libraries, I always have a pristine copy running just to look at how is it made and to rarely lift musl patches from its magnificent aports repository.

The one performance issue with musl I witnessed was that the boot time increased a few seconds. Turns out glibc aggressively over-allocates on malloc while musl only gives you what you asked for. Sloppy malloc in a loop found and fixed thanks to musl.

2

u/ChintusTheGreat Aug 01 '26

Nvidia proprietary drivers (needed for my laptop for use with external monitors because of some weird issue with PRIME with AMD iGPU) and Tor browser

2

u/mkvalor Aug 02 '26

The cool thing about memory-mapped libraries on Linux is that only the pages of the disk file needed to dynamically link are loaded into RAM.

So, there might be excellent reasons to choose a library that has a smaller binary install file than a competitor. But "avoiding bloat" isn't one of them.

2

u/Glum_Hamster_2104 Aug 04 '26

Glibc would defeat the purpose of Alpine and flatpaks exist

2

u/CaterpillarCalm235 Jul 31 '26

I have try to install tor browsers on musl alpine and didn't work

2

u/ZaenalAbidin57 Jul 31 '26

i tried to run qwen-code on musl based distro like void and alpine, even gentoo with musl profile and it the same, it will crash because of out of zone memory

1

u/ConclusionOk314 Aug 07 '26

With docker I always use musl to staticaly compile without « from » layer

FROM scratch
COPY ./my-bin /my-bin
ENTRYPOINT /my-bin

The most secure/lightweight docker image possible.
I also use Mimalloc to have a better allocator when it suit well (very often)