-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(bench): Run benchmark on a custom runner (#9877)
**Description:** I configured one custom runner using https://github.com/myoung34/docker-github-actions-runner that has 16 cores and 64GB RAM. It's much quieter than a public GitHub runner, so I'll rely on this for profiling.
- Loading branch information
Showing
7 changed files
with
93 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,65 +24,27 @@ env: | |
SKIP_YARN_COREPACK_CHECK: 1 | ||
|
||
jobs: | ||
# list-crates: | ||
# if: >- | ||
# ${{ !contains(github.event.head_commit.message, 'chore: ') }} | ||
# name: List crates | ||
# runs-on: ubuntu-latest | ||
# outputs: | ||
# crates: ${{ steps.list-crates.outputs.crates }} | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
|
||
# - name: Install Rust | ||
# uses: actions-rs/toolchain@v1 | ||
# with: | ||
# profile: minimal | ||
|
||
# - name: List crates | ||
# id: list-crates | ||
# run: echo "crates=$(./scripts/cargo/get-crates.sh)" >> $GITHUB_OUTPUT | ||
|
||
# bench-crate: | ||
# name: Bench ${{ matrix.crate }} | ||
# runs-on: ubuntu-latest | ||
# needs: | ||
# - list-crates | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# crate: ${{fromJson(needs.list-crates.outputs.crates)}} | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
|
||
# - name: Install Rust | ||
# uses: actions-rs/toolchain@v1 | ||
# with: | ||
# profile: minimal | ||
|
||
# - uses: ./.github/actions/setup-node | ||
|
||
# - name: Setup rust toolchain, cache and cargo-codspeed binary | ||
# uses: moonrepo/setup-rust@v0 | ||
# with: | ||
# channel: stable | ||
# cache-target: release | ||
# bins: cargo-codspeed | ||
|
||
# - name: Build the benchmark target(s) | ||
# run: cargo codspeed build -p ${{ matrix.crate }} | ||
|
||
# - name: Run the benchmarks | ||
# uses: CodSpeedHQ/action@v2 | ||
# with: | ||
# run: cargo codspeed run -p ${{ matrix.crate }} | ||
# token: ${{ secrets.CODSPEED_TOKEN }} | ||
|
||
bench-all: | ||
name: Bench everything | ||
list-crates: | ||
if: >- | ||
${{ !contains(github.event.head_commit.message, 'chore: ') }} | ||
name: List crates to benchmark | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
crates: ${{ steps.list-crates.outputs.crates }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: List crates | ||
id: list-crates | ||
run: echo "crates=$(./scripts/bench/list-crates-with-bench.sh)" >> $GITHUB_OUTPUT | ||
|
||
build-crate: | ||
name: Build benchmark for ${{ matrix.crate }} | ||
runs-on: ubuntu-22.04 | ||
needs: list-crates | ||
strategy: | ||
matrix: | ||
crate: ${{fromJson(needs.list-crates.outputs.crates)}} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
|
@@ -91,18 +53,65 @@ jobs: | |
with: | ||
profile: minimal | ||
|
||
- uses: ./.github/actions/setup-node | ||
- uses: Swatinem/rust-cache@v2 | ||
# Some crates are too slow to build | ||
if: matrix.crate == 'swc' | ||
with: | ||
shared-key: "bench-${{ matrix.crate }}" | ||
key: "bench-${{ matrix.crate }}" | ||
cache-all-crates: true | ||
|
||
- name: Install cargo-codspeed | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: [email protected] | ||
|
||
- name: Build the benchmark target(s) | ||
run: ./scripts/bench/build-all-crates.sh | ||
run: ./scripts/bench/build-crate.sh ${{ matrix.crate }} | ||
|
||
- name: Upload built artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: bench-${{ matrix.crate }} | ||
path: target/codspeed | ||
|
||
bench-all: | ||
name: Run benchmarks | ||
needs: build-crate | ||
runs-on: | ||
- self-hosted | ||
- linux | ||
- x64 | ||
if: >- | ||
${{ !contains(github.event.head_commit.message, 'chore: ') }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
|
||
- name: Install cargo-codspeed | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: [email protected] | ||
|
||
- run: mkdir -p target/codspeed | ||
|
||
- name: Download built artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: bench-* | ||
path: target/codspeed | ||
merge-multiple: true | ||
|
||
- run: ls -alR target/codspeed | ||
|
||
- run: chmod -R +x target/codspeed/* | ||
|
||
- name: Run the benchmarks | ||
uses: CodSpeedHQ/action@v2 | ||
uses: CodSpeedHQ/action@v3 | ||
with: | ||
run: cargo codspeed run | ||
token: ${{ secrets.CODSPEED_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
crate=$1 | ||
|
||
# If crate has feature 'concurrent', build it with feature | ||
if [[ $(./scripts/cargo/list-features.sh $crate) == *"concurrent"* ]]; then | ||
echo "Building $crate with feature 'concurrent'" | ||
cargo codspeed build -p $crate --features concurrent | ||
else | ||
echo "Building $crate" | ||
cargo codspeed build -p $crate | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
WS_CRATES=$(./scripts/cargo/get-workspace-crates-json.sh) | ||
echo "$WS_CRATES" | jq -r -c '[.[] | select(.targets[] | .kind | contains(["bench"])) | .name] | sort | unique' | jq -r -c '[.[] | select(. != "swc_plugin_runner")]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
cargo metadata --format-version 1 --no-deps | jq -r -j '[.packages[] | select(.source == null and .name != "xtask")]' |