Skip to content

Commit bc122b0

Browse files
committed
Convert unused ledger binary to proper criterion benchmarks
Removed the unused src/bin/ledger.rs binary that was not integrated into the build system and converted it to proper Rust benchmarks using criterion following Rustacean best practices. Changes: - Removed ledger/src/bin/ledger.rs (unused binary) - Created ledger/benches/database.rs with criterion benchmarks for: * Account generation performance * Merkle root computation performance - Updated ledger/Cargo.toml: * Removed binary declaration * Added benchmark declaration * Added criterion to dev-dependencies - Added criterion to workspace Cargo.toml dependencies - Added Makefile targets: * build-benches: Build all benchmarks without running * build-bench-database: Build specific ledger database benchmark * bench: Run all benchmarks * bench-database: Run ledger database benchmark - Added CI workflows for building benchmarks: * bench-reusable.yaml: Reusable workflow using existing setup actions * bench-ubuntu-22-04.yaml: Runs on all events (PRs, pushes, etc.) * bench-ubuntu-24-04.yaml: Runs only on main/develop pushes * bench-ubuntu-24-04-arm.yaml: Runs only on main/develop pushes * bench-macos-latest.yaml: Runs only on main/develop pushes * bench-macos-13.yaml: Runs only on main/develop pushes * bench-macos-14.yaml: Runs only on main/develop pushes * bench-macos-15.yaml: Runs only on main/develop pushes The benchmarks can be run with: - cargo bench --bench database - make bench-database - make bench (for all benchmarks)
1 parent 8e05651 commit bc122b0

File tree

13 files changed

+280
-31
lines changed

13 files changed

+280
-31
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Bench macOS 13
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
bench:
14+
uses: ./.github/workflows/bench-reusable.yaml
15+
with:
16+
os: macos-13
17+
cache-prefix: macos-13-
18+
rustflags: "-C link-args=-Wl,-undefined,dynamic_lookup"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Bench macOS 14
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
bench:
14+
uses: ./.github/workflows/bench-reusable.yaml
15+
with:
16+
os: macos-14
17+
cache-prefix: macos-14-
18+
rustflags: "-C link-args=-Wl,-undefined,dynamic_lookup"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Bench macOS 15
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
bench:
14+
uses: ./.github/workflows/bench-reusable.yaml
15+
with:
16+
os: macos-15
17+
cache-prefix: macos-15-
18+
rustflags: "-C link-args=-Wl,-undefined,dynamic_lookup"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Bench macOS Latest
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
bench:
14+
uses: ./.github/workflows/bench-reusable.yaml
15+
with:
16+
os: macos-latest
17+
cache-prefix: macos-latest-
18+
rustflags: "-C link-args=-Wl,-undefined,dynamic_lookup"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Reusable Bench Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
description: "Operating system to build benches on"
10+
ocaml_version:
11+
required: false
12+
type: string
13+
default: "4.14.2"
14+
description: "OCaml version to use"
15+
cache-prefix:
16+
required: false
17+
type: string
18+
default: ""
19+
description: "Cache prefix for the build"
20+
rustflags:
21+
required: false
22+
type: string
23+
default: ""
24+
description: "Additional RUSTFLAGS to append (e.g., macOS-specific linker flags)"
25+
26+
env:
27+
CARGO_TERM_COLOR: always
28+
RUST_BACKTRACE: full
29+
MINA_PANIC_ON_BUG: true
30+
CARGO_INCREMENTAL: 1
31+
RUSTFLAGS: "-C overflow-checks=off -C debug-assertions=off"
32+
33+
jobs:
34+
build-benches:
35+
timeout-minutes: 60
36+
runs-on: ${{ inputs.os }}
37+
env:
38+
RUSTFLAGS: "-C overflow-checks=off -C debug-assertions=off ${{ inputs.rustflags }}"
39+
steps:
40+
- name: Git checkout
41+
uses: actions/checkout@v5
42+
43+
- name: Setup build dependencies
44+
uses: ./.github/actions/setup-build-deps
45+
46+
- name: Use shared OCaml setting up steps
47+
uses: ./.github/actions/setup-ocaml
48+
with:
49+
ocaml_version: ${{ inputs.ocaml_version }}
50+
51+
- name: Setup Rust
52+
uses: ./.github/actions/setup-rust
53+
with:
54+
toolchain: 1.84
55+
cache-prefix: bench-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
56+
57+
- name: Build all benchmarks
58+
run: make build-benches
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Bench Ubuntu 22.04
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
bench:
15+
uses: ./.github/workflows/bench-reusable.yaml
16+
with:
17+
os: ubuntu-22.04
18+
cache-prefix: ubuntu-22-04-
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Bench Ubuntu 24.04 ARM
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
bench:
14+
uses: ./.github/workflows/bench-reusable.yaml
15+
with:
16+
os: ubuntu-24.04-arm
17+
cache-prefix: ubuntu-24-04-arm-
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Bench Ubuntu 24.04
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
bench:
14+
uses: ./.github/workflows/bench-reusable.yaml
15+
with:
16+
os: ubuntu-24.04
17+
cache-prefix: ubuntu-24-04-

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ clap = { version = "4.5", features = ["derive"] }
7777
console = "0.15.5"
7878
console_error_panic_hook = "0.1"
7979
crc32fast = "1"
80+
criterion = { version = "0.5", features = ["html_reports"] }
8081
crypto-bigint = { version = "0.5.5", features = [
8182
"generic-array",
8283
"serde",

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,22 @@ build-wasm: ## Build WebAssembly node
123123
--out-dir pkg \
124124
target/wasm32-unknown-unknown/release/mina_node_web.wasm
125125

126+
.PHONY: build-benches
127+
build-benches: ## Build all benchmarks without running them
128+
@cargo bench --no-run
129+
130+
.PHONY: build-bench-database
131+
build-bench-database: ## Build ledger database benchmark
132+
@cargo bench --bench database --no-run
133+
134+
.PHONY: bench
135+
bench: ## Run all benchmarks
136+
@cargo bench
137+
138+
.PHONY: bench-database
139+
bench-database: ## Run ledger database benchmark
140+
@cargo bench --bench database
141+
126142
.PHONY: check
127143
check: ## Check code for compilation errors
128144
cargo check --all-targets

0 commit comments

Comments
 (0)