reduce exec time of fast-unstake benchmarks (#13120)

* reduce exec time of fast-unstake benchmarks

* fix test

* fmt

* fix patch the tests

* fix patch the tests

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* add batch size as well

* update some benches to be better

* fix one last test

* fix

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* reduce time even more

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* fix tests

* nit

* remove

* improve the weight calc further

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* fix benchmarks

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* update

* fix

* fix

* fmt

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* lots of changes again...

* smaller input

* update

* fmt

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* cleanup

* small simplification

* fmt

* reduce exec time a bit

* fix

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* test

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* increase again

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* review comments

* fmt

* fix

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

Co-authored-by: command-bot <>
This commit is contained in:
Kian Paimani
2023-01-25 20:59:19 -03:00
committed by GitHub
parent 73a9776266
commit 451a13c642
6 changed files with 237 additions and 263 deletions
+86 -69
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
// Copyright (C) 2023 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,24 +18,25 @@
//! Autogenerated weights for pallet_fast_unstake
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! DATE: 2023-01-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// ./target/production/substrate
// target/production/substrate
// benchmark
// pallet
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_fast_unstake
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./frame/fast-unstake/src/weights.rs
// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json
// --pallet=pallet_fast_unstake
// --chain=dev
// --header=./HEADER-APACHE2
// --output=./frame/fast-unstake/src/weights.rs
// --template=./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
@@ -47,8 +48,8 @@ use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_fast_unstake.
pub trait WeightInfo {
fn on_idle_unstake() -> Weight;
fn on_idle_check(x: u32, ) -> Weight;
fn on_idle_unstake(b: u32, ) -> Weight;
fn on_idle_check(v: u32, b: u32, ) -> Weight;
fn register_fast_unstake() -> Weight;
fn deregister() -> Weight;
fn control() -> Weight;
@@ -59,8 +60,9 @@ pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:1 w:1)
@@ -70,29 +72,36 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Ledger (r:0 w:1)
// Storage: Staking Payee (r:0 w:1)
fn on_idle_unstake() -> Weight {
// Minimum execution time: 82_426 nanoseconds.
Weight::from_ref_time(83_422_000 as u64)
.saturating_add(T::DbWeight::get().reads(11 as u64))
.saturating_add(T::DbWeight::get().writes(6 as u64))
/// The range of component `b` is `[1, 64]`.
fn on_idle_unstake(b: u32, ) -> Weight {
// Minimum execution time: 92_833 nanoseconds.
Weight::from_ref_time(62_136_346)
// Standard Error: 25_541
.saturating_add(Weight::from_ref_time(42_904_859).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(b.into())))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:2 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking ErasStakers (r:1344 w:0)
/// The range of component `x` is `[672, 86016]`.
fn on_idle_check(x: u32, ) -> Weight {
// Minimum execution time: 13_932_777 nanoseconds.
Weight::from_ref_time(13_996_029_000 as u64)
// Standard Error: 16_878
.saturating_add(Weight::from_ref_time(18_113_540 as u64).saturating_mul(x as u64))
.saturating_add(T::DbWeight::get().reads(345 as u64))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64)))
.saturating_add(T::DbWeight::get().writes(3 as u64))
// Storage: Staking ErasStakers (r:2 w:0)
/// The range of component `v` is `[1, 256]`.
/// The range of component `b` is `[1, 64]`.
fn on_idle_check(v: u32, b: u32, ) -> Weight {
// Minimum execution time: 1_775_293 nanoseconds.
Weight::from_ref_time(1_787_133_000)
// Standard Error: 17_109_142
.saturating_add(Weight::from_ref_time(546_766_552).saturating_mul(v.into()))
// Standard Error: 68_455_625
.saturating_add(Weight::from_ref_time(2_135_980_830).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:1)
@@ -109,10 +118,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight {
// Minimum execution time: 120_190 nanoseconds.
Weight::from_ref_time(121_337_000 as u64)
.saturating_add(T::DbWeight::get().reads(14 as u64))
.saturating_add(T::DbWeight::get().writes(9 as u64))
// Minimum execution time: 124_849 nanoseconds.
Weight::from_ref_time(128_176_000)
.saturating_add(T::DbWeight::get().reads(14))
.saturating_add(T::DbWeight::get().writes(9))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:0)
@@ -120,16 +129,16 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight {
// Minimum execution time: 49_897 nanoseconds.
Weight::from_ref_time(50_080_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
// Minimum execution time: 48_246 nanoseconds.
Weight::from_ref_time(49_720_000)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight {
// Minimum execution time: 4_814 nanoseconds.
Weight::from_ref_time(4_997_000 as u64)
.saturating_add(T::DbWeight::get().writes(1 as u64))
// Minimum execution time: 4_611 nanoseconds.
Weight::from_ref_time(4_844_000)
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -137,8 +146,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
impl WeightInfo for () {
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:1 w:1)
@@ -148,29 +158,36 @@ impl WeightInfo for () {
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Ledger (r:0 w:1)
// Storage: Staking Payee (r:0 w:1)
fn on_idle_unstake() -> Weight {
// Minimum execution time: 82_426 nanoseconds.
Weight::from_ref_time(83_422_000 as u64)
.saturating_add(RocksDbWeight::get().reads(11 as u64))
.saturating_add(RocksDbWeight::get().writes(6 as u64))
/// The range of component `b` is `[1, 64]`.
fn on_idle_unstake(b: u32, ) -> Weight {
// Minimum execution time: 92_833 nanoseconds.
Weight::from_ref_time(62_136_346)
// Standard Error: 25_541
.saturating_add(Weight::from_ref_time(42_904_859).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(6))
.saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes(1))
.saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(b.into())))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:2 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking ErasStakers (r:1344 w:0)
/// The range of component `x` is `[672, 86016]`.
fn on_idle_check(x: u32, ) -> Weight {
// Minimum execution time: 13_932_777 nanoseconds.
Weight::from_ref_time(13_996_029_000 as u64)
// Standard Error: 16_878
.saturating_add(Weight::from_ref_time(18_113_540 as u64).saturating_mul(x as u64))
.saturating_add(RocksDbWeight::get().reads(345 as u64))
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(x as u64)))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
// Storage: Staking ErasStakers (r:2 w:0)
/// The range of component `v` is `[1, 256]`.
/// The range of component `b` is `[1, 64]`.
fn on_idle_check(v: u32, b: u32, ) -> Weight {
// Minimum execution time: 1_775_293 nanoseconds.
Weight::from_ref_time(1_787_133_000)
// Standard Error: 17_109_142
.saturating_add(Weight::from_ref_time(546_766_552).saturating_mul(v.into()))
// Standard Error: 68_455_625
.saturating_add(Weight::from_ref_time(2_135_980_830).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(7))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into())))
.saturating_add(RocksDbWeight::get().writes(1))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:1)
@@ -187,10 +204,10 @@ impl WeightInfo for () {
// Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight {
// Minimum execution time: 120_190 nanoseconds.
Weight::from_ref_time(121_337_000 as u64)
.saturating_add(RocksDbWeight::get().reads(14 as u64))
.saturating_add(RocksDbWeight::get().writes(9 as u64))
// Minimum execution time: 124_849 nanoseconds.
Weight::from_ref_time(128_176_000)
.saturating_add(RocksDbWeight::get().reads(14))
.saturating_add(RocksDbWeight::get().writes(9))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:0)
@@ -198,15 +215,15 @@ impl WeightInfo for () {
// Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight {
// Minimum execution time: 49_897 nanoseconds.
Weight::from_ref_time(50_080_000 as u64)
.saturating_add(RocksDbWeight::get().reads(5 as u64))
.saturating_add(RocksDbWeight::get().writes(2 as u64))
// Minimum execution time: 48_246 nanoseconds.
Weight::from_ref_time(49_720_000)
.saturating_add(RocksDbWeight::get().reads(5))
.saturating_add(RocksDbWeight::get().writes(2))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight {
// Minimum execution time: 4_814 nanoseconds.
Weight::from_ref_time(4_997_000 as u64)
.saturating_add(RocksDbWeight::get().writes(1 as u64))
// Minimum execution time: 4_611 nanoseconds.
Weight::from_ref_time(4_844_000)
.saturating_add(RocksDbWeight::get().writes(1))
}
}