diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8615f7b3..ca333e87c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,7 @@ on: env: DEVELOPER_DIR: /Applications/Xcode_26.0.1.app RELEASE_BRANCH: release/${{ inputs.version }} + MIMALLOC_VERSION: 3.0.10 jobs: setup-credentials: @@ -144,21 +145,39 @@ jobs: persist-credentials: false - name: Install SDK run: swift sdk install https://download.swift.org/swift-6.2-release/static-sdk/swift-6.2-RELEASE/swift-6.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum d2225840e592389ca517bbf71652f7003dbf45ac35d1e57d98b9250368769378 + - name: Build mimalloc object + run: | + set -euxo pipefail + curl -sSfL "https://github.com/microsoft/mimalloc/archive/refs/tags/v${MIMALLOC_VERSION}.tar.gz" | tar xz + export CC=clang + cmake -S "mimalloc-${MIMALLOC_VERSION}" -B mimalloc-build \ + -DMI_BUILD_SHARED=OFF \ + -DMI_BUILD_STATIC=ON \ + -DMI_BUILD_OBJECT=OFF \ + -DCMAKE_BUILD_TYPE=Release + cmake --build mimalloc-build --target mimalloc-static - name: Build static binary run: | + # To improve performance with musl, increase the stack size to 512KiB and + # replace musl's default allocator with mimalloc. swift build \ -c release \ --product swiftlint \ --swift-sdk ${{ matrix.swift_sdk }} \ -Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT \ - -Xlinker -z -Xlinker stack-size=0x80000 # 512KiB + -Xlinker -z -Xlinker stack-size=0x80000 \ + -Xlinker --whole-archive \ + -Xlinker ./mimalloc-build/libmimalloc.a \ + -Xlinker --no-whole-archive - name: Strip binary run: strip -s "$BINARY_PATH" - name: Upload artifact uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: name: ${{ matrix.artifact_name }} - path: ${{ env.BINARY_PATH }} + path: | + ${{ env.BINARY_PATH }} + mimalloc-build/LICENSE build-macos: name: Build macOS Binaries @@ -214,6 +233,9 @@ jobs: mv -f swiftlint-linux-arm64/swiftlint swiftlint_linux_arm64 mv -f swiftlint-static-amd64/swiftlint swiftlint_static_amd64 mv -f swiftlint-static-arm64/swiftlint swiftlint_static_arm64 + + # Just pick one of the licenses. + mv -f swiftlint-static-amd64/LICENSE LICENSE.mimalloc - name: Make binaries executable run: chmod +x swiftlint* - name: Create artifacts diff --git a/CHANGELOG.md b/CHANGELOG.md index c075db1e2..be19df5b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,11 @@ [nandhinisubbu](https://github.com/nandhinisubbu) [#6161](https://github.com/realm/SwiftLint/issues/6161) +* Adopt [mimalloc](https://github.com/microsoft/mimalloc) for static Linux binary + to improve performance. + [ainame](https://github.com/ainame) + [#6298](https://github.com/realm/SwiftLint/issues/6298) + ### Bug Fixes * Fix false positive with `#Preview` macro in `closure_end_indentation` rule. diff --git a/Makefile b/Makefile index c8b788487..33adea7ed 100644 --- a/Makefile +++ b/Makefile @@ -119,11 +119,11 @@ zip_linux_release: swiftlint_linux_amd64 swiftlint_linux_arm64 swiftlint_static_ $(eval TMP_FOLDER := $(shell mktemp -d)) cp -f swiftlint_linux_amd64 "$(TMP_FOLDER)/swiftlint" cp -f swiftlint_static_amd64 "$(TMP_FOLDER)/swiftlint-static" - cp -f LICENSE "$(TMP_FOLDER)" - (cd "$(TMP_FOLDER)"; zip -yr - "swiftlint" "swiftlint-static" "LICENSE") > "./swiftlint_linux_amd64.zip" + cp -f LICENSE LICENSE.mimalloc "$(TMP_FOLDER)" + (cd "$(TMP_FOLDER)"; zip -yr - "swiftlint" "swiftlint-static" "LICENSE" "LICENSE.mimalloc") > "./swiftlint_linux_amd64.zip" cp -f swiftlint_linux_arm64 "$(TMP_FOLDER)/swiftlint" cp -f swiftlint_static_arm64 "$(TMP_FOLDER)/swiftlint-static" - (cd "$(TMP_FOLDER)"; zip -yr - "swiftlint" "swiftlint-static" "LICENSE") > "./swiftlint_linux_arm64.zip" + (cd "$(TMP_FOLDER)"; zip -yr - "swiftlint" "swiftlint-static" "LICENSE" "LICENSE.mimalloc") > "./swiftlint_linux_arm64.zip" package: swiftlint $(eval PACKAGE_ROOT := $(shell mktemp -d))