-
Notifications
You must be signed in to change notification settings - Fork 36
Conversation
pallets/author-inherent/src/lib.rs
Outdated
@@ -117,7 +117,7 @@ pub mod pallet { | |||
/// but before transactions are executed. | |||
// This should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 | |||
// TODO better weight. For now we just set a somewhat conservative fudge factor | |||
#[pallet::weight((10 * T::DbWeight::get().write, DispatchClass::Mandatory))] | |||
#[pallet::weight((3 * T::DbWeight::get().read + 11 * T::DbWeight::get().write, DispatchClass::Mandatory))] |
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.
I understand that this is a fudge factor, but it seems extremely high. What's the rationale for them?
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.
It was 10 writes before and now it is 11 writes. The HighestSlotSeen
added 1 more write.
I do not know why the fudge factor was 7 writes, it isn't benchmarked so the author (probably @JoshOrndorff ) was presumably being conservative (and just estimating all reads + writes + computation as 10 writes).
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.
Yeah, it was me that added that fudge factor, and it was exactly as Amar says. I just wanted something quick and safe that was better than 0
.
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.
This is tricky because it calls the SlotBeacon
which can have any implementation it wants. I think this problem has been solved in substrate land. It's the problem of weighing functionality that is abstracted behind a trait. How do they do it for all the pallets that depend on Currency
?
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.
It's true I was assuming T::SlotBeacon::slot() was 1 read. I think this is what most implementations will be in practice.
This is tricky because it calls the
SlotBeacon
which can have any implementation it wants.
@girazoki told me it's best to return (ReturnValue, WeightConsumed) in that case for the trait that is getting the value. So we'd need to change the SlotBeacon trait to return this tuple and change the impl to return the weight consumed too.
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.
I am in the process of benchmarking this, I think I have almost everything set except for paritytech/cumulus#1187.
pallets/author-inherent/src/lib.rs
Outdated
@@ -117,7 +117,7 @@ pub mod pallet { | |||
/// but before transactions are executed. | |||
// This should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 | |||
// TODO better weight. For now we just set a somewhat conservative fudge factor | |||
#[pallet::weight((10 * T::DbWeight::get().write, DispatchClass::Mandatory))] | |||
#[pallet::weight((3 * T::DbWeight::get().read + 11 * T::DbWeight::get().write, DispatchClass::Mandatory))] |
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.
#[pallet::weight((3 * T::DbWeight::get().read + 11 * T::DbWeight::get().write, DispatchClass::Mandatory))] | |
#[pallet::weight((10 * T::DbWeight::get().write, DispatchClass::Mandatory))] |
I'll revert the weight change so the objective optimization can get in.
dont change benchmarking in this PR
follow up
update weight as per #41 (comment) (MOON-1613)