Skip to content
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

Clamp benchmark ranks to respect MaxRank #7720

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Doordashcon
Copy link
Contributor

@Doordashcon Doordashcon commented Feb 25, 2025

resolves #7517

Issues

1. Compile-Time vs Runtime Rank Mismatch

  • promote_fast Benchmark uses mock runtime's MaxRank during benchmark generation while allowing runtime overrides. Creating potential parameter mismatch between benchmark metadata(i.e. generated r values) and runtime configuration(i.e. T::MaxRank).

2. Static Rank Assumptions

  • bump_demote Benchmark initialized members at rank 2, making it incompatible with MaxRank=1 configurations
  • promote Benchmark contained hardcoded rank values (1 → 2) which fails for MaxRank=1

Changes

Dynamic Rank Clamping

// promote_fast
let target_rank = r.min(T::MaxRank::get()).try_into().unwrap();

// promote
let to_rank = (current_rank + 1).min(max_rank.try_into().unwrap());

@Doordashcon Doordashcon marked this pull request as ready for review March 2, 2025 13:30
@Doordashcon Doordashcon requested a review from a team as a code owner March 2, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Benchmark promote_fast and others in pallet-core-fellowship Generates Ranks Exceeding MaxRank
1 participant