2

Can someone please explain the following output:

Why did the weights generate a zero input?

  • Weight::from_ref_time(0 as u64)

What is the fastest way to eyeball this and conclude whether these weights are within reason or telling me I need to rethink my implementation?

fn on_initialize(m: u32, ) -> Weight {
    Weight::from_ref_time(0 as u64)
        // Standard Error: 5_000
        .saturating_add(Weight::from_ref_time(1_242_000 as u64).saturating_mul(m as u64))
        .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(m as u64)))
}
4
  • But's not simply zero. It's 0 + 124200 * m + <db_write_wight> * m. Doesn't it make sense in your case that weight is entirely dependent on m? Dec 12, 2022 at 12:09
  • Totally understand the the total weight is not zero. What I did not understand was why this is zero: Weight::from_ref_time(0 as u64). I am not sure what that means.
    – Yatusabes
    Dec 12, 2022 at 17:38
  • 1
    I think it simply means that the constant part of your weight is zero. Is it true for your code that when m is zero, it does nothing? Dec 13, 2022 at 13:29
  • 1
    ahh...got it. Thanks. This is true.
    – Yatusabes
    Dec 13, 2022 at 17:21

1 Answer 1

1

It meant that the linear regression found a zero or negative interception point. In the later case we shift everything upwards to get to a zero intercept point.
This is a case-by-case thing, since we just throw the linear regression on it and expect it to do well.
It is obviously necessary that your call has linear complexity, otherwise the results make no sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.