MUSL vs GLIBC what do you prefer?

If one wonders what's better performance wise on a common high-end router nowadays (2x1+GHz cpu, 512 MB RAM) MUSL or GLIBC, not taking into account size of resulting binaries, what would you choose?

I've seen comparison here, but it seems outdated.

1 Like

I'd choose musl, to remain compatible with the repositories. I'd also trust musl's security track record a little bit morem, but ymmv.

Glibc is obviously faster. Musl is not meant to be fast.

1 Like

This is most likely going to boil down to arch, compiler and application. My personal guess would be that musl is going to be faster on architectures with small cache (mips, arm) in general while x86/amd64 probably benefits from glibc. Keep in mind that the toolchain enforces compiler flag -Os which may no be ideal in terms of performance. Looking at musl's repo it suggests that you use O2 and/or O3, I don't have any numbers but I think you can safely assume that someone made benchmarks to come up with that setup. (small patch to override toolchain)
There are also a few more performance hacks in that branch which works fine for me(tm).

Also as jow pointed out, being that musl is the default library not a lot of stuff is tested against glibc however as glibc is the default library in most major Linux distributions compatibility is high however there are some musl specific fixes/hacks which may break using glibc.

Depending on your workload it may also be of interest to switch malloc implementation which can improve overall performance quite a bit and of course also result in performance regression.

Here are some interesting results for instance:

2 Likes very interesting. I know glibc has x86 and ARM specific optimizations but didn't know musl had the potential to be faster. I guess this is something that needs to be tested on a per arch basis.