Nightly Gas Costs Benchmark #380
This file contains hidden or 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
| name: Nightly Gas Costs Benchmark | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| env: | |
| GIT_REPO: ${{ github.repository }} | |
| GIT_REPO_NAME: ${{ github.event.repository.name }} | |
| CARGO_TERM_COLOR: always | |
| RUST_VERSION: 1.81.0 | |
| CONSENSUS_PARAMETERS_VERSION: V2 | |
| jobs: | |
| benchmark: | |
| runs-on: | |
| group: fuelcore-benchmark | |
| concurrency: | |
| group: fuelcore-benchmark # only allow one benchmark run at a time | |
| cancel-in-progress: false | |
| outputs: | |
| benchmark_results: ${{ steps.benchmarks.outputs.benchmark_results }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Rust Toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_VERSION }} | |
| targets: "wasm32-unknown-unknown" | |
| - name: Install criterion | |
| run: cargo install cargo-criterion | |
| - name: Cache | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run benchmarks | |
| id: run_benchmarks | |
| run: | | |
| cargo criterion -p fuel-core-benches --message-format json --bench vm > nightly_benchmarks.json | |
| cargo run -p fuel-core-benches --bin collect --release -- --input nightly_benchmarks.json --format consensus-parameters --output nightly_benchmarks.json | |
| - name: Archive benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nightly_benchmarks.json | |
| path: nightly_benchmarks.json | |
| - name: Set benchmark result output | |
| id: benchmarks | |
| run: | # this will fail when consensus parameters version changes | |
| echo "benchmark_results=$(cat nightly_benchmarks.json | jq '.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs' | tr -d '\n' )" >> "$GITHUB_OUTPUT" | |
| create_pr: | |
| needs: benchmark | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Parse benchmark results and create/update PR | |
| run: | | |
| # Update benchmark results in chain config | |
| jq --argjson benchmark_results "$benchmark_results" \ | |
| '.consensus_parameters.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs = $benchmark_results' \ | |
| bin/fuel-core/chainspec/local-testnet/chain_config.json > \ | |
| bin/fuel-core/chainspec/local-testnet/chain_config.json.tmp && \ | |
| mv bin/fuel-core/chainspec/local-testnet/chain_config.json.tmp bin/fuel-core/chainspec/local-testnet/chain_config.json | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| branch_name="chore/nightly-benchmark-updates" | |
| # Check if PR already exists | |
| pr_number=$(gh pr list --head "$branch_name" --base master --json number --jq '.[0].number') | |
| git add bin/fuel-core/chainspec/local-testnet/chain_config.json | |
| git commit -m "chore: update nightly benchmark results - $(date -u +%Y-%m-%d)" | |
| if [ -n "$pr_number" ]; then | |
| echo "PR #$pr_number already exists. Updating..." | |
| git fetch origin "$branch_name" | |
| git checkout -B "$branch_name" | |
| git push origin "$branch_name" --force | |
| # Update PR body with latest timestamp | |
| gh pr edit "$pr_number" \ | |
| --body "## Nightly Benchmark Results | |
| This PR is automatically updated every night with the latest benchmark results. | |
| **Last Updated:** $(date -u +"%Y-%m-%d %H:%M:%S UTC") | |
| ### Changes | |
| - Updated gas costs in \`bin/fuel-core/chainspec/local-testnet/chain_config.json\` | |
| - Consensus Parameters Version: \`${{ env.CONSENSUS_PARAMETERS_VERSION }}\` | |
| **Note:** This PR is for tracking performance changes and should not be merged." | |
| else | |
| echo "No existing PR found. Creating new PR..." | |
| git checkout -b "$branch_name" | |
| git push origin "$branch_name" | |
| # Create new PR | |
| gh pr create \ | |
| --title "chore(gas_costs): nightly benchmark results tracking" \ | |
| --body "## Nightly Benchmark Results | |
| This PR is automatically updated every night with the latest benchmark results. | |
| **Last Updated:** $(date -u +"%Y-%m-%d %H:%M:%S UTC") | |
| ### Changes | |
| - Updated gas costs in \`bin/fuel-core/chainspec/local-testnet/chain_config.json\` | |
| - Consensus Parameters Version: \`${{ env.CONSENSUS_PARAMETERS_VERSION }}\` | |
| **Note:** This PR is for tracking performance changes and should not be merged." \ | |
| --base master \ | |
| --head "$branch_name" \ | |
| --label "no changelog" | |
| fi | |
| env: | |
| benchmark_results: ${{ needs.benchmark.outputs.benchmark_results }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |