-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
Bug Description
0.61.0 introduced experimental fully static Linux binary with Static Linux SDK. I fixed its crash issue #6287 and 0.62.1 was released. But it looks like the performance is significantly slow #6291 (comment)
This is not formal benchmark but static Linux binary is about 3 time slower than just normal release build on my end (Ubuntu Desktop 24.04 on VMware running on M4 Max with 8 cores/16GB memory allocated).
# v0.62.1 binary downloaded from GitHub Release
ainame@ainame-vm:~/repos/SwiftLint$ time ./swiftlint-static --no-cache 2&>1 /dev/null
real 0m4.300s
user 0m13.376s
sys 0m10.517s
# Normal release build at main branch 32cf983
# swift build --product swiftlint -c release -Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT
ainame@ainame-vm:~/repos/SwiftLint$ time .build/aarch64-unknown-linux-gnu/release/swiftlint --no-cache 2&>1 > /dev/null
real 0m1.353s
user 0m6.682s
sys 0m0.127s
I suppose this is kind of expected that musl's allocator seems to be known as slow and found many Rust devs complaint about it.
https://nickb.dev/blog/default-musl-allocator-considered-harmful-to-performance/
nextstrain/nextclade#1338
In fact, when I just gave https://github.com/microsoft/mimalloc a try, it is as performant as normal release build. That said, it's better to get some benchmark/profile before introducing something new.
sudo apt-get install -y musl-tools cmake
git clone https://github.com/microsoft/mimalloc.git
cd mimalloc/
CC=musl-gcc CFLAGS="-O3" cmake -B build -DMI_BUILD_STATIC=ON -DMI_BUILD_SHARED=OFF
cmake --build build -j
cp build/libmimalloc.a ../SwiftLint/
ainame@ainame-vm:~/repos/SwiftLint$ swift build --product swiftlint \
-c release \
-Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT \
--swift-sdk x86_64-swift-linux-musl \
-Xlinker -z -Xlinker stack-size=0x80000 \
-Xlinker ~/repos/SwiftLint/libmimalloc.a
ainame@ainame-vm:~/repos/SwiftLint$ time .build/aarch64-swift-linux-musl/release/swiftlint --no-cache 2&>1 > /dev/null
real 0m1.462s
user 0m7.844s
sys 0m0.123s
Environment
- SwiftLint version 0.62.1
- Xcode version N/A
- Configuration file: N/A