22

Why does musl make my Rust code so slow?

 3 years ago
source link: https://andygrove.io/2020/05/why-musl-extremely-slow/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

I’ve been running some benchmarks of my Ballista project lately. You can see the current results here . During this benchmarking work, I discovered that the Rust benchmarks were ridiculously slow. After some debugging, it turns out that this is due to the use of musl, and I’d love to understand what is going on.

The benchmark is packaged in Docker ( Dockerfile ) and I’m running these on a 24-core desktop using the command docker run --cpus=12 to allocate CPU usage, and I’m wondering if the issue is somehow specific to multi-threaded use of musl in Docker perhaps.

Without musl

If the Dockerfile contains the following, the benchmark takes around 5 seconds. System monitor shows some threads using 100% CPU for a short period of time.

RUN cargo build --release
ENTRYPOINT ["target/release/ballista-benchmarks"]

am2uauZ.png!web

With musl

If the Dockerfile contains the following, the benchmark takes around 30x longer. System monitor shows many threads using between 20% and 40% CPU for an extended period of time.

RUN cargo build --release --target x86_64-unknown-linux-musl
ENTRYPOINT ["target/x86_64-unknown-linux-musl/release/ballista-benchmarks"]

mYzAbiI.png!web

Can anyone help me understand what is going on here?

Join the discussion on /r/rust or Hacker News !

I will update this post with information received from these discussions!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK