Is there any best practice how to count the weights in on_initialize
correctly?
I read through the Polkadot and Substrate on_initialize
weight calculations and couldn't always figure out: When to benchmark? When to use benchmark components? When to use manual read and write additions?
Just an example here. There the length of Leases
was not taken into account of the weight benchmark.
In regards to benchmark components: Why does the component MaxApprovals
affect the weight here?
Why do we return 0 weight here, when there was at least the calculation of (n % T::SpendPeriod::get()).is_zero()
(which also should consume a little bit processing time)?
This is a pretty good example, that the length of Approvals
affect the weight and should be a component.
Here only T::DbWeight::get().
is used. But isn't there some processing time for the assert
call? Why wasn't benchmarking taken into account there? When using this style. Why couldn't I just use T::DbWeight::get().reads_writes(proposals_approvals_len, proposals_approvals_len)
here?
I count the following reads_writes
in on_initialize
and on_finalize
here:
READS:
StoragePeriod
, ChunkCount
, ProofChecked
(take), BlockTransactions
WRITES:
Transactions
, ChunkCount
, ProofChecked
(take), BlockTransactions
But it is T::DbWeight::get().reads_writes(2, 4)
, why?
I would expect T::DbWeight::get().writes(1)
here. Why it only takes the weight of check_xcm_version_change
into the overall weight?
Can you provide any best practices how to correctly count the weights of on_initialize
?