Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix benchmark delegate_with_auto_compound weights #1

Conversation

Chralt98
Copy link
Member

@Chralt98 Chralt98 commented Sep 19, 2023

What does it do?

The benchmark of delegate_with_auto_compound produces the following weight after this fix.

    /// Storage: System Account (r:1 w:1)
    /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen)
    /// Storage: ParachainStaking DelegatorState (r:1 w:1)
    /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking CandidateInfo (r:1 w:1)
    /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1)
    /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking TopDelegations (r:1 w:1)
    /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking BottomDelegations (r:1 w:1)
    /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking CandidatePool (r:1 w:1)
    /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured)
    /// Storage: Balances Locks (r:1 w:1)
    /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
    /// Storage: ParachainStaking Total (r:1 w:1)
    /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured)
    fn delegate_with_auto_compound(x: u32, y: u32, z: u32) -> Weight {
        // Proof Size summary in bytes:
        //  Measured:  `0 + x * (84 ±0) + y * (33 ±0) + z * (114 ±0)`
        //  Estimated: `127262 + x * (367 ±0) + y * (73 ±0) + z * (230 ±1)`
        // Minimum execution time: 88_000 nanoseconds.
        Weight::from_parts(149_011_098, 127262)
            // Standard Error: 34_531
            .saturating_add(Weight::from_ref_time(535_456).saturating_mul(z.into()))
            .saturating_add(T::DbWeight::get().reads(8_u64))
            .saturating_add(T::DbWeight::get().writes(8_u64))
			.saturating_add(Weight::from_proof_size(367).saturating_mul(x.into()))
			.saturating_add(Weight::from_proof_size(73).saturating_mul(y.into()))
			.saturating_add(Weight::from_proof_size(230).saturating_mul(z.into()))
    }

What important points reviewers should know?

Before the fix the weight included a very large proof of validity size:

    /// Storage: System Account (r:1 w:1)
    /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen)
    /// Storage: ParachainStaking DelegatorState (r:1 w:1)
    /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking CandidateInfo (r:1 w:1)
    /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1)
    /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking BottomDelegations (r:1 w:1)
    /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured)
    /// Storage: Balances Locks (r:1 w:1)
    /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
    /// Storage: ParachainStaking Total (r:1 w:1)
    /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured)
    /// Storage: ParachainStaking TopDelegations (r:1 w:1)
    /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured)
    /// Storage: ParachainStaking CandidatePool (r:1 w:1)
    /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured)
    fn delegate_with_auto_compound(x: u32, y: u32, z: u32) -> Weight {
        // Proof Size summary in bytes:
        //  Measured:  `0 + x * (82 ±0) + y * (33 ±0) + z * (60 ±0)`
        //  Estimated: `242081338576 + y * (2502655457532 ±0) + z * (196 ±2) + x * (168 ±0)`
        // Minimum execution time: 124_371 nanoseconds.
        Weight::from_parts(117_410_630, 242081338576)
            // Standard Error: 2_928
            .saturating_add(Weight::from_ref_time(80_456).saturating_mul(x.into()))
            // Standard Error: 2_928
            .saturating_add(Weight::from_ref_time(85_084).saturating_mul(y.into()))
            // Standard Error: 10_219
            .saturating_add(Weight::from_ref_time(362_814).saturating_mul(z.into()))
            .saturating_add(T::DbWeight::get().reads(8_u64))
            .saturating_add(T::DbWeight::get().writes(8_u64))
            .saturating_add(Weight::from_proof_size(2502655457532).saturating_mul(y.into()))
            .saturating_add(Weight::from_proof_size(196).saturating_mul(z.into()))
            .saturating_add(Weight::from_proof_size(168).saturating_mul(x.into()))
    }

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

moonbeam-foundation#2336

What value does it bring to the blockchain users?

@Chralt98 Chralt98 self-assigned this Sep 19, 2023
@Chralt98
Copy link
Member Author

Mentioned in zeitgeistpm/zeitgeist#1118

@sea212 sea212 merged commit 095ddae into polkadot-v0.9.38-use-paritytech-dependencies Sep 19, 2023
5 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants