Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
47fd087
feat(benches): add Criterion benchmarks for historic scanning mode
yug49 Dec 13, 2025
329e2a4
Add latest events scanning benchmark
yug49 Dec 13, 2025
988adea
Update Cargo.lock
yug49 Dec 13, 2025
8ff77f3
feat(benches): optimize benchmarks and simplify BenchConfig API
yug49 Dec 17, 2025
fa67e5b
chore: update Cargo.lock with latest dependency versions
yug49 Dec 17, 2025
7ec2a3d
Merge branch 'OpenZeppelin:main' into feat/benchmarks
yug49 Dec 21, 2025
28c052c
feat: add Bencher CI integration for performance tracking
yug49 Dec 21, 2025
f7a3d81
fix: remove invalid --noplot flag from benchmark command
yug49 Dec 21, 2025
70c6b17
perf: run benchmarks in parallel jobs to avoid disk space issues
yug49 Dec 21, 2025
b8146e8
fix: add disk cleanup step to free space before benchmarks
yug49 Dec 21, 2025
a53baef
perf: reduce latest events benchmark from 100K to 50K events
yug49 Dec 21, 2025
e541a36
fix: correct Bencher integration for baseline tracking
yug49 Dec 21, 2025
651bf30
fix: use dynamic branch name in Bencher upload
yug49 Dec 21, 2025
44e4ead
fix: remove --ci-only flag from PR tracking workflow
yug49 Dec 21, 2025
d5d7e9e
Update .github/workflows/benchmarks.yml
yug49 Dec 22, 2025
4825627
Update .github/workflows/benchmarks.yml
yug49 Dec 22, 2025
6a1e923
Update .github/workflows/benchmarks.yml
yug49 Dec 22, 2025
6f036a4
Merge branch 'OpenZeppelin:main' into feat/benchmarks
yug49 Dec 22, 2025
23c741c
refactor: update benchmark config and remove PR workflows
yug49 Dec 22, 2025
dc8f23d
Update .github/workflows/benchmarks.yml
yug49 Dec 25, 2025
798f9c5
Merge branch 'OpenZeppelin:main' into feat/benchmarks
yug49 Dec 25, 2025
ec4ed63
Remove log count tracking and assertion from historic scanning benchmark
yug49 Dec 25, 2025
78ed3bd
Rename BenchCounter to Counter
yug49 Dec 25, 2025
97cc1d9
bench: add 5s warm-up time to benchmark groups
yug49 Dec 25, 2025
4b71d12
feat: use singleton tokio runtime in benchmarks
yug49 Dec 25, 2025
ae58054
refactor(benches): replace panics with proper error handling
yug49 Dec 26, 2025
29acfb8
Update .github/workflows/benchmarks.yml
yug49 Dec 26, 2025
089d5af
fix: make benchmark jobs consistent with dependency versions
yug49 Dec 26, 2025
bb81e8d
feat: add benchmarking system using anvil dump files
yug49 Dec 29, 2025
c84172d
fix: increase benchmark measurement time to 200s
yug49 Dec 29, 2025
6b5141c
Update benches/benches/historic_scanning.rs
yug49 Dec 29, 2025
202ee64
fix: restore .clone() for provider in historic benchmark
yug49 Dec 29, 2025
6e74b55
Update .github/workflows/benchmarks.yml
yug49 Jan 20, 2026
8a2dc23
Update .github/workflows/benchmarks.yml
yug49 Jan 20, 2026
0dbf27f
Update benches/dumps/state_100000.metadata.json
yug49 Jan 20, 2026
16642f6
fix: apply --err flag only on manual workflow dispatch
yug49 Jan 20, 2026
3b34076
refactor: remove unnecessary sleep before Anvil shutdown
yug49 Jan 20, 2026
afd1c48
chore: resolve merge conflicts
yug49 Jan 20, 2026
dac85ae
Merge branch 'main' into feat/benchmarks
yug49 Jan 20, 2026
18cfe68
fix: update benchmarks to use robust-provider as direct dependency
yug49 Jan 20, 2026
1181f46
fix: remove --err flag from benchmark workflow
yug49 Jan 21, 2026
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
144 changes: 144 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Benchmarks

# Runs benchmarks to track performance and detect regressions.
# - On push to main: automatically updates baseline in Bencher
# - On manual dispatch: run specific benchmarks on-demand

on:
push:
branches: [main]
paths:
# Only run benchmarks if relevant code changes
- "src/**"
- "benches/**"
- "Cargo.toml"
- "Cargo.lock"
workflow_dispatch:
inputs:
benchmark:
description: "Benchmark to run"
required: true
default: "all"
type: choice
options:
- all
- historic_scanning
- latest_events_scanning

permissions:
contents: read
checks: write

env:
CARGO_TERM_COLOR: always

jobs:
# Run historic benchmarks
benchmark_historic:
name: Run Historic Benchmarks
runs-on: ubuntu-latest
# Run on push to main, or when manually selecting 'all' or 'historic_scanning'
if: ${{ github.event_name == 'push' || inputs.benchmark == 'all' || inputs.benchmark == 'historic_scanning' }}

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit

- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf /usr/local/lib/android
df -h

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2

- name: Install Foundry (Anvil)
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

- name: Install Bencher CLI
uses: bencherdev/bencher@main

- name: Run historic benchmarks and track with Bencher
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT }}
run: |
bencher run \
--project "$BENCHER_PROJECT" \
--token "$BENCHER_API_TOKEN" \
--branch "${{ github.ref_name }}" \
--testbed ubuntu-latest \
--threshold-measure latency \
--threshold-test t_test \
--threshold-max-sample-size 64 \
--threshold-upper-boundary 0.99 \
--thresholds-reset \
--err \
--adapter rust_criterion \
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
"cargo bench --manifest-path benches/Cargo.toml --bench historic_scanning"

# Run latest events benchmarks
benchmark_latest:
name: Run Latest Events Benchmarks
runs-on: ubuntu-latest
# Run on push to main, or when manually selecting 'all' or 'latest_events_scanning'
if: ${{ github.event_name == 'push' || inputs.benchmark == 'all' || inputs.benchmark == 'latest_events_scanning' }}

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit

- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf /usr/local/lib/android
df -h

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2

- name: Install Foundry (Anvil)
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

- name: Install Bencher CLI
uses: bencherdev/bencher@main

- name: Run latest events benchmarks and track with Bencher
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT }}
run: |
bencher run \
--project "$BENCHER_PROJECT" \
--token "$BENCHER_API_TOKEN" \
--branch "${{ github.ref_name }}" \
--testbed ubuntu-latest \
--threshold-measure latency \
--threshold-test t_test \
--threshold-max-sample-size 64 \
--threshold-upper-boundary 0.99 \
--thresholds-reset \
--err \
--adapter rust_criterion \
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
"cargo bench --manifest-path benches/Cargo.toml --bench latest_events_scanning"
142 changes: 142 additions & 0 deletions .github/workflows/pr_benchmarks_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Run PR Benchmarks

# This workflow runs benchmarks on pull requests and caches the results.
# For security, benchmark results are uploaded as artifacts and tracked
# by a separate workflow (pr_benchmarks_track.yml) that has access to secrets.

on:
pull_request:
types: [opened, reopened, synchronize]
paths:
# Only run benchmarks if relevant code changes
- "src/**"
- "benches/**"
- "Cargo.toml"
- "Cargo.lock"

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
benchmark_historic:
name: Run Historic Benchmarks
runs-on: ubuntu-latest

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit

- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf /usr/local/lib/android
df -h

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2

- name: Install Foundry (Anvil)
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

- name: Run historic benchmarks
run: |
cargo bench --manifest-path benches/Cargo.toml --bench historic_scanning 2>&1 | tee historic_results.txt

- name: Upload historic benchmark results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: historic_results.txt
path: ./historic_results.txt

benchmark_latest:
name: Run Latest Events Benchmarks
runs-on: ubuntu-latest

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit

- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf /usr/local/lib/android
df -h

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2

- name: Install Foundry (Anvil)
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

- name: Run latest events benchmarks
run: |
cargo bench --manifest-path benches/Cargo.toml --bench latest_events_scanning 2>&1 | tee latest_results.txt

- name: Upload latest benchmark results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: latest_results.txt
path: ./latest_results.txt

# Combine results after both benchmarks complete
combine_results:
name: Combine Benchmark Results
runs-on: ubuntu-latest
needs: [benchmark_historic, benchmark_latest]

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit

- name: Download historic results
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: historic_results.txt

- name: Download latest results
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: latest_results.txt

- name: Combine benchmark results
run: |
echo "=== Historic Scanning Benchmarks ===" > benchmark_results.txt
cat historic_results.txt >> benchmark_results.txt
echo "" >> benchmark_results.txt
echo "=== Latest Events Benchmarks ===" >> benchmark_results.txt
cat latest_results.txt >> benchmark_results.txt

- name: Upload combined benchmark results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: benchmark_results.txt
path: ./benchmark_results.txt

- name: Upload PR event
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: event.json
path: ${{ github.event_path }}
79 changes: 79 additions & 0 deletions .github/workflows/pr_benchmarks_track.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Track PR Benchmarks

# This workflow tracks benchmark results from pull requests using Bencher.
# It runs after the pr_benchmarks_run.yml workflow completes successfully.
# This separation is required for security when handling fork PRs, as secrets
# are not available in the context of fork PR workflows.

on:
workflow_run:
workflows: [Run PR Benchmarks]
types: [completed]

permissions:
contents: read
pull-requests: write

env:
BENCHMARK_RESULTS: benchmark_results.txt
PR_EVENT: event.json

jobs:
track_pr_benchmarks:
name: Track PR Benchmarks with Bencher
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit

- name: Download benchmark results
uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8
with:
name: ${{ env.BENCHMARK_RESULTS }}
run_id: ${{ github.event.workflow_run.id }}

- name: Download PR event
uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8
with:
name: ${{ env.PR_EVENT }}
run_id: ${{ github.event.workflow_run.id }}

- name: Export PR event data
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const fs = require('fs');
const prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, { encoding: 'utf8' }));
core.exportVariable('PR_NUMBER', prEvent.number);
core.exportVariable('PR_HEAD', prEvent.pull_request.head.ref);
core.exportVariable('PR_HEAD_SHA', prEvent.pull_request.head.sha);
core.exportVariable('PR_BASE', prEvent.pull_request.base.ref);
core.exportVariable('PR_BASE_SHA', prEvent.pull_request.base.sha);

- name: Install Bencher CLI
uses: bencherdev/bencher@main

- name: Track PR benchmarks with Bencher
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT }}
run: |
bencher run \
--project "$BENCHER_PROJECT" \
--token "$BENCHER_API_TOKEN" \
--branch "$PR_HEAD" \
--hash "$PR_HEAD_SHA" \
--start-point "$PR_BASE" \
--start-point-hash "$PR_BASE_SHA" \
--start-point-clone-thresholds \
--start-point-reset \
--testbed ubuntu-latest \
--err \
--adapter rust_criterion \
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
--ci-number "$PR_NUMBER" \
--file "$BENCHMARK_RESULTS"
Loading