Skip to content
Open
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
70 changes: 70 additions & 0 deletions .github/workflows/pr_perf_rlp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Benchmark RLP

on:
pull_request:
branches: ["**"]
paths:
- "crates/common/rlp/**"
- ".github/workflows/pr_perf_rlp.yaml"
workflow_dispatch:

permissions:
contents: read
actions: write
issues: write
pull-requests: write

jobs:
benchmark:
name: Benchmark RLP
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: 'main'
- name: Setup Rust Environment
uses: ./.github/actions/setup-rust
with:
components: rustfmt, clippy

- name: Install critcmp
run: cargo install critcmp

- name: Run bench main
continue-on-error: true
run: make bench-rlp
- name: Change to PR
env:
HEAD_REF: ${{ github.head_ref }}
run: |
git fetch origin "$HEAD_REF"
git checkout "$HEAD_REF"
- name: Run bench PR
run: make bench-rlp

- name: Save comparison
run: |
{
printf '## RLP Bench Results\n\n<details>\n<summary>Bench output</summary>\n\n```\n'
critcmp --list
printf '\n```\n\n</details>\n'
} > result.md

- name: Find comment
continue-on-error: true
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "RLP Bench Results"

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-path: result.md
edit-mode: replace
88 changes: 85 additions & 3 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: build lint test clean run-image build-image clean-vectors \
setup-hive test-pattern-default run-hive run-hive-debug clean-hive-logs \
load-test-fibonacci load-test-io run-hive-eels-blobs
load-test-fibonacci load-test-io run-hive-eels-blobs bench-rlp

help: ## 📚 Show help for each of the Makefile recipes
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -178,6 +178,9 @@ fixtures/ERC20/ERC20.bin: ## 🔨 Build the ERC20 contract for the load test
sort-genesis-files:
cd ./tooling/genesis && cargo run

bench-rlp: ## ⚡ Bench the RLP decoder/encoder
cd ./crates/common/rlp && cargo bench

# Using & so make calls this recipe only once per run
mermaid-init.js mermaid.min.js &:
@# Required for mdbook-mermaid to work
Expand Down
1 change: 1 addition & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ secp256k1 = { workspace = true, optional = true }

[dev-dependencies]
hex-literal.workspace = true
ethrex-p2p.workspace = true

[features]
default = ["secp256k1"]
Expand Down
14 changes: 14 additions & 0 deletions crates/common/rlp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,22 @@ snap.workspace = true

[dev-dependencies]
hex-literal.workspace = true
criterion = { version = "0.8.0", features = ["html_reports", "csv_output"] }
ethrex-common.workspace = true
ethrex-p2p.workspace = true
ethrex-trie.workspace = true
rand.workspace = true

[lib]
path = "./rlp.rs"

[lints]
workspace = true

[[bench]]
name = "decode"
harness = false

[[bench]]
name = "encode"
harness = false
36 changes: 36 additions & 0 deletions crates/common/rlp/benches/decode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use criterion::{Criterion, criterion_group, criterion_main};

fn bench_decode_scalars(c: &mut Criterion) {
let mut group = c.benchmark_group("decode_scalars");
group.finish();
}

fn bench_decode_bytes_strings(c: &mut Criterion) {
let mut group = c.benchmark_group("decode_bytes_strings");
group.finish();
}

fn bench_decode_collections(c: &mut Criterion) {
let mut group = c.benchmark_group("decode_collections");
group.finish();
}

fn bench_decode_tuples(c: &mut Criterion) {
let mut group = c.benchmark_group("decode_tuples");
group.finish();
}

fn bench_decode_ips(c: &mut Criterion) {
let mut group = c.benchmark_group("decode_ip_types");
group.finish();
}

criterion_group!(
benches,
bench_decode_scalars,
bench_decode_bytes_strings,
bench_decode_collections,
bench_decode_tuples,
bench_decode_ips,
);
criterion_main!(benches);
Loading
Loading