Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Tips Benchmarking to be Runtime Agnostic #10368

Merged

Conversation

ferrell-code
Copy link
Contributor

@ferrell-code ferrell-code commented Nov 24, 2021

Use the generic config traits in benchmarking instead of hard-coded constants so any runtime configuration can benchmark pallet_tips and pallet bounties

@bkchr bkchr added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Nov 25, 2021
Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

A bit worried that if the configs are too small, then the benchmark won't be able to capture the coefficients accurately. For example if Tippers::max_len is just a few dozens (because the council has a small size), running that with the default --step 50 might be a bit of an issue. Code looks correct to me.

Copy link
Contributor

@gui1117 gui1117 left a comment

Choose a reason for hiding this comment

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

looks good to me, maybe better to improve doc so we know that constant mustn't be changed without running the benchmark.

A bit worried that if the configs are too small, then the benchmark won't be able to capture the coefficients accurately. For example if Tippers::max_len is just a few dozens (because the council has a small size), running that with the default --step 50 might be a bit of an issue.

I think we should consider the benchmark only valid for the value given at benchmark. And people should run benchmark again when changing the values.

@@ -33,7 +33,8 @@ const SEED: u32 = 0;
// Create bounties that are approved for use in `on_initialize`.
fn create_approved_bounties<T: Config>(n: u32) -> Result<(), &'static str> {
for i in 0..n {
let (caller, _curator, _fee, value, reason) = setup_bounty::<T>(i, MAX_BYTES);
let (caller, _curator, _fee, value, reason) =
setup_bounty::<T>(i, T::MaximumReasonLength::get());
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should add in the doc of MaximumReasonLength that this value is used in benchmark, so changing it requires running the benchmark again.
(so it can't be changed without runtime upgrade).

benchmarks! {
report_awesome {
let r in 0 .. MAX_BYTES;
let r in 0 .. T::MaximumReasonLength::get();
Copy link
Contributor

Choose a reason for hiding this comment

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

similarly I think we should say something in the doc

let r in 0 .. MAX_BYTES;
let t in 1 .. MAX_TIPPERS;
let r in 0 .. T::MaximumReasonLength::get();
let t in 1 .. T::Tippers::max_len() as u32;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it also worth mentionning it that ContainsLengthBound::max_len implementation of Tippers is used in benchmark.

@shawntabrizi
Copy link
Member

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot paritytech-processbot bot merged commit e2a89b2 into paritytech:master Nov 29, 2021
@ferrell-code ferrell-code deleted the fer-tips-benchmark branch November 30, 2021 15:22
niklasad1 added a commit that referenced this pull request Dec 2, 2021
chevdor pushed a commit that referenced this pull request Jan 11, 2022
* use config traits instead of constants

* bounties too

* do bounties too

* update docs
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
* use config traits instead of constants

* bounties too

* do bounties too

* update docs
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* use config traits instead of constants

* bounties too

* do bounties too

* update docs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants