Skip to content

Commit

Permalink
Production profile for better performance (#804)
Browse files Browse the repository at this point in the history
* Production profile for better performance

* Update CHANGELOG.md
  • Loading branch information
liuchengxu authored Feb 20, 2022
1 parent 7310cc8 commit c4d7f0c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions ci/build_static_binary.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit c4d7f0c

Please sign in to comment.