-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(ci): Configure codspeed #76884
base: canary
Are you sure you want to change the base?
Changes from all commits
de2de3e
c8cef89
35e4f61
499dfa4
9a97fff
e16abbe
98537f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Benchmark | ||
|
||
on: | ||
push: | ||
branches: | ||
- canary | ||
paths: | ||
- '**/crates/**' | ||
pull_request: | ||
types: ['labeled'] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.sha }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
env: | ||
CI: 1 | ||
CARGO_INCREMENTAL: 0 | ||
# For faster CI | ||
RUST_LOG: 'off' | ||
# https://github.com/actions/setup-node/issues/899#issuecomment-1819151595 | ||
SKIP_YARN_COREPACK_CHECK: 1 | ||
|
||
jobs: | ||
list-crates: | ||
name: List crates to benchmark | ||
runs-on: | ||
- 'self-hosted' | ||
- 'linux' | ||
- 'x64' | ||
- 'metal' | ||
if: ${{ github.event.label.name == 'benchmark' }} | ||
outputs: | ||
crates: ${{ steps.list-crates.outputs.crates }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: List crates | ||
id: list-crates | ||
run: echo "crates=$(./scripts/cargo/bench/list-crates-with-bench.sh)" >> $GITHUB_OUTPUT | ||
|
||
benchmark-crate: | ||
name: Benchmark ${{ matrix.crate }} | ||
runs-on: ubuntu-22.04 | ||
needs: list-crates | ||
strategy: | ||
matrix: | ||
crate: ${{fromJson(needs.list-crates.outputs.crates)}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do something to limit this parallelism? I'm concerned that we could end up with a lot of crates over time, and sharding has some cost and reliability tradeoffs. For tests, we divide between a fixed number of workers. Tests have a complicated system that takes into account timings from previous executions that @ijjk wrote to reduce latency, but we can do something simple here for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. I'll think a bit more about this. (I'm not sure how should I split it) |
||
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] | ||
|
||
- name: Build the benchmark target(s) | ||
run: cargo codspeed build -p ${{ matrix.crate }} | ||
|
||
- name: Run the benchmarks | ||
uses: CodSpeedHQ/action@v3 | ||
with: | ||
run: cargo codspeed run | ||
token: ${{ secrets.CODSPEED_TOKEN }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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)]' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
|
||
WS_CRATES="$("$SCRIPT_DIR"/get-workspace-crates.sh)" | ||
echo "$WS_CRATES" | jq -r -c '[.[] | select(.targets[] | .kind | contains(["bench"])) | .name] | sort | unique' | jq -r -c '[.[] | select(. != "napi" and . != "wasm")]' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know enough to say there's a problem here, but it seems suspicious that you're piping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤣 It was copied from https://github.com/swc-project/swc/blob/15ea059712f6726d52b6304870f337a93272bb53/scripts/cargo/get-workspace-crates-json.sh (very old script) and https://github.com/swc-project/swc/blob/15ea059712f6726d52b6304870f337a93272bb53/scripts/bench/list-crates-with-bench.sh (relatively young script) I decided to simply call the old script while writing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, if you mean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider using
build_reusable.yml
to handle stuff like this, but that's not a blocker and can be a longer-term follow-up. https://github.com/search?q=repo%3Avercel%2Fnext.js%20build_reusable&type=codeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! I didn't know that such thing is possible in GH Actions