Live data from Hacker News

Why does musl make my Rust code so slow?

andygrove.io

1–10 of 77 posts

Re: Why does musl make my Rust code so slow?

#4
This actually someone asking and not an investigation and explanation. There isn't even a lot of due diligence to figuring it out - no profiling or resource usage other than CPUs. Also it is musl combined with docker causing a 30x slowdown.

If something is running 30x slower from linking in a different libc, I'm guessing it should not be that difficult to narrow down the cause at least a little bit.

Re: Why does musl make my Rust code so slow?

#7
post #3

Swap out the allocator https://users.rust-lang.org/t/optimizing-rust-binaries-obser...

Without familiarity with rust, I wasn't sure what they meant by "system allocator". Apparently that means libc's malloc. (Or HeapAlloc on Windows)

So I guess they statically link jemalloc but can optionally use libc malloc.

Re: Why does musl make my Rust code so slow?

#10
post #2

Swapping out the allocator for jemalloc would be my first try. It's easy to do and often results in better performance. 30x requires some kind of pathological case though.

In a commercial product I worked on I went against the vendors advice to try out jemalloc. It took a 100GB memory hold (that took 48 hours to happen) to staying steady at around 2-4GB and only peaking at 100GB for a few seconds a day.

Same exact code but just swapped out the jemalloc at the command line.

Post reply on HN