Skip to content

Commit

Permalink
ci: add ecosystem benchmark (#8868)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykingxyz authored Dec 27, 2024
1 parent 6f12327 commit ce4758a
Showing 1 changed file with 157 additions and 0 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/ecosystem-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: ecosystem-benchmark

on:
workflow_dispatch:
inputs:
pr:
type: number
description: "Run Benchmark PR number"
required: true
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "website/**"
tags-ignore:
- "**"

jobs:
get-runner-labels:
name: Get Runner Labels
uses: ./.github/workflows/get-runner-labels.yml

build:
name: Test Linux
needs: [get-runner-labels]
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-unknown-linux-gnu
native: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS == '"ubuntu-22.04"' }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
ref: ${{ github.event_name == 'workflow_dispatch' && format('pull/{0}/head', inputs.pr) || github.sha }}
test: false
bench: false

create-comment:
runs-on: ubuntu-latest
outputs:
comment-id: ${{ steps.create-comment.outputs.result }}
steps:
- id: create-comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const body = `⏳ Triggered benchmark: ${urlLink}`
if (context.eventName === 'workflow_dispatch') {
const { data: comment } = await github.rest.issues.createComment({
issue_number: context.payload.inputs.pr,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
return comment.id
}
const { data: comment } = await github.rest.repos.createCommitComment({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
return comment.id
bench:
needs: [build]
runs-on: [self-hosted, benchmark]
outputs:
diff-result: ${{ steps.run-benchmark.outputs.diff-result }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && format('pull/{0}/head', inputs.pr) || github.sha }}

- name: Clean
uses: ./.github/actions/clean
with:
target: x86_64-unknown-linux-gnu

- name: Download bindings
uses: ./.github/actions/download-artifact
with:
name: bindings-x86_64-unknown-linux-gnu
path: crates/node_binding/
try-local-cache: false

- name: Show restored binding
shell: bash
run: ls -lah crates/node_binding/*.node

- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache

- name: Build JS
run: pnpm run build:js

- name: Run rspack-ecosystem-benchmark
id: run-benchmark
run: |
RSPACK_DIR=$(pwd)
git clone --single-branch --depth 1 https://github.com/web-infra-dev/rspack-ecosystem-benchmark.git
cd rspack-ecosystem-benchmark
pnpm i
RSPACK_DIR="$RSPACK_DIR" node bin/cli.js bench
result=$(node bin/cli.js compare --base latest --current current)
echo "$result"
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
comment-compare-results:
runs-on: ubuntu-latest
needs: [create-comment, bench]
if: ${{ !cancelled() }}
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const diffResult = `${{ needs.bench.outputs.diff-result }}`
let result = "task ${{ needs.bench.result }}"
if (diffResult) {
result = diffResult.replace(/@@/g, "\n");
}
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const body = `
📝 Benchmark detail: ${urlLink}
${result}
`
if (context.eventName === 'workflow_dispatch') {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: `${{ needs.create-comment.outputs.comment-id }}`,
body
})
} else {
await github.rest.repos.updateCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: `${{ needs.create-comment.outputs.comment-id }}`,
body,
});
}
if (result.includes("Threshold exceeded")) {
console.log("Some benchmark cases exceed the threshold, please visit the previous step for more information");
process.exit(1);
}

1 comment on commit ce4758a

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on ce4758a Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-12-27 170b877) Current Change
10000_big_production-mode_disable-minimize + exec 37.9 s ± 592 ms 38.4 s ± 462 ms +1.44 %
10000_development-mode + exec 1.86 s ± 25 ms 1.82 s ± 20 ms -2.54 %
10000_development-mode_hmr + exec 682 ms ± 12 ms 684 ms ± 29 ms +0.18 %
10000_production-mode + exec 2.5 s ± 32 ms 2.46 s ± 40 ms -1.76 %
arco-pro_development-mode + exec 1.76 s ± 46 ms 1.76 s ± 77 ms +0.28 %
arco-pro_development-mode_hmr + exec 377 ms ± 0.82 ms 377 ms ± 0.68 ms -0.03 %
arco-pro_production-mode + exec 3.62 s ± 91 ms 3.61 s ± 105 ms -0.19 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.67 s ± 53 ms 3.68 s ± 96 ms +0.29 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.62 s ± 114 ms 3.67 s ± 80 ms +1.24 %
threejs_development-mode_10x + exec 1.51 s ± 11 ms 1.52 s ± 26 ms +0.16 %
threejs_development-mode_10x_hmr + exec 790 ms ± 33 ms 772 ms ± 9.4 ms -2.29 %
threejs_production-mode_10x + exec 5.4 s ± 129 ms 5.35 s ± 52 ms -0.92 %
10000_big_production-mode_disable-minimize + rss memory 9505 MiB ± 278 MiB 9519 MiB ± 69.5 MiB +0.15 %
10000_development-mode + rss memory 653 MiB ± 10.9 MiB 686 MiB ± 23.2 MiB +5.06 %
10000_development-mode_hmr + rss memory 1451 MiB ± 170 MiB 1514 MiB ± 347 MiB +4.39 %
10000_production-mode + rss memory 628 MiB ± 25.7 MiB 685 MiB ± 23.3 MiB +9.00 %
arco-pro_development-mode + rss memory 578 MiB ± 26.7 MiB 606 MiB ± 24.4 MiB +4.94 %
arco-pro_development-mode_hmr + rss memory 610 MiB ± 104 MiB 656 MiB ± 30.7 MiB +7.55 %
arco-pro_production-mode + rss memory 731 MiB ± 44.6 MiB 759 MiB ± 59.2 MiB +3.83 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 745 MiB ± 71.9 MiB 749 MiB ± 41.7 MiB +0.48 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 759 MiB ± 30.2 MiB 755 MiB ± 58.3 MiB -0.56 %
threejs_development-mode_10x + rss memory 594 MiB ± 12.2 MiB 638 MiB ± 19 MiB +7.45 %
threejs_development-mode_10x_hmr + rss memory 1171 MiB ± 171 MiB 1140 MiB ± 193 MiB -2.60 %
threejs_production-mode_10x + rss memory 873 MiB ± 52.4 MiB 903 MiB ± 42.6 MiB +3.38 %

Please sign in to comment.