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

Chores/update capacity benchmarks #1949 #1966

Conversation

shannonwells
Copy link
Collaborator

@shannonwells shannonwells commented May 9, 2024

Goal

The goal of this PR is to update the benchmark for on_initialize to include the weight when a new RewardEra must be created.

Closes #1949

Discussion

Separates the benchmark for on_initialize into two, start_new_epoch_if_needed and start_new_reward_era_if_needed. Those functions return the WeightInfo for their respective benchmarks.

For start_new_reward_era_if_needed, fills up the reward pool history and sets up the block and era to ensure that a new RewardEra will be created during the benchmark.

Results: The new weights are a lot larger, 19M as compared to 4M, 6 reads as compared to 2, 4 writes as compared to 1, so there's some optimization work to be done. Filed new Issue #1967

Checklist

  • Benchmarks updated
  • Weights updated

@shannonwells shannonwells changed the base branch from main to feat/capacity-staking-rewards-impl May 9, 2024 23:05
@shannonwells shannonwells marked this pull request as ready for review May 9, 2024 23:15
@shannonwells shannonwells requested a review from wilwade as a code owner May 9, 2024 23:15
Copy link

codecov bot commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels May 9, 2024
Copy link
Collaborator

@aramikm aramikm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. If you look at the on_initialize it consists of start_new_epoch_if_needed weights + start_new_reward_era_if_needed weights and inside each of them you are reusing T::WeightInfo::on_initialize() which makes this whole calculation kinda recursive!?

I think one way to fix this is to benchmark start_new_epoch_if_needed and start_new_reward_era_if_needed separately and maybe add them to get the weights for on_initialize

@shannonwells shannonwells marked this pull request as draft May 10, 2024 00:03
@shannonwells
Copy link
Collaborator Author

You are correct, I'd completely overlooked that it was doing that, and I'm not sure why it was set up that way.

@shannonwells shannonwells requested a review from aramikm May 10, 2024 00:48
@shannonwells shannonwells marked this pull request as ready for review May 10, 2024 00:48
Copy link
Collaborator

@aramikm aramikm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Ship it!

@shannonwells shannonwells merged commit f8ada08 into feat/capacity-staking-rewards-impl May 13, 2024
@shannonwells shannonwells deleted the chores/update-capacity-benchmarks-#1949 branch May 13, 2024 18:20
shannonwells added a commit that referenced this pull request May 14, 2024
# Goal
The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949
shannonwells added a commit that referenced this pull request May 21, 2024
# Goal
The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949
shannonwells added a commit that referenced this pull request May 22, 2024
The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949
shannonwells added a commit that referenced this pull request Jun 12, 2024
The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949
shannonwells added a commit that referenced this pull request Jun 25, 2024
The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949
shannonwells added a commit that referenced this pull request Jul 18, 2024
The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949
shannonwells added a commit that referenced this pull request Jul 23, 2024
The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented Provider Boosting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check maximum weight of on_initialize when starting a new era.
3 participants