Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .github/workflows/nightly-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,55 @@ 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@v4

- 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: 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
echo "benchmark_results=$(cat nightly_benchmarks.json | tr -d '\n' | jq '.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs')" >> "$GITHUB_OUTPUT" # this will fail when consensus parameters version changes

- 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
if: ${{ github.event.inputs.create_pr == 'true' }}
permissions:
pull-requests: write

if: ${{ github.event.inputs.create_pr == 'true' || github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- run: |
jq --argjson benchmark_results "$benchmark_results" \
'.consensus_parameters.${{ env.CONSENSUS_PARAMETERS_VERSION }}.gas_costs = $benchmark_results' \
Expand All @@ -55,7 +80,6 @@ jobs:
branch_name="chore/benchmark-update-$(date +%s)"
git checkout -b "$branch_name"
git add 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'
git commit -m "Update benchmark results"
Expand Down
Loading