Skip to content

Test codspeed in op-rbuilder #175

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
76 changes: 76 additions & 0 deletions .github/workflows/codspeed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CodSpeed

on:
push:
branches:
- "main"
- "codspeed"
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

jobs:
codspeed:
name: Run benchmarks
runs-on: warp-ubuntu-latest-x64-32x
env:
# Set features for the Makefile
FEATURES: ${{ matrix.features }}
RUSTFLAGS: "-Awarnings"
strategy:
matrix:
toolchain:
- stable
features:
- ""
steps:
- uses: actions/checkout@v4

- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}

- name: Download builder playground
uses: flashbots/[email protected]
with:
builder-playground: v0.1.3

# https://github.com/swatinem/rust-cache
- name: Run Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

# https://github.com/Mozilla-Actions/sccache-action
- name: Run sccache-action
uses: mozilla-actions/[email protected]

- name: Set sccache env vars
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV

- name: Build the rbuilder
run: cargo build --features="${{ matrix.features }}"

- name: Run the playground
run: builder-playground &

- name: Install codspeed
run: cargo install cargo-codspeed

# - name: Set Swap Space
# uses: pierotofy/set-swap-space@master
# with:
# swap-size-gb: 64

- name: Build the benchmark target(s)
run: cargo codspeed build

- name: Run the benchmarks
uses: CodSpeedHQ/action@v3
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
98 changes: 98 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ reth-ipc = { workspace = true }
reth-node-builder = { workspace = true, features = ["test-utils"] }
bollard = "0.19"
ctor = "0.4.2"
divan = { version = "2.10.1", package = "codspeed-divan-compat" }

[features]
default = ["jemalloc"]
Expand Down Expand Up @@ -188,3 +189,7 @@ path = "src/bin/op-rbuilder/main.rs"
[[bin]]
name = "tester"
required-features = ["testing"]

[[bench]]
harness = false
name = "test_bench"
14 changes: 14 additions & 0 deletions crates/op-rbuilder/benches/test_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fn main() {
// Run registered benchmarks.
divan::main();
}

// Register a `fibonacci` function and benchmark it over multiple cases.
#[divan::bench(args = [1, 2, 4, 8, 16, 32])]
fn test_bench(n: u64) -> u64 {
if n <= 1 {
1
} else {
test_bench(n - 2) + test_bench(n - 1)
}
}
Loading