Skip to content

Conversation

dannywillems
Copy link
Member

@dannywillems dannywillems commented Oct 13, 2025

Converts the unused ledger/src/bin/ledger.rs binary to proper Rust benchmarks using criterion, following Rustacean best practices.

Running Benchmarks

# Run all benchmarks
make bench

# Run specific benchmark
make bench-database

# Or directly with cargo
cargo bench --bench database

@dannywillems dannywillems changed the base branch from remove-unused-poseidon-fp to develop October 13, 2025 15:15
Copy link

github-actions bot commented Oct 13, 2025

✓ Code Reference Verification Passed

All code references in the documentation have been verified successfully!

Total references checked: 1
Valid references: 1

The documentation is in sync with the codebase on the develop branch.

Copy link

github-actions bot commented Oct 13, 2025

OCaml Reference Validation Results

Repository: https://github.com/MinaProtocol/mina.git
Branch: compatible
Status: ❌ Validation failed

Click to see full validation output
Checking OCaml references against https://github.com/MinaProtocol/mina.git (branch: compatible)
Fetching current commit from compatible...

@dannywillems dannywillems force-pushed the add-criterion-benchmarks branch 2 times, most recently from 59246d3 to 8fc203d Compare October 13, 2025 15:49
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)
Instead of having separate workflow files for each platform's benchmarks,
integrate benchmark building as a new job in the existing build-reusable
workflow. This approach:
- Reduces workflow file duplication
- Reuses existing build caches for efficiency
- Makes benchmarks depend on successful main build
- Maintains benchmark builds across all platforms

Changes:
- Added build-benches job to build-reusable.yaml
- Removed 8 separate bench-*.yaml workflow files
- build-benches depends on build job and reuses its cache
- Updated CHANGELOG to reflect the integration approach
Set sample_size(10) for both benchmark groups to reduce execution time
in CI. This reduces samples from the default ~100 to 10, providing a
reasonable balance between statistical accuracy and build time.
Created comprehensive benchmark documentation page organized by component
(ledger). Added bash scripts for building and running benchmarks, which
are verified in CI to ensure commands exist in Makefile.

Documentation includes:
- Overview of criterion-based benchmarking
- Build and run instructions using bash scripts
- Ledger database benchmark details (account generation and merkle root
  computation)

CI verification added to test-docs-scripts workflow:
- Verifies benchmark scripts are executable
- Confirms make targets exist in Makefile
- Does not run benchmarks to avoid long CI times
@dannywillems dannywillems force-pushed the add-criterion-benchmarks branch from 8fc203d to 9eb385d Compare October 13, 2025 15:49
@dannywillems dannywillems requested a review from 0xMimir October 13, 2025 15:50
@dannywillems dannywillems self-assigned this Oct 13, 2025
@dannywillems dannywillems moved this to Done in Rust node Oct 13, 2025
@dannywillems dannywillems merged commit b8d4c16 into develop Oct 14, 2025
140 of 149 checks passed
@dannywillems dannywillems deleted the add-criterion-benchmarks branch October 16, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants