diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57ec24017..45a7b9446 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,7 +68,7 @@ jobs: - name: Build if: matrix.os == 'windows-latest' || matrix.os == 'macos-latest' - run: cargo build --release --locked + run: cargo build --profile production --locked - name: Build static binary if: matrix.os == 'ubuntu-latest' @@ -78,6 +78,6 @@ jobs: uses: svenstaro/upload-release-action@v1-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/release/${{ matrix.artifact_name }} + file: target/production/${{ matrix.artifact_name }} asset_name: ${{ matrix.asset_name }} tag: ${{ github.ref }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c3898213..78d98f831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ - Fix the `proj_tags` cmd list under Vim. #796 - No syntax highlight for `c` preview. #800 +## Improved + +- Better performance for the pre-built binary. #804 + ## Changed - Set `g:clap_builtin_fuzzy_filter_threshold` to `0` to always use the async `on_typed` implementation which is full-featured using the Rust backend. diff --git a/Cargo.toml b/Cargo.toml index 1dc3ac395..d72ec7523 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,3 +18,13 @@ maple_cli = { path = "crates/maple_cli" } [build-dependencies] built = { package = "built", version = "0.5", features = ["git2"] } + +[profile.production] +inherits = "release" + +# Sacrifice compile speed for execution speed by using optimization flags: + +# https://doc.rust-lang.org/rustc/linker-plugin-lto.html +lto = "fat" +# https://doc.rust-lang.org/rustc/codegen-options/index.html#codegen-units +codegen-units = 1 diff --git a/ci/build_static_binary.sh b/ci/build_static_binary.sh index 98016d72f..51909e7fd 100644 --- a/ci/build_static_binary.sh +++ b/ci/build_static_binary.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +PROFILE=production + # Install Docker sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common @@ -10,9 +12,9 @@ sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker --version docker pull clux/muslrust -docker run -v $PWD:/volume --rm -t clux/muslrust cargo build --release --locked +docker run -v $PWD:/volume --rm -t clux/muslrust cargo build --profile $PROFILE --locked mkdir -p target/release -sudo cp target/x86_64-unknown-linux-musl/release/maple target/release/maple +sudo cp target/x86_64-unknown-linux-musl/$PROFILE/maple target/$PROFILE/maple -./target/release/maple version +./target/$PROFILE/maple version