-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Dont use benchmark range on constant functions #12456
Dont use benchmark range on constant functions #12456
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you manually deploy this to the Substrate runtime to update the weights?
yes, did it manually, just to get a new file. The weight itself is not very important. |
We also never updated it. Could be that it never ran on reference hardware and therefore incorrectly detected a slope. |
I ran it locally, and it detected a very small slope of 1 ns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
It's probably not worth it to try and detect these kinds of constant functions and special-case them during weight generation; such tiny slopes should not make much difference in practice anyway, and there's always the possibility of getting it wrong.
// This is the benchmark setup phase. | ||
let value = 1000u32.into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is supposed to be an example maybe it'd be a good idea to explicitly say that "the set_dummy
always takes constant time hence we're hardcoding the value
here" or something like that?
bot merge |
Waiting for commit status. |
Merge cancelled due to error. Error: Statuses failed for 1600913 |
bot rebase |
…-example-benchmarking
Rebased |
bot merge |
* dont use benchmark range on constant function * update weights * fix * new weights * Update frame/examples/basic/src/benchmarking.rs Co-authored-by: parity-processbot <>
Trying to address the confusion here: https://substrate.stackexchange.com/questions/5249/why-would-benchmarking-a-simple-setter-has-a-linear-behaviour
These are constant functions, and should have constant weight.