From c13b5004347074b161e8d2d4f416cdee37fcee06 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 18 Jul 2021 22:38:46 -0400 Subject: [PATCH 01/73] extract repeat out of benchmark --- frame/benchmarking/src/lib.rs | 192 +++++++-------- frame/benchmarking/src/utils.rs | 4 - out | 0 pallet_balances.rs | 123 ++++++++++ utils/frame/benchmarking-cli/src/command.rs | 257 +++++++++++--------- 5 files changed, 358 insertions(+), 218 deletions(-) create mode 100644 out create mode 100644 pallet_balances.rs diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index fb4fd0801a245..0ee4297cd8725 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -703,7 +703,6 @@ macro_rules! impl_benchmark { lowest_range_values: &[u32], highest_range_values: &[u32], steps: &[u32], - repeat: u32, whitelist: &[$crate::TrackedStorageKey], verify: bool, ) -> Result<$crate::Vec<$crate::BenchmarkResults>, &'static str> { @@ -715,9 +714,6 @@ macro_rules! impl_benchmark { _ => return Err("Could not find extrinsic."), }; let mut results: $crate::Vec<$crate::BenchmarkResults> = $crate::Vec::new(); - if repeat == 0 { - return Ok(results); - } // Add whitelist to DB including whitelisted caller let mut whitelist = whitelist.to_vec(); @@ -740,120 +736,114 @@ macro_rules! impl_benchmark { // Default number of steps for a component. let mut prev_steps = 10; - let mut repeat_benchmark = | - repeat: u32, + let mut do_benchmark = | c: &[($crate::BenchmarkParameter, u32)], results: &mut $crate::Vec<$crate::BenchmarkResults>, verify: bool, step: u32, num_steps: u32, | -> Result<(), &'static str> { - // Run the benchmark `repeat` times. - for r in 0..repeat { - // Set up the externalities environment for the setup we want to - // benchmark. - let closure_to_benchmark = < - SelectedBenchmark as $crate::BenchmarkingSetup - >::instance(&selected_benchmark, c, verify)?; - - // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { - frame_system::Pallet::::set_block_number(1u32.into()); - } - - // Commit the externalities to the database, flushing the DB cache. - // This will enable worst case scenario for reading from the database. - $crate::benchmarking::commit_db(); - - // Reset the read/write counter so we don't count operations in the setup process. - $crate::benchmarking::reset_read_write_count(); + // Set up the externalities environment for the setup we want to + // benchmark. + let closure_to_benchmark = < + SelectedBenchmark as $crate::BenchmarkingSetup + >::instance(&selected_benchmark, c, verify)?; - if verify { - closure_to_benchmark()?; - } else { - // Time the extrinsic logic. - $crate::log::trace!( - target: "benchmark", - "Start Benchmark: {:?}", c - ); - - let start_pov = $crate::benchmarking::proof_size(); - let start_extrinsic = $crate::benchmarking::current_time(); - - closure_to_benchmark()?; + // Set the block number to at least 1 so events are deposited. + if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); + } - let finish_extrinsic = $crate::benchmarking::current_time(); - let end_pov = $crate::benchmarking::proof_size(); + // Commit the externalities to the database, flushing the DB cache. + // This will enable worst case scenario for reading from the database. + $crate::benchmarking::commit_db(); - // Calculate the diff caused by the benchmark. - let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic); - let diff_pov = match (start_pov, end_pov) { - (Some(start), Some(end)) => end.saturating_sub(start), - _ => Default::default(), - }; + // Reset the read/write counter so we don't count operations in the setup process. + $crate::benchmarking::reset_read_write_count(); - // Commit the changes to get proper write count - $crate::benchmarking::commit_db(); - $crate::log::trace!( - target: "benchmark", - "End Benchmark: {} ns", elapsed_extrinsic - ); - let read_write_count = $crate::benchmarking::read_write_count(); - $crate::log::trace!( + if verify { + closure_to_benchmark()?; + } else { + // Time the extrinsic logic. + $crate::log::trace!( + target: "benchmark", + "Start Benchmark: {:?}", c + ); + + let start_pov = $crate::benchmarking::proof_size(); + let start_extrinsic = $crate::benchmarking::current_time(); + + closure_to_benchmark()?; + + let finish_extrinsic = $crate::benchmarking::current_time(); + let end_pov = $crate::benchmarking::proof_size(); + + // Calculate the diff caused by the benchmark. + let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic); + let diff_pov = match (start_pov, end_pov) { + (Some(start), Some(end)) => end.saturating_sub(start), + _ => Default::default(), + }; + + // Commit the changes to get proper write count + $crate::benchmarking::commit_db(); + $crate::log::trace!( + target: "benchmark", + "End Benchmark: {} ns", elapsed_extrinsic + ); + let read_write_count = $crate::benchmarking::read_write_count(); + $crate::log::trace!( + target: "benchmark", + "Read/Write Count {:?}", read_write_count + ); + + let time = $crate::benchmarking::current_time(); + if time.saturating_sub(progress) > 5000000000 { + progress = $crate::benchmarking::current_time(); + $crate::log::info!( target: "benchmark", - "Read/Write Count {:?}", read_write_count + "Benchmarking {} {}/{}", + extrinsic, + step, + num_steps, ); - - let time = $crate::benchmarking::current_time(); - if time.saturating_sub(progress) > 5000000000 { - progress = $crate::benchmarking::current_time(); - $crate::log::info!( - target: "benchmark", - "Benchmarking {} {}/{}, run {}/{}", - extrinsic, - step, - num_steps, - r, - repeat, - ); - } - - // Time the storage root recalculation. - let start_storage_root = $crate::benchmarking::current_time(); - $crate::storage_root(); - let finish_storage_root = $crate::benchmarking::current_time(); - let elapsed_storage_root = finish_storage_root - start_storage_root; - - // TODO: Fix memory allocation issue then re-enable - // let read_and_written_keys = $crate::benchmarking::get_read_and_written_keys(); - let read_and_written_keys = Default::default(); - - results.push($crate::BenchmarkResults { - components: c.to_vec(), - extrinsic_time: elapsed_extrinsic, - storage_root_time: elapsed_storage_root, - reads: read_write_count.0, - repeat_reads: read_write_count.1, - writes: read_write_count.2, - repeat_writes: read_write_count.3, - proof_size: diff_pov, - keys: read_and_written_keys, - }); } - // Wipe the DB back to the genesis state. - $crate::benchmarking::wipe_db(); + // Time the storage root recalculation. + let start_storage_root = $crate::benchmarking::current_time(); + $crate::storage_root(); + let finish_storage_root = $crate::benchmarking::current_time(); + let elapsed_storage_root = finish_storage_root - start_storage_root; + + // TODO: Fix memory allocation issue then re-enable + let read_and_written_keys = $crate::benchmarking::get_read_and_written_keys(); + //let read_and_written_keys = Default::default(); + + results.push($crate::BenchmarkResults { + components: c.to_vec(), + extrinsic_time: elapsed_extrinsic, + storage_root_time: elapsed_storage_root, + reads: read_write_count.0, + repeat_reads: read_write_count.1, + writes: read_write_count.2, + repeat_writes: read_write_count.3, + proof_size: diff_pov, + keys: read_and_written_keys, + }); } + // Wipe the DB back to the genesis state. + $crate::benchmarking::wipe_db(); + Ok(()) }; if components.is_empty() { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - repeat_benchmark(1, Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; } - repeat_benchmark(repeat, Default::default(), &mut results, false, 1, 1)?; + do_benchmark(Default::default(), &mut results, false, 1, 1)?; } else { // Select the component we will be benchmarking. Each component will be benchmarked. for (idx, (name, low, high)) in components.iter().enumerate() { @@ -891,9 +881,9 @@ macro_rules! impl_benchmark { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - repeat_benchmark(1, &c, &mut $crate::Vec::new(), true, s, num_of_steps)?; + do_benchmark(&c, &mut $crate::Vec::new(), true, s, num_of_steps)?; } - repeat_benchmark(repeat, &c, &mut results, false, s, num_of_steps)?; + do_benchmark(&c, &mut results, false, s, num_of_steps)?; } } } @@ -1246,7 +1236,6 @@ pub fn show_benchmark_debug_info( lowest_range_values: &sp_std::prelude::Vec, highest_range_values: &sp_std::prelude::Vec, steps: &sp_std::prelude::Vec, - repeat: &u32, verify: &bool, error_message: &str, ) -> sp_runtime::RuntimeString { @@ -1256,7 +1245,6 @@ pub fn show_benchmark_debug_info( * Lowest_range_values: {:?}\n\ * Highest_range_values: {:?}\n\ * Steps: {:?}\n\ - * Repeat: {:?}\n\ * Verify: {:?}\n\ * Error message: {}", sp_std::str::from_utf8(instance_string) @@ -1266,7 +1254,6 @@ pub fn show_benchmark_debug_info( lowest_range_values, highest_range_values, steps, - repeat, verify, error_message, ) @@ -1347,7 +1334,6 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, - repeat, verify, extra, } = config; @@ -1363,7 +1349,6 @@ macro_rules! add_benchmark { &lowest_range_values[..], &highest_range_values[..], &steps[..], - *repeat, whitelist, *verify, ).map_err(|e| { @@ -1373,7 +1358,6 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, - repeat, verify, e, ) @@ -1390,7 +1374,6 @@ macro_rules! add_benchmark { &lowest_range_values[..], &highest_range_values[..], &steps[..], - *repeat, whitelist, *verify, ).map_err(|e| { @@ -1400,7 +1383,6 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, - repeat, verify, e, ) diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index c40434fb1a584..2552be18fe3be 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -80,8 +80,6 @@ pub struct BenchmarkConfig { pub highest_range_values: Vec, /// The number of samples to take across the range of values for components. pub steps: Vec, - /// The number of times to repeat a benchmark. - pub repeat: u32, /// Enable an extra benchmark iteration which runs the verification logic for a benchmark. pub verify: bool, /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a pallet. @@ -193,13 +191,11 @@ pub trait Benchmarking { /// - `steps`: The number of sample points you want to take across the range of parameters. /// - `lowest_range_values`: The lowest number for each range of parameters. /// - `highest_range_values`: The highest number for each range of parameters. - /// - `repeat`: The number of times you want to repeat a benchmark. fn run_benchmark( name: &[u8], lowest_range_values: &[u32], highest_range_values: &[u32], steps: &[u32], - repeat: u32, whitelist: &[TrackedStorageKey], verify: bool, ) -> Result, &'static str>; diff --git a/out b/out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/pallet_balances.rs b/pallet_balances.rs new file mode 100644 index 0000000000000..a6980d4d6e843 --- /dev/null +++ b/pallet_balances.rs @@ -0,0 +1,123 @@ +// This file is part of Substrate. + +// Copyright (C) 2021 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Autogenerated weights for pallet_balances +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Interpreted, CHAIN: Some("dev"), DB CACHE: 128 + +// Executed Command: +// target/release/substrate +// benchmark +// --chain=dev +// --steps=50 +// --repeat=10 +// --pallet=pallet_balances +// --extrinsic=* +// --execution=wasm +// --wasm-execution=interpreted-i-know-what-i-do +// --heap-pages=4096 +// --output=./ +// --template=./.maintain/frame-weight-template.hbs +// --raw + + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_balances. +pub trait WeightInfo { + fn force_transfer() -> Weight; + fn transfer_all() -> Weight; + fn transfer() -> Weight; + fn transfer_keep_alive() -> Weight; + fn set_balance_creating() -> Weight; + fn set_balance_killing() -> Weight; +} + +/// Weights for pallet_balances using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn force_transfer() -> Weight { + (330_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + fn transfer_all() -> Weight { + (327_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn transfer() -> Weight { + (335_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn transfer_keep_alive() -> Weight { + (262_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn set_balance_creating() -> Weight { + (103_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn set_balance_killing() -> Weight { + (124_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn force_transfer() -> Weight { + (330_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + fn transfer_all() -> Weight { + (327_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn transfer() -> Weight { + (335_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn transfer_keep_alive() -> Weight { + (262_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn set_balance_creating() -> Weight { + (103_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn set_balance_killing() -> Weight { + (124_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } +} diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 3bfb639dd9eb7..eef830db3661d 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -17,7 +17,7 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; -use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkSelector}; +use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkSelector, BenchmarkResults}; use frame_support::traits::StorageInfo; use sc_cli::{SharedParams, CliConfiguration, ExecutionStrategy, Result}; use sc_client_db::BenchmarkingState; @@ -31,7 +31,33 @@ use sp_externalities::Extensions; use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use sp_state_machine::StateMachine; -use std::{fmt::Debug, sync::Arc}; +use std::{fmt::Debug, sync::Arc, collections::HashMap}; + +// This takes multiple benchmark batches and combines all the results where the pallet, instance, +// and benchmark are the same. +fn combine_batches(batches: Vec) -> Vec { + if batches.is_empty() { return batches } + + let mut all_benchmarks = HashMap::<_, Vec>::new(); + + batches.into_iter().for_each(|BenchmarkBatch { pallet, instance, benchmark, results }| { + // We use this key to uniquely identify a benchmark among batches. + let key = (pallet, instance, benchmark); + + match all_benchmarks.get_mut(&key) { + // We already have this benchmark, so we extend the results. + Some(x) => x.extend(results), + // New benchmark, so we add a new entry with the initial results. + None => { + all_benchmarks.insert(key, results); + }, + } + }); + + all_benchmarks.into_iter().map(|((pallet, instance, benchmark), results)| { + BenchmarkBatch { pallet, instance, benchmark, results } + }).collect::>() +} impl BenchmarkCmd { /// Runs the command and benchmarks the chain. @@ -70,117 +96,130 @@ impl BenchmarkCmd { 2, // The runtime instances cache size. ); - let mut extensions = Extensions::default(); - extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); - let (offchain, _) = TestOffchainExt::new(); - let (pool, _) = TestTransactionPoolExt::new(); - extensions.register(OffchainWorkerExt::new(offchain.clone())); - extensions.register(OffchainDbExt::new(offchain)); - extensions.register(TransactionPoolExt::new(pool)); - - let result = StateMachine::<_, _, NumberFor, _>::new( - &state, - None, - &mut changes, - &executor, - "Benchmark_dispatch_benchmark", - &( - &self.pallet, - &self.extrinsic, - self.lowest_range_values.clone(), - self.highest_range_values.clone(), - self.steps.clone(), - self.repeat, - !self.no_verify, - self.extra, - ).encode(), - extensions, - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, - sp_core::testing::TaskExecutor::new(), - ) - .execute(strategy.into()) - .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - - let results = , Vec), - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))?; - - match results { - Ok((batches, storage_info)) => { - if let Some(output_path) = &self.output { - crate::writer::write_results(&batches, &storage_info, output_path, self)?; - } + let mut batches = Vec::new(); + let mut storage_info = Vec::new(); + + for r in 0 .. self.repeat { + let mut extensions = Extensions::default(); + extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); + let (offchain, _) = TestOffchainExt::new(); + let (pool, _) = TestTransactionPoolExt::new(); + extensions.register(OffchainWorkerExt::new(offchain.clone())); + extensions.register(OffchainDbExt::new(offchain)); + extensions.register(TransactionPoolExt::new(pool)); + + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_dispatch_benchmark", + &( + &self.pallet, + &self.extrinsic, + self.lowest_range_values.clone(), + self.highest_range_values.clone(), + self.steps.clone(), + r, + !self.no_verify, + self.extra, + ).encode(), + extensions, + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), + ) + .execute(strategy.into()) + .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; + + let (batch, last_storage_info) = , Vec), + String, + > as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; + + batches.extend(batch); + storage_info = last_storage_info; + } + + let batches = combine_batches(batches); + + for b in batches.clone() { + println!("{:?}: {:?}", + String::from_utf8(b.pallet).unwrap(), + String::from_utf8(b.benchmark).unwrap(), + ); + } + - for batch in batches.into_iter() { - // Print benchmark metadata - println!( - "Pallet: {:?}, Extrinsic: {:?}, Lowest values: {:?}, Highest values: {:?}, Steps: {:?}, Repeat: {:?}", - String::from_utf8(batch.pallet).expect("Encoded from String; qed"), - String::from_utf8(batch.benchmark).expect("Encoded from String; qed"), - self.lowest_range_values, - self.highest_range_values, - self.steps, - self.repeat, + if let Some(output_path) = &self.output { + crate::writer::write_results(&batches, &storage_info, output_path, self)?; + } + + for batch in batches.into_iter() { + // Print benchmark metadata + println!( + "Pallet: {:?}, Extrinsic: {:?}, Lowest values: {:?}, Highest values: {:?}, Steps: {:?}, Repeat: {:?}", + String::from_utf8(batch.pallet).expect("Encoded from String; qed"), + String::from_utf8(batch.benchmark).expect("Encoded from String; qed"), + self.lowest_range_values, + self.highest_range_values, + self.steps, + self.repeat, + ); + + // Skip raw data + analysis if there are no results + if batch.results.is_empty() { continue } + + if self.raw_data { + // Print the table header + batch.results[0].components.iter().for_each(|param| print!("{:?},", param.0)); + + print!("extrinsic_time_ns,storage_root_time_ns,reads,repeat_reads,writes,repeat_writes,proof_size_bytes\n"); + // Print the values + batch.results.iter().for_each(|result| { + + let parameters = &result.components; + parameters.iter().for_each(|param| print!("{:?},", param.1)); + // Print extrinsic time and storage root time + print!("{:?},{:?},{:?},{:?},{:?},{:?},{:?}\n", + result.extrinsic_time, + result.storage_root_time, + result.reads, + result.repeat_reads, + result.writes, + result.repeat_writes, + result.proof_size, ); + }); - // Skip raw data + analysis if there are no results - if batch.results.is_empty() { continue } - - if self.raw_data { - // Print the table header - batch.results[0].components.iter().for_each(|param| print!("{:?},", param.0)); - - print!("extrinsic_time_ns,storage_root_time_ns,reads,repeat_reads,writes,repeat_writes,proof_size_bytes\n"); - // Print the values - batch.results.iter().for_each(|result| { - - let parameters = &result.components; - parameters.iter().for_each(|param| print!("{:?},", param.1)); - // Print extrinsic time and storage root time - print!("{:?},{:?},{:?},{:?},{:?},{:?},{:?}\n", - result.extrinsic_time, - result.storage_root_time, - result.reads, - result.repeat_reads, - result.writes, - result.repeat_writes, - result.proof_size, - ); - }); - - println!(); - } - - // Conduct analysis. - if !self.no_median_slopes { - println!("Median Slopes Analysis\n========"); - if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::ExtrinsicTime) { - println!("-- Extrinsic Time --\n{}", analysis); - } - if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::Reads) { - println!("Reads = {:?}", analysis); - } - if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::Writes) { - println!("Writes = {:?}", analysis); - } - } - if !self.no_min_squares { - println!("Min Squares Analysis\n========"); - if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::ExtrinsicTime) { - println!("-- Extrinsic Time --\n{}", analysis); - } - if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Reads) { - println!("Reads = {:?}", analysis); - } - if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Writes) { - println!("Writes = {:?}", analysis); - } - } + println!(); + } + + // Conduct analysis. + if !self.no_median_slopes { + println!("Median Slopes Analysis\n========"); + if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::ExtrinsicTime) { + println!("-- Extrinsic Time --\n{}", analysis); } - }, - Err(error) => eprintln!("Error: {}", error), + if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::Reads) { + println!("Reads = {:?}", analysis); + } + if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::Writes) { + println!("Writes = {:?}", analysis); + } + } + if !self.no_min_squares { + println!("Min Squares Analysis\n========"); + if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::ExtrinsicTime) { + println!("-- Extrinsic Time --\n{}", analysis); + } + if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Reads) { + println!("Reads = {:?}", analysis); + } + if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Writes) { + println!("Writes = {:?}", analysis); + } + } } Ok(()) From c309539e147565e921012b4a77bba6c37d6f14f4 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 18 Jul 2021 22:49:50 -0400 Subject: [PATCH 02/73] remove r --- utils/frame/benchmarking-cli/src/command.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index eef830db3661d..91e38093f0943 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -120,7 +120,6 @@ impl BenchmarkCmd { self.lowest_range_values.clone(), self.highest_range_values.clone(), self.steps.clone(), - r, !self.no_verify, self.extra, ).encode(), From e909b9d4e4750f863efacc6724b29f0145e826e8 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 18 Jul 2021 22:51:47 -0400 Subject: [PATCH 03/73] unused --- utils/frame/benchmarking-cli/src/command.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 91e38093f0943..5007f1e31c4d6 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -99,7 +99,7 @@ impl BenchmarkCmd { let mut batches = Vec::new(); let mut storage_info = Vec::new(); - for r in 0 .. self.repeat { + for _r in 0 .. self.repeat { let mut extensions = Extensions::default(); extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); let (offchain, _) = TestOffchainExt::new(); From 6e7086141db35ea6430e186fe0419b944441aa4e Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Mon, 19 Jul 2021 02:57:33 +0000 Subject: [PATCH 04/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 76 ++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index 79e6445dd6bb6..7574d1f352e9f 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -17,8 +17,8 @@ //! Autogenerated weights for pallet_balances //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -45,43 +45,49 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. pub trait WeightInfo { fn transfer() -> Weight; - fn transfer_keep_alive() -> Weight; fn set_balance_creating() -> Weight; - fn set_balance_killing() -> Weight; fn force_transfer() -> Weight; fn transfer_all() -> Weight; + fn transfer_keep_alive() -> Weight; + fn set_balance_killing() -> Weight; } /// Weights for pallet_balances using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (73_268_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (54_881_000 as Weight) + (76_264_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (29_853_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (36_007_000 as Weight) + (30_731_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (72_541_000 as Weight) + (74_715_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } + // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (67_360_000 as Weight) + (69_789_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn transfer_keep_alive() -> Weight { + (56_681_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn set_balance_killing() -> Weight { + (37_083_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -89,33 +95,39 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { + // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (73_268_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (54_881_000 as Weight) + (76_264_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (29_853_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (36_007_000 as Weight) + (30_731_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (72_541_000 as Weight) + (74_715_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } + // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (67_360_000 as Weight) + (69_789_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn transfer_keep_alive() -> Weight { + (56_681_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn set_balance_killing() -> Weight { + (37_083_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From 30e9e5ff46eb6811d9242300591253153d301a90 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Mon, 19 Jul 2021 03:32:21 +0000 Subject: [PATCH 05/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index 7574d1f352e9f..1e665807c3333 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -44,11 +44,11 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. pub trait WeightInfo { - fn transfer() -> Weight; fn set_balance_creating() -> Weight; + fn transfer_keep_alive() -> Weight; fn force_transfer() -> Weight; + fn transfer() -> Weight; fn transfer_all() -> Weight; - fn transfer_keep_alive() -> Weight; fn set_balance_killing() -> Weight; } @@ -56,38 +56,38 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (76_264_000 as Weight) + fn set_balance_creating() -> Weight { + (30_439_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_731_000 as Weight) + fn transfer_keep_alive() -> Weight { + (55_632_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (74_715_000 as Weight) + (74_593_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (69_789_000 as Weight) + fn transfer() -> Weight { + (75_298_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_keep_alive() -> Weight { - (56_681_000 as Weight) + fn transfer_all() -> Weight { + (68_792_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_083_000 as Weight) + (37_101_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -96,38 +96,38 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (76_264_000 as Weight) + fn set_balance_creating() -> Weight { + (30_439_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_731_000 as Weight) + fn transfer_keep_alive() -> Weight { + (55_632_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (74_715_000 as Weight) + (74_593_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (69_789_000 as Weight) + fn transfer() -> Weight { + (75_298_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_keep_alive() -> Weight { - (56_681_000 as Weight) + fn transfer_all() -> Weight { + (68_792_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_083_000 as Weight) + (37_101_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From 66c1dbbdd4f89038f26f25d93a82332b9e631ced Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Mon, 19 Jul 2021 04:33:00 +0000 Subject: [PATCH 06/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/staking/src/weights.rs | 810 ++++++++++++++++++++++++----------- 1 file changed, 549 insertions(+), 261 deletions(-) diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index cf14e8b22362f..d9fdfda7b5a8c 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -17,8 +17,8 @@ //! Autogenerated weights for pallet_staking //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -44,409 +44,697 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_staking. pub trait WeightInfo { - fn bond() -> Weight; - fn bond_extra() -> Weight; - fn unbond() -> Weight; - fn withdraw_unbonded_update(s: u32, ) -> Weight; - fn withdraw_unbonded_kill(s: u32, ) -> Weight; - fn validate() -> Weight; fn kick(k: u32, ) -> Weight; - fn nominate(n: u32, ) -> Weight; - fn chill() -> Weight; - fn set_payee() -> Weight; fn set_controller() -> Weight; - fn set_validator_count() -> Weight; - fn force_no_eras() -> Weight; - fn force_new_era() -> Weight; fn force_new_era_always() -> Weight; - fn set_invulnerables(v: u32, ) -> Weight; + fn withdraw_unbonded_update(s: u32, ) -> Weight; fn force_unstake(s: u32, ) -> Weight; fn cancel_deferred_slash(s: u32, ) -> Weight; - fn payout_stakers_dead_controller(n: u32, ) -> Weight; + fn withdraw_unbonded_kill(s: u32, ) -> Weight; fn payout_stakers_alive_staked(n: u32, ) -> Weight; fn rebond(l: u32, ) -> Weight; - fn set_history_depth(e: u32, ) -> Weight; - fn reap_stash(s: u32, ) -> Weight; - fn new_era(v: u32, n: u32, ) -> Weight; fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight; + fn force_no_eras() -> Weight; + fn set_invulnerables(v: u32, ) -> Weight; + fn payout_stakers_dead_controller(n: u32, ) -> Weight; + fn chill() -> Weight; + fn set_payee() -> Weight; + fn nominate(n: u32, ) -> Weight; fn get_npos_targets(v: u32, ) -> Weight; + fn force_new_era() -> Weight; + fn set_history_depth(e: u32, ) -> Weight; fn set_staking_limits() -> Weight; + fn bond_extra() -> Weight; + fn validate() -> Weight; + fn set_validator_count() -> Weight; + fn unbond() -> Weight; + fn reap_stash(s: u32, ) -> Weight; + fn new_era(v: u32, n: u32, ) -> Weight; + fn bond() -> Weight; fn chill_other() -> Weight; } /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - fn bond() -> Weight { - (72_617_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - } - fn bond_extra() -> Weight { - (55_590_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - fn unbond() -> Weight { - (59_730_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_279_000 as Weight) - // Standard Error: 0 - .saturating_add((68_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_629_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_379_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - fn validate() -> Weight { - (32_393_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (36_986_000 as Weight) - // Standard Error: 13_000 - .saturating_add((16_574_000 as Weight).saturating_mul(k as Weight)) + (15_687_000 as Weight) + // Standard Error: 10_000 + .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } - fn nominate(n: u32, ) -> Weight { - (43_228_000 as Weight) - // Standard Error: 21_000 - .saturating_add((5_119_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - fn chill() -> Weight { - (17_800_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - } - fn set_payee() -> Weight { - (12_612_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (27_503_000 as Weight) + (26_437_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - fn set_validator_count() -> Weight { - (2_119_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn force_no_eras() -> Weight { - (2_320_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn force_new_era() -> Weight { - (2_269_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } + // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_334_000 as Weight) + (2_370_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - fn set_invulnerables(v: u32, ) -> Weight { - (2_354_000 as Weight) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (51_712_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_556_000 as Weight) + (61_438_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_377_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_367_105_000 as Weight) + (3_382_921_000 as Weight) // Standard Error: 222_000 - .saturating_add((19_817_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (47_229_000 as Weight) - // Standard Error: 53_000 - .saturating_add((48_365_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + // Storage: Staking Validators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (85_987_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (156_788_000 as Weight) - // Standard Error: 20_000 - .saturating_add((61_280_000 as Weight).saturating_mul(n as Weight)) + (154_336_000 as Weight) + // Standard Error: 22_000 + .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (47_815_000 as Weight) + (48_596_000 as Weight) // Standard Error: 1_000 - .saturating_add((65_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + // Storage: Staking SlashingSpans (r:21 w:0) + // Storage: Staking Validators (r:501 w:0) + // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) + // Storage: Staking Bonded (r:1500 w:0) + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 95_000 + .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 95_000 + .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_234_000 + .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_396_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_389_000 as Weight) + // Standard Error: 0 + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (117_261_000 as Weight) + // Standard Error: 15_000 + .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + fn chill() -> Weight { + (18_448_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) + fn set_payee() -> Weight { + (12_210_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking MinNominatorBond (r:1 w:0) + fn nominate(n: u32, ) -> Weight { + (41_518_000 as Weight) + // Standard Error: 11_000 + .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Validators (r:501 w:0) + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 28_000 + .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_332_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:2) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasValidatorPrefs (r:0 w:2) + // Storage: Staking HistoryDepth (r:1 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 74_000 - .saturating_add((34_945_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } + // Storage: Staking MaxValidatorsCount (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) + // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) + // Storage: Staking MaxNominatorsCount (r:0 w:1) + fn set_staking_limits() -> Weight { + (6_412_000 as Weight) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) + } + // Storage: Staking Bonded (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond_extra() -> Weight { + (56_614_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + fn validate() -> Weight { + (34_652_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_284_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + fn unbond() -> Weight { + (60_745_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Staking SpanSlash (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_483_000 as Weight) + (72_938_000 as Weight) // Standard Error: 0 - .saturating_add((2_384_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Bonded (r:101 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Nominators (r:101 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 846_000 - .saturating_add((305_234_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 847_000 + .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 42_000 - .saturating_add((48_280_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 99_000 - .saturating_add((25_735_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 99_000 - .saturating_add((28_122_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_388_000 - .saturating_add((21_500_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - } - fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 30_000 - .saturating_add((11_065_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - } - fn set_staking_limits() -> Weight { - (5_028_000 as Weight) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond() -> Weight { + (73_985_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MaxValidatorsCount (r:1 w:0) fn chill_other() -> Weight { - (35_758_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) + (61_381_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } } // For backwards compatibility and tests impl WeightInfo for () { - fn bond() -> Weight { - (72_617_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - } - fn bond_extra() -> Weight { - (55_590_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - fn unbond() -> Weight { - (59_730_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_279_000 as Weight) - // Standard Error: 0 - .saturating_add((68_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_629_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_379_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - fn validate() -> Weight { - (32_393_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (36_986_000 as Weight) - // Standard Error: 13_000 - .saturating_add((16_574_000 as Weight).saturating_mul(k as Weight)) + (15_687_000 as Weight) + // Standard Error: 10_000 + .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } - fn nominate(n: u32, ) -> Weight { - (43_228_000 as Weight) - // Standard Error: 21_000 - .saturating_add((5_119_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - fn chill() -> Weight { - (17_800_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - } - fn set_payee() -> Weight { - (12_612_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (27_503_000 as Weight) + (26_437_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - fn set_validator_count() -> Weight { - (2_119_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn force_no_eras() -> Weight { - (2_320_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn force_new_era() -> Weight { - (2_269_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } + // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_334_000 as Weight) + (2_370_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - fn set_invulnerables(v: u32, ) -> Weight { - (2_354_000 as Weight) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (51_712_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_556_000 as Weight) + (61_438_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_377_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_367_105_000 as Weight) + (3_382_921_000 as Weight) // Standard Error: 222_000 - .saturating_add((19_817_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (47_229_000 as Weight) - // Standard Error: 53_000 - .saturating_add((48_365_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + // Storage: Staking Validators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (85_987_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(8 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (156_788_000 as Weight) - // Standard Error: 20_000 - .saturating_add((61_280_000 as Weight).saturating_mul(n as Weight)) + (154_336_000 as Weight) + // Standard Error: 22_000 + .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (47_815_000 as Weight) + (48_596_000 as Weight) // Standard Error: 1_000 - .saturating_add((65_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: Staking SlashingSpans (r:21 w:0) + // Storage: Staking Validators (r:501 w:0) + // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) + // Storage: Staking Bonded (r:1500 w:0) + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 95_000 + .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 95_000 + .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_234_000 + .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_396_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_389_000 as Weight) + // Standard Error: 0 + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (117_261_000 as Weight) + // Standard Error: 15_000 + .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(10 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + fn chill() -> Weight { + (18_448_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) + fn set_payee() -> Weight { + (12_210_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking MinNominatorBond (r:1 w:0) + fn nominate(n: u32, ) -> Weight { + (41_518_000 as Weight) + // Standard Error: 11_000 + .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Validators (r:501 w:0) + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 28_000 + .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_332_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:2) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasValidatorPrefs (r:0 w:2) + // Storage: Staking HistoryDepth (r:1 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 74_000 - .saturating_add((34_945_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } + // Storage: Staking MaxValidatorsCount (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) + // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) + // Storage: Staking MaxNominatorsCount (r:0 w:1) + fn set_staking_limits() -> Weight { + (6_412_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + } + // Storage: Staking Bonded (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond_extra() -> Weight { + (56_614_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + fn validate() -> Weight { + (34_652_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_284_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + fn unbond() -> Weight { + (60_745_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + } + // Storage: Staking SpanSlash (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_483_000 as Weight) + (72_938_000 as Weight) // Standard Error: 0 - .saturating_add((2_384_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Bonded (r:101 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Nominators (r:101 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 846_000 - .saturating_add((305_234_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 847_000 + .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 42_000 - .saturating_add((48_280_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 99_000 - .saturating_add((25_735_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 99_000 - .saturating_add((28_122_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_388_000 - .saturating_add((21_500_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - } - fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 30_000 - .saturating_add((11_065_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - } - fn set_staking_limits() -> Weight { - (5_028_000 as Weight) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond() -> Weight { + (73_985_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MaxValidatorsCount (r:1 w:0) fn chill_other() -> Weight { - (35_758_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + (61_381_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } } From cd015877e2dfebcf1ed17c0aaecf01798a6192c6 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 20 Jul 2021 23:01:33 -0400 Subject: [PATCH 07/73] use linked map to keep order --- Cargo.lock | 1 + utils/frame/benchmarking-cli/Cargo.toml | 1 + utils/frame/benchmarking-cli/src/command.rs | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd6bcff83fd57..4d0013fc2dbe0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1800,6 +1800,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "handlebars", + "linked-hash-map", "parity-scale-codec", "sc-cli", "sc-client-db", diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 9bae971019779..e9445b03971f8 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -30,6 +30,7 @@ chrono = "0.4" serde = "1.0.126" handlebars = "3.5.0" Inflector = "0.11.4" +linked-hash-map = "0.5.4" [features] default = ["db"] diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 5007f1e31c4d6..5ee8119bad39d 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -31,14 +31,15 @@ use sp_externalities::Extensions; use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use sp_state_machine::StateMachine; -use std::{fmt::Debug, sync::Arc, collections::HashMap}; +use std::{fmt::Debug, sync::Arc}; +use linked_hash_map::LinkedHashMap; // This takes multiple benchmark batches and combines all the results where the pallet, instance, // and benchmark are the same. fn combine_batches(batches: Vec) -> Vec { if batches.is_empty() { return batches } - let mut all_benchmarks = HashMap::<_, Vec>::new(); + let mut all_benchmarks = LinkedHashMap::<_, Vec>::new(); batches.into_iter().for_each(|BenchmarkBatch { pallet, instance, benchmark, results }| { // We use this key to uniquely identify a benchmark among batches. From d0184a03f437cd5484e60cd7d9bd18cf73097a45 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Wed, 21 Jul 2021 03:06:51 +0000 Subject: [PATCH 08/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index 1e665807c3333..160ec851dde01 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -44,50 +44,50 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. pub trait WeightInfo { - fn set_balance_creating() -> Weight; + fn transfer() -> Weight; fn transfer_keep_alive() -> Weight; + fn set_balance_creating() -> Weight; + fn set_balance_killing() -> Weight; fn force_transfer() -> Weight; - fn transfer() -> Weight; fn transfer_all() -> Weight; - fn set_balance_killing() -> Weight; } /// Weights for pallet_balances using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_439_000 as Weight) + fn transfer() -> Weight { + (78_138_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (55_632_000 as Weight) + (57_454_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) - fn force_transfer() -> Weight { - (74_593_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (75_298_000 as Weight) + fn set_balance_creating() -> Weight { + (31_664_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (68_792_000 as Weight) + fn set_balance_killing() -> Weight { + (37_901_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) + fn force_transfer() -> Weight { + (76_515_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } // Storage: System Account (r:1 w:1) - fn set_balance_killing() -> Weight { - (37_101_000 as Weight) + fn transfer_all() -> Weight { + (71_007_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -96,38 +96,38 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_439_000 as Weight) + fn transfer() -> Weight { + (78_138_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (55_632_000 as Weight) + (57_454_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) - fn force_transfer() -> Weight { - (74_593_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (75_298_000 as Weight) + fn set_balance_creating() -> Weight { + (31_664_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (68_792_000 as Weight) + fn set_balance_killing() -> Weight { + (37_901_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) + fn force_transfer() -> Weight { + (76_515_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } // Storage: System Account (r:1 w:1) - fn set_balance_killing() -> Weight { - (37_101_000 as Weight) + fn transfer_all() -> Weight { + (71_007_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From 31810d92592a632e2b489211a1fe59dc964ddb1d Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 20 Jul 2021 23:08:44 -0400 Subject: [PATCH 09/73] Delete pallet_balances.rs --- pallet_balances.rs | 123 --------------------------------------------- 1 file changed, 123 deletions(-) delete mode 100644 pallet_balances.rs diff --git a/pallet_balances.rs b/pallet_balances.rs deleted file mode 100644 index a6980d4d6e843..0000000000000 --- a/pallet_balances.rs +++ /dev/null @@ -1,123 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for pallet_balances -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Interpreted, CHAIN: Some("dev"), DB CACHE: 128 - -// Executed Command: -// target/release/substrate -// benchmark -// --chain=dev -// --steps=50 -// --repeat=10 -// --pallet=pallet_balances -// --extrinsic=* -// --execution=wasm -// --wasm-execution=interpreted-i-know-what-i-do -// --heap-pages=4096 -// --output=./ -// --template=./.maintain/frame-weight-template.hbs -// --raw - - -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_balances. -pub trait WeightInfo { - fn force_transfer() -> Weight; - fn transfer_all() -> Weight; - fn transfer() -> Weight; - fn transfer_keep_alive() -> Weight; - fn set_balance_creating() -> Weight; - fn set_balance_killing() -> Weight; -} - -/// Weights for pallet_balances using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - fn force_transfer() -> Weight { - (330_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - fn transfer_all() -> Weight { - (327_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer() -> Weight { - (335_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (262_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_balance_creating() -> Weight { - (103_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (124_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - fn force_transfer() -> Weight { - (330_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - fn transfer_all() -> Weight { - (327_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn transfer() -> Weight { - (335_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (262_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn set_balance_creating() -> Weight { - (103_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (124_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } -} From 1ab00664451051b8ed8bf7a0e23af56a89ec72b3 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 20 Jul 2021 23:08:55 -0400 Subject: [PATCH 10/73] Delete out --- out | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 out diff --git a/out b/out deleted file mode 100644 index e69de29bb2d1d..0000000000000 From 257fbbbcb77aefa33391f6ec7ccd849185975d9d Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Wed, 21 Jul 2021 04:10:27 +0000 Subject: [PATCH 11/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/staking/src/weights.rs | 962 +++++++++++++++++------------------ 1 file changed, 481 insertions(+), 481 deletions(-) diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index d9fdfda7b5a8c..fcce4276c9f5a 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -44,696 +44,696 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_staking. pub trait WeightInfo { + fn bond() -> Weight; + fn bond_extra() -> Weight; + fn unbond() -> Weight; + fn withdraw_unbonded_update(s: u32, ) -> Weight; + fn withdraw_unbonded_kill(s: u32, ) -> Weight; + fn validate() -> Weight; fn kick(k: u32, ) -> Weight; + fn nominate(n: u32, ) -> Weight; + fn chill() -> Weight; + fn set_payee() -> Weight; fn set_controller() -> Weight; + fn set_validator_count() -> Weight; + fn force_no_eras() -> Weight; + fn force_new_era() -> Weight; fn force_new_era_always() -> Weight; - fn withdraw_unbonded_update(s: u32, ) -> Weight; + fn set_invulnerables(v: u32, ) -> Weight; fn force_unstake(s: u32, ) -> Weight; fn cancel_deferred_slash(s: u32, ) -> Weight; - fn withdraw_unbonded_kill(s: u32, ) -> Weight; + fn payout_stakers_dead_controller(n: u32, ) -> Weight; fn payout_stakers_alive_staked(n: u32, ) -> Weight; fn rebond(l: u32, ) -> Weight; - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight; - fn force_no_eras() -> Weight; - fn set_invulnerables(v: u32, ) -> Weight; - fn payout_stakers_dead_controller(n: u32, ) -> Weight; - fn chill() -> Weight; - fn set_payee() -> Weight; - fn nominate(n: u32, ) -> Weight; - fn get_npos_targets(v: u32, ) -> Weight; - fn force_new_era() -> Weight; fn set_history_depth(e: u32, ) -> Weight; - fn set_staking_limits() -> Weight; - fn bond_extra() -> Weight; - fn validate() -> Weight; - fn set_validator_count() -> Weight; - fn unbond() -> Weight; fn reap_stash(s: u32, ) -> Weight; fn new_era(v: u32, n: u32, ) -> Weight; - fn bond() -> Weight; + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight; + fn get_npos_targets(v: u32, ) -> Weight; + fn set_staking_limits() -> Weight; fn chill_other() -> Weight; } /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn bond() -> Weight { + (73_506_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + fn bond_extra() -> Weight { + (57_019_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn unbond() -> Weight { + (61_257_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Staking Ledger (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: System Account (r:1 w:1) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (52_060_000 as Weight) + // Standard Error: 0 + .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (86_303_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + fn validate() -> Weight { + (35_189_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (15_687_000 as Weight) + (16_161_000 as Weight) // Standard Error: 10_000 - .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking MinNominatorBond (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + fn nominate(n: u32, ) -> Weight { + (41_638_000 as Weight) + // Standard Error: 9_000 + .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + fn chill() -> Weight { + (18_707_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + fn set_payee() -> Weight { + (12_688_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_437_000 as Weight) + (26_726_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_309_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_508_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_483_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_370_000 as Weight) + (2_487_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (51_712_000 as Weight) + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_465_000 as Weight) // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_438_000 as Weight) + (62_075_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_382_921_000 as Weight) - // Standard Error: 222_000 - .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) + (3_403_675_000 as Weight) + // Standard Error: 223_000 + .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Staking Validators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:2) - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (85_987_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Staking Bonded (r:2 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (111_168_000 as Weight) + // Standard Error: 17_000 + .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } // Storage: Staking Ledger (r:2 w:2) // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:2 w:2) // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasRewardPoints (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (154_336_000 as Weight) + (148_375_000 as Weight) // Standard Error: 22_000 - .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Balances Locks (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_596_000 as Weight) - // Standard Error: 1_000 - .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) + (48_669_000 as Weight) + // Standard Error: 2_000 + .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Validators (r:501 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:2) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasValidatorPrefs (r:0 w:2) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) + fn set_history_depth(e: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 70_000 + .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) + } + // Storage: System Account (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) + fn reap_stash(s: u32, ) -> Weight { + (73_475_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().writes(8 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking Nominators (r:101 w:0) + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Bonded (r:101 w:0) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) + fn new_era(v: u32, n: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 970_000 + .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 48_000 + .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking Bonded (r:1500 w:0) // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking SlashingSpans (r:21 w:0) // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Validators (r:501 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { (0 as Weight) - // Standard Error: 95_000 - .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 95_000 - .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_234_000 - .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) + // Standard Error: 102_000 + .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 102_000 + .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_473_000 + .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking ForceEra (r:0 w:1) - fn force_no_eras() -> Weight { - (2_396_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Invulnerables (r:0 w:1) - fn set_invulnerables(v: u32, ) -> Weight { - (2_389_000 as Weight) - // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (117_261_000 as Weight) - // Standard Error: 15_000 - .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - fn chill() -> Weight { - (18_448_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - } - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:0) - fn set_payee() -> Weight { - (12_210_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - fn nominate(n: u32, ) -> Weight { - (41_518_000 as Weight) - // Standard Error: 11_000 - .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { (0 as Weight) - // Standard Error: 28_000 - .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 29_000 + .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) } - // Storage: Staking ForceEra (r:0 w:1) - fn force_new_era() -> Weight { - (2_332_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:2) - // Storage: Staking ErasValidatorReward (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking ErasValidatorPrefs (r:0 w:2) - // Storage: Staking HistoryDepth (r:1 w:1) - fn set_history_depth(e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 68_000 - .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) - } + // Storage: Staking MaxNominatorsCount (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_limits() -> Weight { - (6_412_000 as Weight) + (6_599_000 as Weight) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - fn bond_extra() -> Weight { - (56_614_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Validators (r:1 w:1) - fn validate() -> Weight { - (34_652_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) + fn chill_other() -> Weight { + (62_743_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: Staking ValidatorCount (r:0 w:1) - fn set_validator_count() -> Weight { - (2_284_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) +} + +// For backwards compatibility and tests +impl WeightInfo for () { + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn bond() -> Weight { + (73_506_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) + fn bond_extra() -> Weight { + (57_019_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) fn unbond() -> Weight { - (60_745_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + (61_257_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking SpanSlash (r:0 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Validators (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) // Storage: System Account (r:1 w:1) - fn reap_stash(s: u32, ) -> Weight { - (72_938_000 as Weight) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (52_060_000 as Weight) // Standard Error: 0 - .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: System BlockWeight (r:1 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:0 w:1) - // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking CounterForNominators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking Ledger (r:101 w:0) - // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) - fn new_era(v: u32, n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 847_000 - .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 42_000 - .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking Bonded (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) - fn bond() -> Weight { - (73_985_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (86_303_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(8 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Validators (r:1 w:1) // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking MaxValidatorsCount (r:1 w:0) - fn chill_other() -> Weight { - (61_381_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + fn validate() -> Weight { + (35_189_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } -} - -// For backwards compatibility and tests -impl WeightInfo for () { // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (15_687_000 as Weight) + (16_161_000 as Weight) // Standard Error: 10_000 - .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking MinNominatorBond (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + fn nominate(n: u32, ) -> Weight { + (41_638_000 as Weight) + // Standard Error: 9_000 + .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + fn chill() -> Weight { + (18_707_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + fn set_payee() -> Weight { + (12_688_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_437_000 as Weight) + (26_726_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_309_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_508_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_483_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_370_000 as Weight) + (2_487_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (51_712_000 as Weight) + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_465_000 as Weight) // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_438_000 as Weight) + (62_075_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_382_921_000 as Weight) - // Standard Error: 222_000 - .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) + (3_403_675_000 as Weight) + // Standard Error: 223_000 + .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Staking Validators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:2) - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (85_987_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Staking Bonded (r:2 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (111_168_000 as Weight) + // Standard Error: 17_000 + .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(10 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } // Storage: Staking Ledger (r:2 w:2) // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:2 w:2) // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasRewardPoints (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (154_336_000 as Weight) + (148_375_000 as Weight) // Standard Error: 22_000 - .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Balances Locks (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_596_000 as Weight) - // Standard Error: 1_000 - .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) + (48_669_000 as Weight) + // Standard Error: 2_000 + .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Validators (r:501 w:0) - // Storage: Staking Ledger (r:1500 w:0) - // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Bonded (r:1500 w:0) - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 95_000 - .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 95_000 - .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_234_000 - .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Staking ForceEra (r:0 w:1) - fn force_no_eras() -> Weight { - (2_396_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Invulnerables (r:0 w:1) - fn set_invulnerables(v: u32, ) -> Weight { - (2_389_000 as Weight) - // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (117_261_000 as Weight) - // Standard Error: 15_000 - .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - fn chill() -> Weight { - (18_448_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - } - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:0) - fn set_payee() -> Weight { - (12_210_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Validators (r:2 w:0) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - fn nominate(n: u32, ) -> Weight { - (41_518_000 as Weight) - // Standard Error: 11_000 - .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Staking Validators (r:501 w:0) - fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 28_000 - .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - } - // Storage: Staking ForceEra (r:0 w:1) - fn force_new_era() -> Weight { - (2_332_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:2) - // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasRewardPoints (r:0 w:1) // Storage: Staking ErasValidatorPrefs (r:0 w:2) - // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 68_000 - .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 70_000 + .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } - // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) - // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) - fn set_staking_limits() -> Weight { - (6_412_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - fn bond_extra() -> Weight { - (56_614_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) - fn validate() -> Weight { - (34_652_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Staking ValidatorCount (r:0 w:1) - fn set_validator_count() -> Weight { - (2_284_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) - fn unbond() -> Weight { - (60_745_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } - // Storage: Staking SpanSlash (r:0 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Validators (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (72_938_000 as Weight) - // Standard Error: 0 - .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) + (73_475_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking Nominators (r:101 w:0) // Storage: Staking Validators (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:0 w:1) - // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking CounterForNominators (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking Ledger (r:101 w:0) // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 847_000 - .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 42_000 - .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 970_000 + .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 48_000 + .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - fn bond() -> Weight { - (73_985_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking SlashingSpans (r:21 w:0) + // Storage: Staking Nominators (r:1001 w:0) + // Storage: Staking Validators (r:501 w:0) + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 102_000 + .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 102_000 + .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_473_000 + .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking Validators (r:501 w:0) + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 29_000 + .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking MaxNominatorsCount (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) + // Storage: Staking MaxValidatorsCount (r:0 w:1) + // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) + fn set_staking_limits() -> Weight { + (6_599_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) - // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Validators (r:1 w:1) // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) fn chill_other() -> Weight { - (61_381_000 as Weight) + (62_743_000 as Weight) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From ca5cdc5092ecf99f5fefb856ee349e36d59464d1 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 21 Jul 2021 21:14:24 -0400 Subject: [PATCH 12/73] steps and repeat to tuple (current_*, total_*) --- frame/benchmarking/src/lib.rs | 29 ++++++++++++--------- frame/benchmarking/src/utils.rs | 19 +++++++++++--- utils/frame/benchmarking-cli/src/command.rs | 5 ++-- utils/frame/benchmarking-cli/src/lib.rs | 4 +-- utils/frame/benchmarking-cli/src/writer.rs | 2 +- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 0ee4297cd8725..eda819e8e9f08 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -702,7 +702,8 @@ macro_rules! impl_benchmark { extrinsic: &[u8], lowest_range_values: &[u32], highest_range_values: &[u32], - steps: &[u32], + steps: (u32, u32), + repeat: (u32, u32), whitelist: &[$crate::TrackedStorageKey], verify: bool, ) -> Result<$crate::Vec<$crate::BenchmarkResults>, &'static str> { @@ -733,8 +734,6 @@ macro_rules! impl_benchmark { >::components(&selected_benchmark); let mut progress = $crate::benchmarking::current_time(); - // Default number of steps for a component. - let mut prev_steps = 10; let mut do_benchmark = | c: &[($crate::BenchmarkParameter, u32)], @@ -848,11 +847,7 @@ macro_rules! impl_benchmark { // Select the component we will be benchmarking. Each component will be benchmarked. for (idx, (name, low, high)) in components.iter().enumerate() { // Get the number of steps for this component. - let steps = steps.get(idx).cloned().unwrap_or(prev_steps); - prev_steps = steps; - - // Skip this loop if steps is zero - if steps == 0 { continue } + let (_current_step, total_steps) = steps; let lowest = lowest_range_values.get(idx).cloned().unwrap_or(*low); let highest = highest_range_values.get(idx).cloned().unwrap_or(*high); @@ -860,7 +855,7 @@ macro_rules! impl_benchmark { let diff = highest - lowest; // Create up to `STEPS` steps for that component between high and low. - let step_size = (diff / steps).max(1); + let step_size = (diff / total_steps).max(1); let num_of_steps = diff / step_size + 1; for s in 0..num_of_steps { @@ -1235,7 +1230,8 @@ pub fn show_benchmark_debug_info( benchmark: &[u8], lowest_range_values: &sp_std::prelude::Vec, highest_range_values: &sp_std::prelude::Vec, - steps: &sp_std::prelude::Vec, + steps: &(u32, u32), + repeat: &(u32, u32), verify: &bool, error_message: &str, ) -> sp_runtime::RuntimeString { @@ -1245,6 +1241,7 @@ pub fn show_benchmark_debug_info( * Lowest_range_values: {:?}\n\ * Highest_range_values: {:?}\n\ * Steps: {:?}\n\ + * Repeat: {:?}\n\ * Verify: {:?}\n\ * Error message: {}", sp_std::str::from_utf8(instance_string) @@ -1253,7 +1250,8 @@ pub fn show_benchmark_debug_info( .expect("it's all just strings ran through the wasm interface. qed"), lowest_range_values, highest_range_values, - steps, + steps.1, + repeat.1, verify, error_message, ) @@ -1334,6 +1332,7 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, + repeat, verify, extra, } = config; @@ -1348,7 +1347,8 @@ macro_rules! add_benchmark { benchmark, &lowest_range_values[..], &highest_range_values[..], - &steps[..], + *steps, + *repeat, whitelist, *verify, ).map_err(|e| { @@ -1358,6 +1358,7 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, + repeat, verify, e, ) @@ -1373,7 +1374,8 @@ macro_rules! add_benchmark { &benchmark[..], &lowest_range_values[..], &highest_range_values[..], - &steps[..], + *steps, + *repeat, whitelist, *verify, ).map_err(|e| { @@ -1383,6 +1385,7 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, + repeat, verify, e, ) diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 2552be18fe3be..5ef332264c545 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -78,8 +78,10 @@ pub struct BenchmarkConfig { pub lowest_range_values: Vec, /// An optional manual override to the highest values used in the `steps` range. pub highest_range_values: Vec, - /// The number of samples to take across the range of values for components. - pub steps: Vec, + /// The number of samples to take across the range of values for components. (current_step, total_steps) + pub steps: (u32, u32), + /// The number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeat) + pub repeat: (u32, u32), /// Enable an extra benchmark iteration which runs the verification logic for a benchmark. pub verify: bool, /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a pallet. @@ -89,6 +91,13 @@ pub struct BenchmarkConfig { sp_api::decl_runtime_apis! { /// Runtime api for benchmarking a FRAME runtime. pub trait Benchmark { + /// Get the benchmarks available for this runtime. + /// + /// Parameters + /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be + /// needed for weight calculation. + //fn benchmarks(extra: bool) -> Vec<(&'static [u8], Vec<&'static [u8])>; + /// Dispatch the given benchmark. fn dispatch_benchmark(config: BenchmarkConfig) -> Result<(Vec, Vec), sp_runtime::RuntimeString>; @@ -188,14 +197,16 @@ pub trait Benchmarking { /// Parameters /// - `name`: The name of extrinsic function or benchmark you want to benchmark encoded as /// bytes. - /// - `steps`: The number of sample points you want to take across the range of parameters. /// - `lowest_range_values`: The lowest number for each range of parameters. /// - `highest_range_values`: The highest number for each range of parameters. + /// - `steps`: The number of sample points you want to take across the range of parameters. (current_step, total_steps) + /// - `repeat`: The total number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeats) fn run_benchmark( name: &[u8], lowest_range_values: &[u32], highest_range_values: &[u32], - steps: &[u32], + steps: (u32, u32), + repeat: (u32, u32), whitelist: &[TrackedStorageKey], verify: bool, ) -> Result, &'static str>; diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 5ee8119bad39d..c0de1bf4c11e9 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -100,7 +100,7 @@ impl BenchmarkCmd { let mut batches = Vec::new(); let mut storage_info = Vec::new(); - for _r in 0 .. self.repeat { + for r in 0 .. self.repeat { let mut extensions = Extensions::default(); extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); let (offchain, _) = TestOffchainExt::new(); @@ -120,7 +120,8 @@ impl BenchmarkCmd { &self.extrinsic, self.lowest_range_values.clone(), self.highest_range_values.clone(), - self.steps.clone(), + (self.steps, self.steps), + (r, self.repeat), !self.no_verify, self.extra, ).encode(), diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index 0642ddabc1374..e5cf568c5d179 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -39,8 +39,8 @@ pub struct BenchmarkCmd { pub extrinsic: String, /// Select how many samples we should take across the variable components. - #[structopt(short, long, use_delimiter = true)] - pub steps: Vec, + #[structopt(short, long, default_value = "1")] + pub steps: u32, /// Indicates lowest values for each of the component ranges. #[structopt(long = "low", use_delimiter = true)] diff --git a/utils/frame/benchmarking-cli/src/writer.rs b/utils/frame/benchmarking-cli/src/writer.rs index 64a4ea62f0d4c..ff736daf5e643 100644 --- a/utils/frame/benchmarking-cli/src/writer.rs +++ b/utils/frame/benchmarking-cli/src/writer.rs @@ -69,7 +69,7 @@ struct BenchmarkData { // This forwards some specific metadata from the `BenchmarkCmd` #[derive(Serialize, Default, Debug, Clone)] struct CmdData { - steps: Vec, + steps: u32, repeat: u32, lowest_range_values: Vec, highest_range_values: Vec, From f42d16f7b193a72aa67e185739f1c2dc60572ad9 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 21 Jul 2021 23:41:21 -0400 Subject: [PATCH 13/73] idea for list command --- bin/node/runtime/src/lib.rs | 15 ++++++ frame/benchmarking/src/utils.rs | 8 ++- utils/frame/benchmarking-cli/src/command.rs | 59 +++++++++++++++++++++ utils/frame/benchmarking-cli/src/lib.rs | 4 ++ 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 4c8f1a8298704..87f7b5a5278e1 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1528,6 +1528,21 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { + fn benchmarks(extra: bool) -> Vec { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + + let benchmarks = Assets::benchmarks(extra) + .iter() + .map(|b| b.to_vec()) + .collect::>(); + let list = BenchmarkList { + pallet: b"Balances".to_vec(), + benchmarks: benchmarks.to_vec(), + }; + + return vec![list] + } + fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result< diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 5ef332264c545..212f450f70d03 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -88,6 +88,12 @@ pub struct BenchmarkConfig { pub extra: bool, } +#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] +pub struct BenchmarkList { + pub pallet: Vec, + pub benchmarks: Vec>, +} + sp_api::decl_runtime_apis! { /// Runtime api for benchmarking a FRAME runtime. pub trait Benchmark { @@ -96,7 +102,7 @@ sp_api::decl_runtime_apis! { /// Parameters /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be /// needed for weight calculation. - //fn benchmarks(extra: bool) -> Vec<(&'static [u8], Vec<&'static [u8])>; + fn benchmarks(extra: bool) -> Vec; /// Dispatch the given benchmark. fn dispatch_benchmark(config: BenchmarkConfig) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index c0de1bf4c11e9..da25d1c8e305a 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -69,6 +69,7 @@ impl BenchmarkCmd { ::Hash: std::str::FromStr, ExecDispatch: NativeExecutionDispatch + 'static, { + if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { return Err("Output file or path is invalid!".into()) @@ -109,6 +110,34 @@ impl BenchmarkCmd { extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); + if self.list { + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_benchmarks", + &(self.extra).encode(), + extensions, + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), + ) + .execute(strategy.into()) + .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; + + let lists = as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + + for list in lists { + println!("{}", String::from_utf8(list.pallet).unwrap()); + for benchmark in list.benchmarks { + println!("- {}", String::from_utf8(benchmark).unwrap()); + } + } + + return Ok(()) + } + let result = StateMachine::<_, _, NumberFor, _>::new( &state, None, @@ -239,3 +268,33 @@ impl CliConfiguration for BenchmarkCmd { }) } } + +// fn list(extra: bool) -> Result<()> +// where +// BB: BlockT + Debug, +// <<::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug, +// ::Hash: std::str::FromStr, +// { +// let result = StateMachine::<_, _, NumberFor, _>::new( +// &state, +// None, +// &mut changes, +// &executor, +// "Benchmark_benchmarks", +// &(extra).encode(), +// extensions, +// &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, +// sp_core::testing::TaskExecutor::new(), +// ) +// .execute(strategy.into()) +// .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; + +// let list = , +// String, +// > as Decode>::decode(&mut &result[..]) +// .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))??; + +// println!("{:?}", list); +// Ok(()) +// } diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index e5cf568c5d179..d66e59bde0cbd 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -129,4 +129,8 @@ pub struct BenchmarkCmd { /// Limit the memory the database cache can use. #[structopt(long = "db-cache", value_name = "MiB", default_value = "128")] pub database_cache_size: u32, + + /// List the benchmarks available + #[structopt(long)] + pub list: bool, } From 81a7e779d346a649af5878be0834ed07056cc282 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 29 Jul 2021 22:17:07 +0200 Subject: [PATCH 14/73] fmt --- utils/frame/benchmarking-cli/src/command.rs | 104 ++++++++++++-------- 1 file changed, 65 insertions(+), 39 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 12b4f9d58fc69..b84737e02d253 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -17,8 +17,9 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; -use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkSelector, BenchmarkResults}; +use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector}; use frame_support::traits::StorageInfo; +use linked_hash_map::LinkedHashMap; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; use sc_client_db::BenchmarkingState; use sc_executor::NativeExecutor; @@ -32,32 +33,41 @@ use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use sp_state_machine::StateMachine; use std::{fmt::Debug, sync::Arc}; -use linked_hash_map::LinkedHashMap; // This takes multiple benchmark batches and combines all the results where the pallet, instance, // and benchmark are the same. fn combine_batches(batches: Vec) -> Vec { - if batches.is_empty() { return batches } + if batches.is_empty() { + return batches + } let mut all_benchmarks = LinkedHashMap::<_, Vec>::new(); - batches.into_iter().for_each(|BenchmarkBatch { pallet, instance, benchmark, results }| { - // We use this key to uniquely identify a benchmark among batches. - let key = (pallet, instance, benchmark); - - match all_benchmarks.get_mut(&key) { - // We already have this benchmark, so we extend the results. - Some(x) => x.extend(results), - // New benchmark, so we add a new entry with the initial results. - None => { - all_benchmarks.insert(key, results); - }, - } - }); - - all_benchmarks.into_iter().map(|((pallet, instance, benchmark), results)| { - BenchmarkBatch { pallet, instance, benchmark, results } - }).collect::>() + batches + .into_iter() + .for_each(|BenchmarkBatch { pallet, instance, benchmark, results }| { + // We use this key to uniquely identify a benchmark among batches. + let key = (pallet, instance, benchmark); + + match all_benchmarks.get_mut(&key) { + // We already have this benchmark, so we extend the results. + Some(x) => x.extend(results), + // New benchmark, so we add a new entry with the initial results. + None => { + all_benchmarks.insert(key, results); + }, + } + }); + + all_benchmarks + .into_iter() + .map(|((pallet, instance, benchmark), results)| BenchmarkBatch { + pallet, + instance, + benchmark, + results, + }) + .collect::>() } impl BenchmarkCmd { @@ -69,7 +79,6 @@ impl BenchmarkCmd { ::Hash: std::str::FromStr, ExecDispatch: NativeExecutionDispatch + 'static, { - if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { return Err("Output file or path is invalid!".into()) @@ -105,7 +114,7 @@ impl BenchmarkCmd { let mut batches = Vec::new(); let mut storage_info = Vec::new(); - for r in 0 .. self.repeat { + for r in 0..self.repeat { let mut extensions = Extensions::default(); extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); let (offchain, _) = TestOffchainExt::new(); @@ -129,8 +138,9 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let lists = as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + let lists = + as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; for list in lists { println!("{}", String::from_utf8(list.pallet).unwrap()); @@ -157,7 +167,8 @@ impl BenchmarkCmd { (r, self.repeat), !self.no_verify, self.extra, - ).encode(), + ) + .encode(), extensions, &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, sp_core::testing::TaskExecutor::new(), @@ -166,10 +177,10 @@ impl BenchmarkCmd { .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; let (batch, last_storage_info) = , Vec), - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; + (Vec, Vec), + String, + > as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; batches.extend(batch); storage_info = last_storage_info; @@ -178,7 +189,8 @@ impl BenchmarkCmd { let batches = combine_batches(batches); for b in batches.clone() { - println!("{:?}: {:?}", + println!( + "{:?}: {:?}", String::from_utf8(b.pallet).unwrap(), String::from_utf8(b.benchmark).unwrap(), ); @@ -201,7 +213,9 @@ impl BenchmarkCmd { ); // Skip raw data + analysis if there are no results - if batch.results.is_empty() { continue } + if batch.results.is_empty() { + continue + } if self.raw_data { // Print the table header @@ -210,11 +224,11 @@ impl BenchmarkCmd { print!("extrinsic_time_ns,storage_root_time_ns,reads,repeat_reads,writes,repeat_writes,proof_size_bytes\n"); // Print the values batch.results.iter().for_each(|result| { - let parameters = &result.components; parameters.iter().for_each(|param| print!("{:?},", param.1)); // Print extrinsic time and storage root time - print!("{:?},{:?},{:?},{:?},{:?},{:?},{:?}\n", + print!( + "{:?},{:?},{:?},{:?},{:?},{:?},{:?}\n", result.extrinsic_time, result.storage_root_time, result.reads, @@ -231,25 +245,37 @@ impl BenchmarkCmd { // Conduct analysis. if !self.no_median_slopes { println!("Median Slopes Analysis\n========"); - if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::ExtrinsicTime) { + if let Some(analysis) = + Analysis::median_slopes(&batch.results, BenchmarkSelector::ExtrinsicTime) + { println!("-- Extrinsic Time --\n{}", analysis); } - if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::Reads) { + if let Some(analysis) = + Analysis::median_slopes(&batch.results, BenchmarkSelector::Reads) + { println!("Reads = {:?}", analysis); } - if let Some(analysis) = Analysis::median_slopes(&batch.results, BenchmarkSelector::Writes) { + if let Some(analysis) = + Analysis::median_slopes(&batch.results, BenchmarkSelector::Writes) + { println!("Writes = {:?}", analysis); } } if !self.no_min_squares { println!("Min Squares Analysis\n========"); - if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::ExtrinsicTime) { + if let Some(analysis) = + Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::ExtrinsicTime) + { println!("-- Extrinsic Time --\n{}", analysis); } - if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Reads) { + if let Some(analysis) = + Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Reads) + { println!("Reads = {:?}", analysis); } - if let Some(analysis) = Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Writes) { + if let Some(analysis) = + Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Writes) + { println!("Writes = {:?}", analysis); } } From 9467179b5869ae91bd00feae0c841e3d68583a9c Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 12:22:58 +0200 Subject: [PATCH 15/73] use benchmark list in cli --- bin/node/runtime/src/lib.rs | 64 ++++++-- frame/benchmarking/src/lib.rs | 100 ++++++------ frame/benchmarking/src/utils.rs | 1 + utils/frame/benchmarking-cli/src/command.rs | 163 +++++++++----------- 4 files changed, 168 insertions(+), 160 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d7b1bdce8ff01..419178d9500eb 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1535,18 +1535,54 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmarks(extra: bool) -> Vec { - use frame_benchmarking::{Benchmarking, BenchmarkList}; - - let benchmarks = Assets::benchmarks(extra) - .iter() - .map(|b| b.to_vec()) - .collect::>(); - let list = BenchmarkList { - pallet: b"Balances".to_vec(), - benchmarks: benchmarks.to_vec(), - }; - - return vec![list] + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + + // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency + // issues. To get around that, we separated the Session benchmarks into its own crate, + // which is why we need these two lines below. + use pallet_session_benchmarking::Pallet as SessionBench; + use pallet_offences_benchmarking::Pallet as OffencesBench; + use frame_system_benchmarking::Pallet as SystemBench; + + impl pallet_session_benchmarking::Config for Runtime {} + impl pallet_offences_benchmarking::Config for Runtime {} + impl frame_system_benchmarking::Config for Runtime {} + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, pallet_assets, Assets); + list_benchmark!(list, extra, pallet_babe, Babe); + list_benchmark!(list, extra, pallet_balances, Balances); + list_benchmark!(list, extra, pallet_bounties, Bounties); + list_benchmark!(list, extra, pallet_collective, Council); + list_benchmark!(list, extra, pallet_contracts, Contracts); + list_benchmark!(list, extra, pallet_democracy, Democracy); + list_benchmark!(list, extra, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); + list_benchmark!(list, extra, pallet_elections_phragmen, Elections); + list_benchmark!(list, extra, pallet_gilt, Gilt); + list_benchmark!(list, extra, pallet_grandpa, Grandpa); + list_benchmark!(list, extra, pallet_identity, Identity); + list_benchmark!(list, extra, pallet_im_online, ImOnline); + list_benchmark!(list, extra, pallet_indices, Indices); + list_benchmark!(list, extra, pallet_lottery, Lottery); + list_benchmark!(list, extra, pallet_membership, TechnicalMembership); + list_benchmark!(list, extra, pallet_mmr, Mmr); + list_benchmark!(list, extra, pallet_multisig, Multisig); + list_benchmark!(list, extra, pallet_offences, OffencesBench::); + list_benchmark!(list, extra, pallet_proxy, Proxy); + list_benchmark!(list, extra, pallet_scheduler, Scheduler); + list_benchmark!(list, extra, pallet_session, SessionBench::); + list_benchmark!(list, extra, pallet_staking, Staking); + list_benchmark!(list, extra, frame_system, SystemBench::); + list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_tips, Tips); + list_benchmark!(list, extra, pallet_transaction_storage, TransactionStorage); + list_benchmark!(list, extra, pallet_treasury, Treasury); + list_benchmark!(list, extra, pallet_uniques, Uniques); + list_benchmark!(list, extra, pallet_utility, Utility); + list_benchmark!(list, extra, pallet_vesting, Vesting); + + return list } fn dispatch_benchmark( @@ -1565,10 +1601,6 @@ impl_runtime_apis! { use pallet_offences_benchmarking::Pallet as OffencesBench; use frame_system_benchmarking::Pallet as SystemBench; - impl pallet_session_benchmarking::Config for Runtime {} - impl pallet_offences_benchmarking::Config for Runtime {} - impl frame_system_benchmarking::Config for Runtime {} - let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index d323d1e0b0a64..f6952c5a4beb2 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -1344,62 +1344,50 @@ macro_rules! add_benchmark { verify, extra, } = config; - if &pallet[..] == &name_string[..] || &pallet[..] == &b"*"[..] { - if &pallet[..] == &b"*"[..] || &benchmark[..] == &b"*"[..] { - for benchmark in $( $location )*::benchmarks(*extra).into_iter() { - $batches.push($crate::BenchmarkBatch { - pallet: name_string.to_vec(), - instance: instance_string.to_vec(), - benchmark: benchmark.to_vec(), - results: $( $location )*::run_benchmark( - benchmark, - &lowest_range_values[..], - &highest_range_values[..], - *steps, - *repeat, - whitelist, - *verify, - ).map_err(|e| { - $crate::show_benchmark_debug_info( - instance_string, - benchmark, - lowest_range_values, - highest_range_values, - steps, - repeat, - verify, - e, - ) - })?, - }); - } - } else { - $batches.push($crate::BenchmarkBatch { - pallet: name_string.to_vec(), - instance: instance_string.to_vec(), - benchmark: benchmark.clone(), - results: $( $location )*::run_benchmark( - &benchmark[..], - &lowest_range_values[..], - &highest_range_values[..], - *steps, - *repeat, - whitelist, - *verify, - ).map_err(|e| { - $crate::show_benchmark_debug_info( - instance_string, - benchmark, - lowest_range_values, - highest_range_values, - steps, - repeat, - verify, - e, - ) - })?, - }); - } + if &pallet[..] == &name_string[..] { + $batches.push($crate::BenchmarkBatch { + pallet: name_string.to_vec(), + instance: instance_string.to_vec(), + benchmark: benchmark.clone(), + results: $( $location )*::run_benchmark( + &benchmark[..], + &lowest_range_values[..], + &highest_range_values[..], + *steps, + *repeat, + whitelist, + *verify, + ).map_err(|e| { + $crate::show_benchmark_debug_info( + instance_string, + benchmark, + lowest_range_values, + highest_range_values, + steps, + repeat, + verify, + e, + ) + })? + }); } ) } + +#[macro_export] +macro_rules! list_benchmark { + ( $list:ident, $extra:ident, $name:path, $( $location:tt )* ) => ( + let pallet_string = stringify!($name).as_bytes(); + let instance_string = stringify!( $( $location )* ).as_bytes(); + let benchmarks = $( $location )*::benchmarks($extra) + .iter() + .map(|b| b.to_vec()) + .collect::>(); + let pallet_benchmarks = BenchmarkList { + pallet: pallet_string.to_vec(), + instance: instance_string.to_vec(), + benchmarks: benchmarks.to_vec(), + }; + $list.push(pallet_benchmarks) + ) +} diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index b13a7477632cc..87e5e024cf21d 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -116,6 +116,7 @@ pub struct BenchmarkConfig { #[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] pub struct BenchmarkList { pub pallet: Vec, + pub instance: Vec, pub benchmarks: Vec>, } diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index b84737e02d253..a23ddfab12848 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -100,6 +100,8 @@ impl BenchmarkCmd { let spec = config.chain_spec; let wasm_method = self.wasm_method.into(); let strategy = self.execution.unwrap_or(ExecutionStrategy::Native); + let pallet = self.pallet.as_bytes(); + let extrinsic = self.extrinsic.as_bytes(); let genesis_storage = spec.build_storage()?; let mut changes = Default::default(); @@ -114,7 +116,7 @@ impl BenchmarkCmd { let mut batches = Vec::new(); let mut storage_info = Vec::new(); - for r in 0..self.repeat { + let extensions = || -> Extensions { let mut extensions = Extensions::default(); extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); let (offchain, _) = TestOffchainExt::new(); @@ -122,80 +124,95 @@ impl BenchmarkCmd { extensions.register(OffchainWorkerExt::new(offchain.clone())); extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); + return extensions + }; + + // Get Benchmark List + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_benchmarks", + &(self.extra).encode(), + extensions(), + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), + ) + .execute(strategy.into()) + .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; + + let list = + as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + + if self.list { + // Show the list and exit early + for item in list { + println!("{}", String::from_utf8(item.pallet).unwrap()); + for benchmark in item.benchmarks { + println!("- {}", String::from_utf8(benchmark).unwrap()); + } + } + return Ok(()) + } - if self.list { + // Use the benchmark list and the user input to determine the set of benchmarks to run. + let mut benchmarks_to_run = Vec::new(); + for item in list { + if pallet == &item.pallet[..] || pallet == &b"*"[..] { + if &pallet[..] == &b"*"[..] || &extrinsic[..] == &b"*"[..] { + for benchmark in item.benchmarks { + benchmarks_to_run.push((item.pallet.clone(), benchmark)); + } + } else { + benchmarks_to_run.push((pallet.to_vec(), extrinsic.to_vec())); + } + } + } + + // Run the benchmarks + for (pallet, extrinsic) in benchmarks_to_run { + for r in 0..self.repeat { let result = StateMachine::<_, _, NumberFor, _>::new( &state, None, &mut changes, &executor, - "Benchmark_benchmarks", - &(self.extra).encode(), - extensions, + "Benchmark_dispatch_benchmark", + &( + &pallet, + &extrinsic, + self.lowest_range_values.clone(), + self.highest_range_values.clone(), + (self.steps, self.steps), + (r, self.repeat), + !self.no_verify, + self.extra, + ) + .encode(), + extensions(), &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, sp_core::testing::TaskExecutor::new(), ) .execute(strategy.into()) - .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - - let lists = - as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - for list in lists { - println!("{}", String::from_utf8(list.pallet).unwrap()); - for benchmark in list.benchmarks { - println!("- {}", String::from_utf8(benchmark).unwrap()); - } - } + let (batch, last_storage_info) = , Vec), + String, + > as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; - return Ok(()) + batches.extend(batch); + storage_info = last_storage_info; } - - let result = StateMachine::<_, _, NumberFor, _>::new( - &state, - None, - &mut changes, - &executor, - "Benchmark_dispatch_benchmark", - &( - &self.pallet, - &self.extrinsic, - self.lowest_range_values.clone(), - self.highest_range_values.clone(), - (self.steps, self.steps), - (r, self.repeat), - !self.no_verify, - self.extra, - ) - .encode(), - extensions, - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, - sp_core::testing::TaskExecutor::new(), - ) - .execute(strategy.into()) - .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - - let (batch, last_storage_info) = , Vec), - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; - - batches.extend(batch); - storage_info = last_storage_info; } + // Combine all of the benchmark results, so that benchmarks of the same pallet/function + // are together. let batches = combine_batches(batches); - for b in batches.clone() { - println!( - "{:?}: {:?}", - String::from_utf8(b.pallet).unwrap(), - String::from_utf8(b.benchmark).unwrap(), - ); - } - if let Some(output_path) = &self.output { crate::writer::write_results(&batches, &storage_info, output_path, self)?; } @@ -297,33 +314,3 @@ impl CliConfiguration for BenchmarkCmd { }) } } - -// fn list(extra: bool) -> Result<()> -// where -// BB: BlockT + Debug, -// <<::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug, -// ::Hash: std::str::FromStr, -// { -// let result = StateMachine::<_, _, NumberFor, _>::new( -// &state, -// None, -// &mut changes, -// &executor, -// "Benchmark_benchmarks", -// &(extra).encode(), -// extensions, -// &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, -// sp_core::testing::TaskExecutor::new(), -// ) -// .execute(strategy.into()) -// .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - -// let list = , -// String, -// > as Decode>::decode(&mut &result[..]) -// .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))??; - -// println!("{:?}", list); -// Ok(()) -// } From e760e3e9c2322f4f4902b3dec32a6ddebb6c2169 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 13:15:02 +0200 Subject: [PATCH 16/73] handle steps in cli --- frame/benchmarking/src/lib.rs | 58 ++++++++++-------- utils/frame/benchmarking-cli/src/command.rs | 68 +++++++++++---------- 2 files changed, 68 insertions(+), 58 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index f6952c5a4beb2..576683ca1b9a0 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -846,17 +846,20 @@ macro_rules! impl_benchmark { Ok(()) }; + let (current_step, total_steps) = steps; + if components.is_empty() { - if verify { - // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + // The CLI could ask to do more steps than is sensible, so we skip those. + if current_step == 0 { + if verify { + // If `--verify` is used, run the benchmark once to verify it would complete. + do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + } + do_benchmark(Default::default(), &mut results, false, 1, 1)?; } - do_benchmark(Default::default(), &mut results, false, 1, 1)?; } else { // Select the component we will be benchmarking. Each component will be benchmarked. for (idx, (name, low, high)) in components.iter().enumerate() { - // Get the number of steps for this component. - let (_current_step, total_steps) = steps; let lowest = lowest_range_values.get(idx).cloned().unwrap_or(*low); let highest = highest_range_values.get(idx).cloned().unwrap_or(*high); @@ -867,28 +870,31 @@ macro_rules! impl_benchmark { let step_size = (diff / total_steps).max(1); let num_of_steps = diff / step_size + 1; - for s in 0..num_of_steps { - // This is the value we will be testing for component `name` - let component_value = lowest + step_size * s; - - // Select the max value for all the other components. - let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components.iter() - .enumerate() - .map(|(idx, (n, _, h))| - if n == name { - (*n, component_value) - } else { - (*n, *highest_range_values.get(idx).unwrap_or(h)) - } - ) - .collect(); + // The CLI could ask to do more steps than is sensible, so we just skip those. + if current_step >= num_of_steps { + continue; + } - if verify { - // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(&c, &mut $crate::Vec::new(), true, s, num_of_steps)?; - } - do_benchmark(&c, &mut results, false, s, num_of_steps)?; + // This is the value we will be testing for component `name` + let component_value = lowest + step_size * current_step; + + // Select the max value for all the other components. + let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components.iter() + .enumerate() + .map(|(idx, (n, _, h))| + if n == name { + (*n, component_value) + } else { + (*n, *highest_range_values.get(idx).unwrap_or(h)) + } + ) + .collect(); + + if verify { + // If `--verify` is used, run the benchmark once to verify it would complete. + do_benchmark(&c, &mut $crate::Vec::new(), true, current_step, num_of_steps)?; } + do_benchmark(&c, &mut results, false, current_step, num_of_steps)?; } } return Ok(results); diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index a23ddfab12848..7e5fd1fef1092 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -173,39 +173,43 @@ impl BenchmarkCmd { // Run the benchmarks for (pallet, extrinsic) in benchmarks_to_run { - for r in 0..self.repeat { - let result = StateMachine::<_, _, NumberFor, _>::new( - &state, - None, - &mut changes, - &executor, - "Benchmark_dispatch_benchmark", - &( - &pallet, - &extrinsic, - self.lowest_range_values.clone(), - self.highest_range_values.clone(), - (self.steps, self.steps), - (r, self.repeat), - !self.no_verify, - self.extra, + for s in 0..self.steps { + for r in 0..self.repeat { + // This should run only a single instance of a benchmark for `pallet` and + // `extrinsic`. All loops happen above. + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_dispatch_benchmark", + &( + &pallet, + &extrinsic, + self.lowest_range_values.clone(), + self.highest_range_values.clone(), + (s, self.steps), + (r, self.repeat), + !self.no_verify, + self.extra, + ) + .encode(), + extensions(), + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), ) - .encode(), - extensions(), - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, - sp_core::testing::TaskExecutor::new(), - ) - .execute(strategy.into()) - .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - - let (batch, last_storage_info) = , Vec), - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; - - batches.extend(batch); - storage_info = last_storage_info; + .execute(strategy.into()) + .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; + + let (batch, last_storage_info) = , Vec), + String, + > as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; + + batches.extend(batch); + storage_info = last_storage_info; + } } } From 630ab7a11f904c291efdd8f21b426e82b23032dd Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 18:05:48 +0200 Subject: [PATCH 17/73] move log update to cli --- Cargo.lock | 1 + frame/benchmarking/src/lib.rs | 22 ++++---------------- utils/frame/benchmarking-cli/Cargo.toml | 1 + utils/frame/benchmarking-cli/src/command.rs | 23 ++++++++++++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f922cbbc12175..998a3aad4c82b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1801,6 +1801,7 @@ dependencies = [ "frame-support", "handlebars", "linked-hash-map", + "log", "parity-scale-codec", "sc-cli", "sc-client-db", diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 576683ca1b9a0..d43748bdc842a 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -748,8 +748,6 @@ macro_rules! impl_benchmark { c: &[($crate::BenchmarkParameter, u32)], results: &mut $crate::Vec<$crate::BenchmarkResults>, verify: bool, - step: u32, - num_steps: u32, | -> Result<(), &'static str> { // Set up the externalities environment for the setup we want to // benchmark. @@ -805,18 +803,6 @@ macro_rules! impl_benchmark { "Read/Write Count {:?}", read_write_count ); - let time = $crate::benchmarking::current_time(); - if time.saturating_sub(progress) > 5000000000 { - progress = $crate::benchmarking::current_time(); - $crate::log::info!( - target: "benchmark", - "Benchmarking {} {}/{}", - extrinsic, - step, - num_steps, - ); - } - // Time the storage root recalculation. let start_storage_root = $crate::benchmarking::current_time(); $crate::storage_root(); @@ -853,9 +839,9 @@ macro_rules! impl_benchmark { if current_step == 0 { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + do_benchmark(Default::default(), &mut $crate::Vec::new(), true)?; } - do_benchmark(Default::default(), &mut results, false, 1, 1)?; + do_benchmark(Default::default(), &mut results, false)?; } } else { // Select the component we will be benchmarking. Each component will be benchmarked. @@ -892,9 +878,9 @@ macro_rules! impl_benchmark { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(&c, &mut $crate::Vec::new(), true, current_step, num_of_steps)?; + do_benchmark(&c, &mut $crate::Vec::new(), true)?; } - do_benchmark(&c, &mut results, false, current_step, num_of_steps)?; + do_benchmark(&c, &mut results, false)?; } } return Ok(results); diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index e9445b03971f8..93616b590f61e 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -31,6 +31,7 @@ serde = "1.0.126" handlebars = "3.5.0" Inflector = "0.11.4" linked-hash-map = "0.5.4" +log = "0.4.8" [features] default = ["db"] diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 7e5fd1fef1092..de1af1839506c 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -32,7 +32,7 @@ use sp_externalities::Extensions; use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use sp_state_machine::StateMachine; -use std::{fmt::Debug, sync::Arc}; +use std::{fmt::Debug, sync::Arc, time}; // This takes multiple benchmark batches and combines all the results where the pallet, instance, // and benchmark are the same. @@ -172,6 +172,7 @@ impl BenchmarkCmd { } // Run the benchmarks + let mut timer = time::SystemTime::now(); for (pallet, extrinsic) in benchmarks_to_run { for s in 0..self.steps { for r in 0..self.repeat { @@ -184,8 +185,8 @@ impl BenchmarkCmd { &executor, "Benchmark_dispatch_benchmark", &( - &pallet, - &extrinsic, + &pallet.clone(), + &extrinsic.clone(), self.lowest_range_values.clone(), self.highest_range_values.clone(), (s, self.steps), @@ -209,6 +210,22 @@ impl BenchmarkCmd { batches.extend(batch); storage_info = last_storage_info; + + // Show progress information + if let Some(elapsed) = timer.elapsed().ok() { + if elapsed >= time::Duration::from_secs(5) { + timer = time::SystemTime::now(); + log::info!( + "Running Benchmark:\t{}\t{}\t{}/{}\t{}/{}", + String::from_utf8(pallet.clone()).expect("Encoded from String; qed"), + String::from_utf8(extrinsic.clone()).expect("Encoded from String; qed"), + s, + self.steps, + r, + self.repeat, + ); + } + } } } } From d4b3f9d37479a4912fc0ac4486971daf9cd6d414 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 18:06:14 +0200 Subject: [PATCH 18/73] fmt --- utils/frame/benchmarking-cli/src/command.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index de1af1839506c..b2ba60d8048c4 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -142,9 +142,8 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let list = - as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + let list = as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; if self.list { // Show the list and exit early @@ -196,7 +195,8 @@ impl BenchmarkCmd { ) .encode(), extensions(), - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + &sp_state_machine::backend::BackendRuntimeCode::new(&state) + .runtime_code()?, sp_core::testing::TaskExecutor::new(), ) .execute(strategy.into()) @@ -217,8 +217,10 @@ impl BenchmarkCmd { timer = time::SystemTime::now(); log::info!( "Running Benchmark:\t{}\t{}\t{}/{}\t{}/{}", - String::from_utf8(pallet.clone()).expect("Encoded from String; qed"), - String::from_utf8(extrinsic.clone()).expect("Encoded from String; qed"), + String::from_utf8(pallet.clone()) + .expect("Encoded from String; qed"), + String::from_utf8(extrinsic.clone()) + .expect("Encoded from String; qed"), s, self.steps, r, From 39bd8c06d8e8823995dc02dbd8993a75456ac11d Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 18:32:14 +0200 Subject: [PATCH 19/73] remove old todo --- frame/benchmarking/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index d43748bdc842a..d5bd859ed2df5 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -809,9 +809,7 @@ macro_rules! impl_benchmark { let finish_storage_root = $crate::benchmarking::current_time(); let elapsed_storage_root = finish_storage_root - start_storage_root; - // TODO: Fix memory allocation issue then re-enable let read_and_written_keys = $crate::benchmarking::get_read_and_written_keys(); - //let read_and_written_keys = Default::default(); results.push($crate::BenchmarkResults { components: c.to_vec(), From fb8fc173d7cb8bc34cf34e08a7bfcb28fe2d73e2 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 18:36:39 +0200 Subject: [PATCH 20/73] line width --- frame/benchmarking/src/utils.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 87e5e024cf21d..db9dc7af2b81d 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -232,8 +232,10 @@ pub trait Benchmarking { /// bytes. /// - `lowest_range_values`: The lowest number for each range of parameters. /// - `highest_range_values`: The highest number for each range of parameters. - /// - `steps`: The number of sample points you want to take across the range of parameters. (current_step, total_steps) - /// - `repeat`: The total number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeats) + /// - `steps`: The number of sample points you want to take across the range of parameters. + /// (current_step, total_steps) + /// - `repeat`: The total number times to repeat each benchmark to increase accuracy of results. + /// (current_repeat, total_repeats) fn run_benchmark( name: &[u8], lowest_range_values: &[u32], From 5627eba5201565c9953e682e385bada08d688d59 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Fri, 30 Jul 2021 16:48:16 +0000 Subject: [PATCH 21/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index aa5bc697a42dd..bc69d0128ca95 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -58,37 +58,37 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_138_000 as Weight) + (78_536_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (57_454_000 as Weight) + (58_474_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (31_664_000 as Weight) + (33_002_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_901_000 as Weight) + (39_321_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (76_515_000 as Weight) + (77_973_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_007_000 as Weight) + (71_563_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -98,37 +98,37 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_138_000 as Weight) + (78_536_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (57_454_000 as Weight) + (58_474_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (31_664_000 as Weight) + (33_002_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_901_000 as Weight) + (39_321_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (76_515_000 as Weight) + (77_973_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_007_000 as Weight) + (71_563_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From ced05142ea8d7e282159907f2f4101a747fdd815 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 19:06:39 +0200 Subject: [PATCH 22/73] benchmark metadata function --- bin/node/runtime/src/lib.rs | 25 +++++++++------------ frame/benchmarking/src/utils.rs | 5 ++--- utils/frame/benchmarking-cli/src/command.rs | 17 ++++++-------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 419178d9500eb..aa4d62a9ae086 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1534,8 +1534,9 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { - fn benchmarks(extra: bool) -> Vec { + fn benchmark_metadata(extra: bool) -> (Vec, Vec) { use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency // issues. To get around that, we separated the Session benchmarks into its own crate, @@ -1544,10 +1545,6 @@ impl_runtime_apis! { use pallet_offences_benchmarking::Pallet as OffencesBench; use frame_system_benchmarking::Pallet as SystemBench; - impl pallet_session_benchmarking::Config for Runtime {} - impl pallet_offences_benchmarking::Config for Runtime {} - impl frame_system_benchmarking::Config for Runtime {} - let mut list = Vec::::new(); list_benchmark!(list, extra, pallet_assets, Assets); @@ -1582,17 +1579,15 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); - return list + let storage_info = AllPalletsWithSystem::storage_info(); + + return (list, storage_info) } fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig - ) -> Result< - (Vec, Vec), - sp_runtime::RuntimeString, - > { + ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; - use frame_support::traits::StorageInfoTrait; // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency // issues. To get around that, we separated the Session benchmarks into its own crate, @@ -1601,6 +1596,10 @@ impl_runtime_apis! { use pallet_offences_benchmarking::Pallet as OffencesBench; use frame_system_benchmarking::Pallet as SystemBench; + impl pallet_session_benchmarking::Config for Runtime {} + impl pallet_offences_benchmarking::Config for Runtime {} + impl frame_system_benchmarking::Config for Runtime {} + let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), @@ -1616,8 +1615,6 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(), ]; - let storage_info = AllPalletsWithSystem::storage_info(); - let mut batches = Vec::::new(); let params = (&config, &whitelist); @@ -1654,7 +1651,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_vesting, Vesting); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok((batches, storage_info)) + Ok(batches) } } } diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index db9dc7af2b81d..440845929fb85 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -128,11 +128,10 @@ sp_api::decl_runtime_apis! { /// Parameters /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be /// needed for weight calculation. - fn benchmarks(extra: bool) -> Vec; + fn benchmark_metadata(extra: bool) -> (Vec, Vec); /// Dispatch the given benchmark. - fn dispatch_benchmark(config: BenchmarkConfig) - -> Result<(Vec, Vec), sp_runtime::RuntimeString>; + fn dispatch_benchmark(config: BenchmarkConfig) -> Result, sp_runtime::RuntimeString>; } } diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index b2ba60d8048c4..d0768731a7536 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -17,7 +17,7 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; -use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector}; +use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector, BenchmarkList}; use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; @@ -113,9 +113,6 @@ impl BenchmarkCmd { 2, // The runtime instances cache size. ); - let mut batches = Vec::new(); - let mut storage_info = Vec::new(); - let extensions = || -> Extensions { let mut extensions = Extensions::default(); extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); @@ -133,7 +130,7 @@ impl BenchmarkCmd { None, &mut changes, &executor, - "Benchmark_benchmarks", + "Benchmark_benchmark_metadata", &(self.extra).encode(), extensions(), &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, @@ -142,8 +139,8 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let list = as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + let (list, storage_info) = <(Vec, Vec) as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; if self.list { // Show the list and exit early @@ -171,6 +168,7 @@ impl BenchmarkCmd { } // Run the benchmarks + let mut batches = Vec::new(); let mut timer = time::SystemTime::now(); for (pallet, extrinsic) in benchmarks_to_run { for s in 0..self.steps { @@ -202,14 +200,13 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - let (batch, last_storage_info) = , Vec), + let batch = , String, > as Decode>::decode(&mut &result[..]) .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; batches.extend(batch); - storage_info = last_storage_info; // Show progress information if let Some(elapsed) = timer.elapsed().ok() { From 1945af5cb8c138b22014cbd20861adaa4b046f56 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 19:18:38 +0200 Subject: [PATCH 23/73] don't need this warm up --- frame/benchmarking/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index d5bd859ed2df5..f6e8b31bf712a 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -734,10 +734,6 @@ macro_rules! impl_benchmark { whitelist.push(whitelisted_caller_key.into()); $crate::benchmarking::set_whitelist(whitelist); - // Warm up the DB - $crate::benchmarking::commit_db(); - $crate::benchmarking::wipe_db(); - let components = < SelectedBenchmark as $crate::BenchmarkingSetup >::components(&selected_benchmark); From b243b02f5f4bebb1d1a14c34e580ee66190824de Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Fri, 30 Jul 2021 17:25:35 +0000 Subject: [PATCH 24/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index bc69d0128ca95..df609b74840d2 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -58,37 +58,37 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_536_000 as Weight) + (78_358_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (58_474_000 as Weight) + (59_001_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (33_002_000 as Weight) + (32_698_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (39_321_000 as Weight) + (38_746_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (77_973_000 as Weight) + (77_622_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_563_000 as Weight) + (72_020_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -98,37 +98,37 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_536_000 as Weight) + (78_358_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (58_474_000 as Weight) + (59_001_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (33_002_000 as Weight) + (32_698_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (39_321_000 as Weight) + (38_746_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (77_973_000 as Weight) + (77_622_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_563_000 as Weight) + (72_020_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From 14a43427d68b220f099d005bf76699907f3a6243 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 19:41:09 +0200 Subject: [PATCH 25/73] fix warnings --- frame/benchmarking/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index f6e8b31bf712a..bba558d241523 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -712,7 +712,7 @@ macro_rules! impl_benchmark { lowest_range_values: &[u32], highest_range_values: &[u32], steps: (u32, u32), - repeat: (u32, u32), + _repeat: (u32, u32), whitelist: &[$crate::TrackedStorageKey], verify: bool, ) -> Result<$crate::Vec<$crate::BenchmarkResults>, &'static str> { @@ -738,9 +738,7 @@ macro_rules! impl_benchmark { SelectedBenchmark as $crate::BenchmarkingSetup >::components(&selected_benchmark); - let mut progress = $crate::benchmarking::current_time(); - - let mut do_benchmark = | + let do_benchmark = | c: &[($crate::BenchmarkParameter, u32)], results: &mut $crate::Vec<$crate::BenchmarkResults>, verify: bool, From ee3b2f79e5dd73073e06e4fabe5c5ae928d3fe71 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 20:37:00 +0200 Subject: [PATCH 26/73] fix node-template --- bin/node-template/runtime/src/lib.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index f9eaa96153eba..d93dc775d927a 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -446,12 +446,26 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> (Vec, Vec) { + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, frame_system, SystemBench::); + list_benchmark!(list, extra, pallet_balances, Balances); + list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_template, TemplateModule); + + let storage_info = AllPalletsWithSystem::storage_info(); + + return (list, storage_info) + } + fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig - ) -> Result< - (Vec, Vec), - sp_runtime::RuntimeString, - > { + ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_support::traits::StorageInfoTrait; @@ -471,8 +485,6 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), ]; - let storage_info = AllPalletsWithSystem::storage_info(); - let mut batches = Vec::::new(); let params = (&config, &whitelist); @@ -482,7 +494,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_template, TemplateModule); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok((batches, storage_info)) + Ok(batches) } } } From 0ae603879f1100eb2b29cb82ffc693e962c1d103 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 20:37:22 +0200 Subject: [PATCH 27/73] fix --- bin/node-template/runtime/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index d93dc775d927a..f94c7d982b27f 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -467,7 +467,6 @@ impl_runtime_apis! { config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; - use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} From f2ae7a14790c9eaa924c6853015bb991b81920d7 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 10:37:16 +0200 Subject: [PATCH 28/73] fmt --- utils/frame/benchmarking-cli/src/command.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index d0768731a7536..bdd131b46d401 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -17,7 +17,9 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; -use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector, BenchmarkList}; +use frame_benchmarking::{ + Analysis, BenchmarkBatch, BenchmarkList, BenchmarkResults, BenchmarkSelector, +}; use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; @@ -139,8 +141,9 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let (list, storage_info) = <(Vec, Vec) as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; + let (list, storage_info) = + <(Vec, Vec) as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; if self.list { // Show the list and exit early @@ -200,11 +203,11 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - let batch = , - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; + let batch = + , String> as Decode>::decode( + &mut &result[..], + ) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; batches.extend(batch); From b7fa4aa8c16772da340cc6941bcdb29088331639 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 10:43:15 +0200 Subject: [PATCH 29/73] line width --- bin/node-template/runtime/src/lib.rs | 5 ++++- bin/node/runtime/src/lib.rs | 5 ++++- frame/benchmarking/src/utils.rs | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index f94c7d982b27f..63da72102df3d 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -446,7 +446,10 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> (Vec, Vec) { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index aa4d62a9ae086..181f5fd423767 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1534,7 +1534,10 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> (Vec, Vec) { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 440845929fb85..efb2a01c1557d 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -103,13 +103,16 @@ pub struct BenchmarkConfig { pub lowest_range_values: Vec, /// An optional manual override to the highest values used in the `steps` range. pub highest_range_values: Vec, - /// The number of samples to take across the range of values for components. (current_step, total_steps) + /// The number of samples to take across the range of values for components. (current_step, + /// total_steps) pub steps: (u32, u32), - /// The number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeat) + /// The number times to repeat each benchmark to increase accuracy of results. (current_repeat, + /// total_repeat) pub repeat: (u32, u32), /// Enable an extra benchmark iteration which runs the verification logic for a benchmark. pub verify: bool, - /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a pallet. + /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a + /// pallet. pub extra: bool, } From f5a839bced4706e7021096545ade49b9462cba37 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Sat, 31 Jul 2021 09:47:12 +0000 Subject: [PATCH 30/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/staking/src/weights.rs | 486 +++++++++++++++++------------------ 1 file changed, 243 insertions(+), 243 deletions(-) diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index 7d2b3363de554..fb4ed160d8325 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -78,208 +78,208 @@ pub trait WeightInfo { /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (73_506_000 as Weight) + (77_492_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } - // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn bond_extra() -> Weight { - (57_019_000 as Weight) + (59_476_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: System Account (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) fn unbond() -> Weight { - (61_257_000 as Weight) + (63_655_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: System Account (r:1 w:1) fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_060_000 as Weight) + (54_534_000 as Weight) // Standard Error: 0 - .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((24_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Balances Locks (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_303_000 as Weight) + (89_850_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_396_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (35_189_000 as Weight) + (36_726_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) fn kick(k: u32, ) -> Weight { - (16_161_000 as Weight) - // Standard Error: 10_000 - .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) + (19_497_000 as Weight) + // Standard Error: 15_000 + .saturating_add((17_057_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Validators (r:2 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) fn nominate(n: u32, ) -> Weight { - (41_638_000 as Weight) - // Standard Error: 9_000 - .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + (45_146_000 as Weight) + // Standard Error: 13_000 + .saturating_add((5_527_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) fn chill() -> Weight { - (18_707_000 as Weight) + (18_986_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) fn set_payee() -> Weight { - (12_688_000 as Weight) + (13_348_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_726_000 as Weight) + (28_148_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (2_309_000 as Weight) + (2_909_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (2_508_000 as Weight) + (3_163_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (2_483_000 as Weight) + (3_141_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_487_000 as Weight) + (3_220_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking Invulnerables (r:0 w:1) fn set_invulnerables(v: u32, ) -> Weight { - (2_465_000 as Weight) + (3_569_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((58_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Staking Payee (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (62_075_000 as Weight) + (65_753_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_420_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_403_675_000 as Weight) - // Standard Error: 223_000 - .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) + (3_056_514_000 as Weight) + // Standard Error: 218_000 + .saturating_add((21_159_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (111_168_000 as Weight) - // Standard Error: 17_000 - .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + (121_794_000 as Weight) + // Standard Error: 19_000 + .saturating_add((49_467_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking ErasValidatorPrefs (r:1 w:0) // Storage: Staking Ledger (r:2 w:2) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Payee (r:2 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:2 w:2) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: System Account (r:2 w:2) // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Payee (r:2 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (148_375_000 as Weight) - // Standard Error: 22_000 - .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) + (147_049_000 as Weight) + // Standard Error: 30_000 + .saturating_add((64_428_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) @@ -289,89 +289,89 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_669_000 as Weight) - // Standard Error: 2_000 - .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) + (52_184_000 as Weight) + // Standard Error: 1_000 + .saturating_add((35_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking ErasValidatorReward (r:0 w:1) // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:2) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 70_000 - .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 57_000 + .saturating_add((30_689_000 as Weight).saturating_mul(e as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } - // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:1) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Payee (r:0 w:1) // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_475_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) + (75_836_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_423_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System BlockWeight (r:1 w:1) // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:1) // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking Validators (r:2 w:0) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) - // Storage: System BlockWeight (r:1 w:1) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking CounterForNominators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Validators (r:2 w:0) // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 970_000 - .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 48_000 - .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_492_000 + .saturating_add((299_860_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 99_000 + .saturating_add((47_937_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } + // Storage: Staking Validators (r:501 w:0) // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) // Storage: Staking Ledger (r:1500 w:0) // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Validators (r:501 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { (0 as Weight) - // Standard Error: 102_000 - .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 102_000 - .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_473_000 - .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) + // Standard Error: 101_000 + .saturating_add((27_304_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 101_000 + .saturating_add((29_893_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_441_000 + .saturating_add((91_111_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -380,29 +380,29 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { (0 as Weight) - // Standard Error: 29_000 - .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 32_000 + .saturating_add((11_692_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) } // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxValidatorsCount (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_limits() -> Weight { - (6_599_000 as Weight) + (7_325_000 as Weight) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } - // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) fn chill_other() -> Weight { - (62_743_000 as Weight) + (62_683_000 as Weight) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -410,208 +410,208 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (73_506_000 as Weight) + (77_492_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } - // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn bond_extra() -> Weight { - (57_019_000 as Weight) + (59_476_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: System Account (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) fn unbond() -> Weight { - (61_257_000 as Weight) + (63_655_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: System Account (r:1 w:1) fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_060_000 as Weight) + (54_534_000 as Weight) // Standard Error: 0 - .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((24_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Balances Locks (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_303_000 as Weight) + (89_850_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_396_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(8 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (35_189_000 as Weight) + (36_726_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } - // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) fn kick(k: u32, ) -> Weight { - (16_161_000 as Weight) - // Standard Error: 10_000 - .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) + (19_497_000 as Weight) + // Standard Error: 15_000 + .saturating_add((17_057_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Validators (r:2 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) fn nominate(n: u32, ) -> Weight { - (41_638_000 as Weight) - // Standard Error: 9_000 - .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + (45_146_000 as Weight) + // Standard Error: 13_000 + .saturating_add((5_527_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) fn chill() -> Weight { - (18_707_000 as Weight) + (18_986_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) fn set_payee() -> Weight { - (12_688_000 as Weight) + (13_348_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_726_000 as Weight) + (28_148_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (2_309_000 as Weight) + (2_909_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (2_508_000 as Weight) + (3_163_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (2_483_000 as Weight) + (3_141_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_487_000 as Weight) + (3_220_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking Invulnerables (r:0 w:1) fn set_invulnerables(v: u32, ) -> Weight { - (2_465_000 as Weight) + (3_569_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((58_000 as Weight).saturating_mul(v as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Staking Payee (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (62_075_000 as Weight) + (65_753_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_420_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_403_675_000 as Weight) - // Standard Error: 223_000 - .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) + (3_056_514_000 as Weight) + // Standard Error: 218_000 + .saturating_add((21_159_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (111_168_000 as Weight) - // Standard Error: 17_000 - .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + (121_794_000 as Weight) + // Standard Error: 19_000 + .saturating_add((49_467_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking ErasValidatorPrefs (r:1 w:0) // Storage: Staking Ledger (r:2 w:2) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Payee (r:2 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:2 w:2) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: System Account (r:2 w:2) // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Payee (r:2 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (148_375_000 as Weight) - // Standard Error: 22_000 - .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) + (147_049_000 as Weight) + // Standard Error: 30_000 + .saturating_add((64_428_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) @@ -621,89 +621,89 @@ impl WeightInfo for () { // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_669_000 as Weight) - // Standard Error: 2_000 - .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) + (52_184_000 as Weight) + // Standard Error: 1_000 + .saturating_add((35_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking ErasValidatorReward (r:0 w:1) // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:2) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 70_000 - .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 57_000 + .saturating_add((30_689_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } - // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:1) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Payee (r:0 w:1) // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_475_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) + (75_836_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_423_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System BlockWeight (r:1 w:1) // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:1) // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking Validators (r:2 w:0) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) - // Storage: System BlockWeight (r:1 w:1) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking CounterForNominators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Validators (r:2 w:0) // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 970_000 - .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 48_000 - .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_492_000 + .saturating_add((299_860_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 99_000 + .saturating_add((47_937_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } + // Storage: Staking Validators (r:501 w:0) // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) // Storage: Staking Ledger (r:1500 w:0) // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Validators (r:501 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { (0 as Weight) - // Standard Error: 102_000 - .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 102_000 - .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_473_000 - .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) + // Standard Error: 101_000 + .saturating_add((27_304_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 101_000 + .saturating_add((29_893_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_441_000 + .saturating_add((91_111_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -712,29 +712,29 @@ impl WeightInfo for () { // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { (0 as Weight) - // Standard Error: 29_000 - .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 32_000 + .saturating_add((11_692_000 as Weight).saturating_mul(v as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) } // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxValidatorsCount (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_limits() -> Weight { - (6_599_000 as Weight) + (7_325_000 as Weight) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } - // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) fn chill_other() -> Weight { - (62_743_000 as Weight) + (62_683_000 as Weight) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From e3ad6dd3f73f7e06a8d90096e011066d54688888 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 12:13:42 +0200 Subject: [PATCH 31/73] improve docs --- frame/benchmarking/src/lib.rs | 20 ++++++++++++++++++++ frame/benchmarking/src/utils.rs | 7 +++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index bba558d241523..ba1ca21481afb 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -1358,6 +1358,26 @@ macro_rules! add_benchmark { ) } +/// This macro allows users to easily generate a list of benchmarks for the pallets configured +/// in the runtime. +/// +/// To use this macro, first create a an object to store the list: +/// +/// ``` +/// let mut list = Vec::::new(); +/// ``` +/// +/// Then pass this `list` to the macro, along with the `extra` boolean, the pallet crate, and +/// pallet struct: +/// +/// ``` +/// list_benchmark!(list, extra, pallet_balances, Balances); +/// list_benchmark!(list, extra, pallet_session, SessionBench::); +/// list_benchmark!(list, extra, frame_system, SystemBench::); +/// ``` +/// +/// This should match what exists with the `add_benchmark!` macro. + #[macro_export] macro_rules! list_benchmark { ( $list:ident, $extra:ident, $name:path, $( $location:tt )* ) => ( diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index efb2a01c1557d..82c6e44796fae 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -116,6 +116,9 @@ pub struct BenchmarkConfig { pub extra: bool, } +/// A list of benchmarks available for a particular pallet and instance. +/// +/// All `Vec` must be valid utf8 strings. #[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] pub struct BenchmarkList { pub pallet: Vec, @@ -126,10 +129,10 @@ pub struct BenchmarkList { sp_api::decl_runtime_apis! { /// Runtime api for benchmarking a FRAME runtime. pub trait Benchmark { - /// Get the benchmarks available for this runtime. + /// Get the benchmark metadata available for this runtime. /// /// Parameters - /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be + /// - `extra`: Also list benchmarks marked "extra" which would otherwise not be /// needed for weight calculation. fn benchmark_metadata(extra: bool) -> (Vec, Vec); From 98b328079e93dae0fe75f623a256b14f68790b3b Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 14:21:01 +0200 Subject: [PATCH 32/73] improve cli --- frame/benchmarking/src/lib.rs | 4 +- utils/frame/benchmarking-cli/src/command.rs | 68 +++++++++++++++------ utils/frame/benchmarking-cli/src/lib.rs | 14 +++-- 3 files changed, 62 insertions(+), 24 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index ba1ca21481afb..7149ddc82f59d 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -1363,14 +1363,14 @@ macro_rules! add_benchmark { /// /// To use this macro, first create a an object to store the list: /// -/// ``` +/// ```ignore /// let mut list = Vec::::new(); /// ``` /// /// Then pass this `list` to the macro, along with the `extra` boolean, the pallet crate, and /// pallet struct: /// -/// ``` +/// ```ignore /// list_benchmark!(list, extra, pallet_balances, Balances); /// list_benchmark!(list, extra, pallet_session, SessionBench::); /// list_benchmark!(list, extra, frame_system, SystemBench::); diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index bdd131b46d401..40670138d8fa8 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -40,7 +40,7 @@ use std::{fmt::Debug, sync::Arc, time}; // and benchmark are the same. fn combine_batches(batches: Vec) -> Vec { if batches.is_empty() { - return batches + return batches; } let mut all_benchmarks = LinkedHashMap::<_, Vec>::new(); @@ -57,7 +57,7 @@ fn combine_batches(batches: Vec) -> Vec { // New benchmark, so we add a new entry with the initial results. None => { all_benchmarks.insert(key, results); - }, + } } }); @@ -83,27 +83,29 @@ impl BenchmarkCmd { { if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { - return Err("Output file or path is invalid!".into()) + return Err("Output file or path is invalid!".into()); } } if let Some(header_file) = &self.header { if !header_file.is_file() { - return Err("Header file is invalid!".into()) + return Err("Header file is invalid!".into()); }; } if let Some(handlebars_template_file) = &self.template { if !handlebars_template_file.is_file() { - return Err("Handlebars template file is invalid!".into()) + return Err("Handlebars template file is invalid!".into()); }; } let spec = config.chain_spec; let wasm_method = self.wasm_method.into(); let strategy = self.execution.unwrap_or(ExecutionStrategy::Native); - let pallet = self.pallet.as_bytes(); - let extrinsic = self.extrinsic.as_bytes(); + let pallet = self.pallet.clone().unwrap_or_else(|| String::new()); + let pallet = pallet.as_bytes(); + let extrinsic = self.extrinsic.clone().unwrap_or_else(|| String::new()); + let extrinsic = extrinsic.as_bytes(); let genesis_storage = spec.build_storage()?; let mut changes = Default::default(); @@ -123,7 +125,7 @@ impl BenchmarkCmd { extensions.register(OffchainWorkerExt::new(offchain.clone())); extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); - return extensions + return extensions; }; // Get Benchmark List @@ -146,14 +148,8 @@ impl BenchmarkCmd { .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; if self.list { - // Show the list and exit early - for item in list { - println!("{}", String::from_utf8(item.pallet).unwrap()); - for benchmark in item.benchmarks { - println!("- {}", String::from_utf8(benchmark).unwrap()); - } - } - return Ok(()) + list_benchmark(pallet, extrinsic, list); + return Ok(()); } // Use the benchmark list and the user input to determine the set of benchmarks to run. @@ -254,7 +250,7 @@ impl BenchmarkCmd { // Skip raw data + analysis if there are no results if batch.results.is_empty() { - continue + continue; } if self.raw_data { @@ -337,3 +333,41 @@ impl CliConfiguration for BenchmarkCmd { }) } } + +/// List the benchmarks available in the runtime, in a CSV friendly format. +/// +/// If `pallet_input` and `extrinsic_input` is empty, we list everything. +/// +/// If `pallet_input` is present, we only list the benchmarks for that pallet. +/// +/// If `extrinsic_input` is `*`, we will hide the individual benchmarks for each pallet, and just +/// show a single line for each available pallet. +fn list_benchmark(pallet_input: &[u8], extrinsic_input: &[u8], list: Vec) { + let filtered_list = list + .into_iter() + .filter(|item| pallet_input.is_empty() || pallet_input == &item.pallet) + .collect::>(); + + if filtered_list.is_empty() { + println!("Pallet not found."); + return; + } + + println!("pallet, benchmark"); + for item in filtered_list { + let pallet_string = + String::from_utf8(item.pallet.clone()).expect("Encoded from String; qed"); + + if extrinsic_input == &b"*"[..] { + println!("{}, *", pallet_string) + } else { + for benchmark in item.benchmarks { + println!( + "{}, {}", + pallet_string, + String::from_utf8(benchmark).expect("Encoded from String; qed"), + ); + } + } + } +} diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index d66e59bde0cbd..41629a866f726 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -31,12 +31,12 @@ fn parse_pallet_name(pallet: &str) -> String { #[derive(Debug, structopt::StructOpt)] pub struct BenchmarkCmd { /// Select a FRAME Pallet to benchmark, or `*` for all (in which case `extrinsic` must be `*`). - #[structopt(short, long, parse(from_str = parse_pallet_name))] - pub pallet: String, + #[structopt(short, long, parse(from_str = parse_pallet_name), required_unless = "list")] + pub pallet: Option, /// Select an extrinsic inside the pallet to benchmark, or `*` for all. - #[structopt(short, long)] - pub extrinsic: String, + #[structopt(short, long, required_unless = "list")] + pub extrinsic: Option, /// Select how many samples we should take across the variable components. #[structopt(short, long, default_value = "1")] @@ -130,7 +130,11 @@ pub struct BenchmarkCmd { #[structopt(long = "db-cache", value_name = "MiB", default_value = "128")] pub database_cache_size: u32, - /// List the benchmarks available + /// List the benchmarks available. + /// + /// * If nothing else is specified, all pallets and benchmarks will be listed. + /// * If the `pallet` argument is passed, then we will only list benchmarks for that pallet. + /// * If the `extrinsic` argument is set to `*`, we will hide the individual benchmarks. #[structopt(long)] pub list: bool, } From cc6e48b81593ea46545810a9583b9c0f97ee95a2 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 15:29:24 +0200 Subject: [PATCH 33/73] fix format --- utils/frame/benchmarking-cli/src/command.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 40670138d8fa8..925cfd07d03e2 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -40,7 +40,7 @@ use std::{fmt::Debug, sync::Arc, time}; // and benchmark are the same. fn combine_batches(batches: Vec) -> Vec { if batches.is_empty() { - return batches; + return batches } let mut all_benchmarks = LinkedHashMap::<_, Vec>::new(); @@ -57,7 +57,7 @@ fn combine_batches(batches: Vec) -> Vec { // New benchmark, so we add a new entry with the initial results. None => { all_benchmarks.insert(key, results); - } + }, } }); @@ -83,19 +83,19 @@ impl BenchmarkCmd { { if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { - return Err("Output file or path is invalid!".into()); + return Err("Output file or path is invalid!".into()) } } if let Some(header_file) = &self.header { if !header_file.is_file() { - return Err("Header file is invalid!".into()); + return Err("Header file is invalid!".into()) }; } if let Some(handlebars_template_file) = &self.template { if !handlebars_template_file.is_file() { - return Err("Handlebars template file is invalid!".into()); + return Err("Handlebars template file is invalid!".into()) }; } @@ -125,7 +125,7 @@ impl BenchmarkCmd { extensions.register(OffchainWorkerExt::new(offchain.clone())); extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); - return extensions; + return extensions }; // Get Benchmark List @@ -149,7 +149,7 @@ impl BenchmarkCmd { if self.list { list_benchmark(pallet, extrinsic, list); - return Ok(()); + return Ok(()) } // Use the benchmark list and the user input to determine the set of benchmarks to run. @@ -250,7 +250,7 @@ impl BenchmarkCmd { // Skip raw data + analysis if there are no results if batch.results.is_empty() { - continue; + continue } if self.raw_data { @@ -350,7 +350,7 @@ fn list_benchmark(pallet_input: &[u8], extrinsic_input: &[u8], list: Vec Date: Sun, 1 Aug 2021 10:51:05 +0200 Subject: [PATCH 34/73] fix bug? --- Cargo.lock | 2 +- frame/metadata/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- frame/support/test/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d22e0c0b6bd9..25acd8206351e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1851,7 +1851,7 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "14.0.0-dev" +version = "4.0.0-dev" dependencies = [ "parity-scale-codec", "serde", diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 332ce5b70c26e..68054da927de7 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-metadata" -version = "14.0.0-dev" +version = "4.0.0-dev" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index ed3a2f45a2e14..45f7d55ebfae9 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] serde = { version = "1.0.126", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] } -frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../metadata" } +frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../metadata" } sp-std = { version = "4.0.0-dev", default-features = false, path = "../../primitives/std" } sp-io = { version = "4.0.0-dev", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "4.0.0-dev", default-features = false, path = "../../primitives/runtime" } diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index c8f746c7cb9d4..c2391a080a762 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -23,7 +23,7 @@ sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../pri trybuild = "1.0.43" pretty_assertions = "0.6.1" rustversion = "1.0.0" -frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../../metadata" } +frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../../metadata" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } # The "std" feature for this pallet is never activated on purpose, in order to test construct_runtime error message test-pallet = { package = "frame-support-test-pallet", default-features = false, path = "pallet" } From d62a13e7095557e8de8cce4795a7dd6cb393a35f Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Aug 2021 11:00:29 +0200 Subject: [PATCH 35/73] Revert "fix bug?" This reverts commit 8051bf1bf9bae862ff28dfff386e7045cd3f045e. --- Cargo.lock | 2 +- frame/metadata/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- frame/support/test/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25acd8206351e..3d22e0c0b6bd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1851,7 +1851,7 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "4.0.0-dev" +version = "14.0.0-dev" dependencies = [ "parity-scale-codec", "serde", diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 68054da927de7..332ce5b70c26e 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-metadata" -version = "4.0.0-dev" +version = "14.0.0-dev" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 45f7d55ebfae9..ed3a2f45a2e14 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] serde = { version = "1.0.126", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] } -frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../metadata" } +frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../metadata" } sp-std = { version = "4.0.0-dev", default-features = false, path = "../../primitives/std" } sp-io = { version = "4.0.0-dev", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "4.0.0-dev", default-features = false, path = "../../primitives/runtime" } diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index c2391a080a762..c8f746c7cb9d4 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -23,7 +23,7 @@ sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../pri trybuild = "1.0.43" pretty_assertions = "0.6.1" rustversion = "1.0.0" -frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../../metadata" } +frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../../metadata" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } # The "std" feature for this pallet is never activated on purpose, in order to test construct_runtime error message test-pallet = { package = "frame-support-test-pallet", default-features = false, path = "pallet" } From 0e20a9242283f7a27eb0070818b8bb8833f189fc Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Aug 2021 11:01:40 +0200 Subject: [PATCH 36/73] skip frame-metadata --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cef2d8badcc9..ca76ae86666b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,7 @@ variables: &default-vars CI_IMAGE: "paritytech/ci-linux:production" # FIXME set to release CARGO_UNLEASH_INSTALL_PARAMS: "--version 1.0.0-alpha.12" - CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder" + CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder frame-metadata" default: cache: {} @@ -273,7 +273,7 @@ node-bench-regression-guard: CI_IMAGE: "paritytech/node-bench-regression-guard:latest" before_script: [""] script: - - 'node-bench-regression-guard --reference artifacts/benches/master-* + - 'node-bench-regression-guard --reference artifacts/benches/master-* --compare-with artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA' cargo-check-subkey: @@ -578,7 +578,7 @@ build-rust-doc: - buildah push --format=v2s2 "$IMAGE_NAME:latest" after_script: - buildah logout "$IMAGE_NAME" - # pass artifacts to the trigger-simnet job + # pass artifacts to the trigger-simnet job - echo "IMAGE_NAME=${IMAGE_NAME}" | tee -a ./artifacts/$PRODUCT/build.env - IMAGE_TAG="$(cat ./artifacts/$PRODUCT/VERSION)" - echo "IMAGE_TAG=${IMAGE_TAG}" | tee -a ./artifacts/$PRODUCT/build.env @@ -713,7 +713,7 @@ trigger-simnet: - if: $CI_COMMIT_REF_NAME == "master" needs: - job: publish-docker-substrate - # `build.env` brings here `$IMAGE_NAME` and `$IMAGE_TAG` (`$VERSION` here, + # `build.env` brings here `$IMAGE_NAME` and `$IMAGE_TAG` (`$VERSION` here, # i.e. `2643-0.8.29-5f689e0a-6b24dc54`). variables: TRGR_PROJECT: ${CI_PROJECT_NAME} From a6aa550e3e15552501f0701cc7a123be64783122 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 18 Jul 2021 22:38:46 -0400 Subject: [PATCH 37/73] extract repeat out of benchmark --- frame/benchmarking/src/lib.rs | 192 ++++++------- frame/benchmarking/src/utils.rs | 4 - out | 0 pallet_balances.rs | 123 +++++++++ utils/frame/benchmarking-cli/src/command.rs | 292 +++++++++++--------- 5 files changed, 378 insertions(+), 233 deletions(-) create mode 100644 out create mode 100644 pallet_balances.rs diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index a0aa78f722f72..546c1f07bc41a 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -712,7 +712,6 @@ macro_rules! impl_benchmark { lowest_range_values: &[u32], highest_range_values: &[u32], steps: &[u32], - repeat: u32, whitelist: &[$crate::TrackedStorageKey], verify: bool, ) -> Result<$crate::Vec<$crate::BenchmarkResults>, &'static str> { @@ -724,9 +723,6 @@ macro_rules! impl_benchmark { _ => return Err("Could not find extrinsic."), }; let mut results: $crate::Vec<$crate::BenchmarkResults> = $crate::Vec::new(); - if repeat == 0 { - return Ok(results); - } // Add whitelist to DB including whitelisted caller let mut whitelist = whitelist.to_vec(); @@ -749,120 +745,114 @@ macro_rules! impl_benchmark { // Default number of steps for a component. let mut prev_steps = 10; - let mut repeat_benchmark = | - repeat: u32, + let mut do_benchmark = | c: &[($crate::BenchmarkParameter, u32)], results: &mut $crate::Vec<$crate::BenchmarkResults>, verify: bool, step: u32, num_steps: u32, | -> Result<(), &'static str> { - // Run the benchmark `repeat` times. - for r in 0..repeat { - // Set up the externalities environment for the setup we want to - // benchmark. - let closure_to_benchmark = < - SelectedBenchmark as $crate::BenchmarkingSetup - >::instance(&selected_benchmark, c, verify)?; - - // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { - frame_system::Pallet::::set_block_number(1u32.into()); - } - - // Commit the externalities to the database, flushing the DB cache. - // This will enable worst case scenario for reading from the database. - $crate::benchmarking::commit_db(); - - // Reset the read/write counter so we don't count operations in the setup process. - $crate::benchmarking::reset_read_write_count(); + // Set up the externalities environment for the setup we want to + // benchmark. + let closure_to_benchmark = < + SelectedBenchmark as $crate::BenchmarkingSetup + >::instance(&selected_benchmark, c, verify)?; - if verify { - closure_to_benchmark()?; - } else { - // Time the extrinsic logic. - $crate::log::trace!( - target: "benchmark", - "Start Benchmark: {:?}", c - ); - - let start_pov = $crate::benchmarking::proof_size(); - let start_extrinsic = $crate::benchmarking::current_time(); - - closure_to_benchmark()?; + // Set the block number to at least 1 so events are deposited. + if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); + } - let finish_extrinsic = $crate::benchmarking::current_time(); - let end_pov = $crate::benchmarking::proof_size(); + // Commit the externalities to the database, flushing the DB cache. + // This will enable worst case scenario for reading from the database. + $crate::benchmarking::commit_db(); - // Calculate the diff caused by the benchmark. - let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic); - let diff_pov = match (start_pov, end_pov) { - (Some(start), Some(end)) => end.saturating_sub(start), - _ => Default::default(), - }; + // Reset the read/write counter so we don't count operations in the setup process. + $crate::benchmarking::reset_read_write_count(); - // Commit the changes to get proper write count - $crate::benchmarking::commit_db(); - $crate::log::trace!( - target: "benchmark", - "End Benchmark: {} ns", elapsed_extrinsic - ); - let read_write_count = $crate::benchmarking::read_write_count(); - $crate::log::trace!( + if verify { + closure_to_benchmark()?; + } else { + // Time the extrinsic logic. + $crate::log::trace!( + target: "benchmark", + "Start Benchmark: {:?}", c + ); + + let start_pov = $crate::benchmarking::proof_size(); + let start_extrinsic = $crate::benchmarking::current_time(); + + closure_to_benchmark()?; + + let finish_extrinsic = $crate::benchmarking::current_time(); + let end_pov = $crate::benchmarking::proof_size(); + + // Calculate the diff caused by the benchmark. + let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic); + let diff_pov = match (start_pov, end_pov) { + (Some(start), Some(end)) => end.saturating_sub(start), + _ => Default::default(), + }; + + // Commit the changes to get proper write count + $crate::benchmarking::commit_db(); + $crate::log::trace!( + target: "benchmark", + "End Benchmark: {} ns", elapsed_extrinsic + ); + let read_write_count = $crate::benchmarking::read_write_count(); + $crate::log::trace!( + target: "benchmark", + "Read/Write Count {:?}", read_write_count + ); + + let time = $crate::benchmarking::current_time(); + if time.saturating_sub(progress) > 5000000000 { + progress = $crate::benchmarking::current_time(); + $crate::log::info!( target: "benchmark", - "Read/Write Count {:?}", read_write_count + "Benchmarking {} {}/{}", + extrinsic, + step, + num_steps, ); - - let time = $crate::benchmarking::current_time(); - if time.saturating_sub(progress) > 5000000000 { - progress = $crate::benchmarking::current_time(); - $crate::log::info!( - target: "benchmark", - "Benchmarking {} {}/{}, run {}/{}", - extrinsic, - step, - num_steps, - r, - repeat, - ); - } - - // Time the storage root recalculation. - let start_storage_root = $crate::benchmarking::current_time(); - $crate::storage_root(); - let finish_storage_root = $crate::benchmarking::current_time(); - let elapsed_storage_root = finish_storage_root - start_storage_root; - - // TODO: Fix memory allocation issue then re-enable - // let read_and_written_keys = $crate::benchmarking::get_read_and_written_keys(); - let read_and_written_keys = Default::default(); - - results.push($crate::BenchmarkResults { - components: c.to_vec(), - extrinsic_time: elapsed_extrinsic, - storage_root_time: elapsed_storage_root, - reads: read_write_count.0, - repeat_reads: read_write_count.1, - writes: read_write_count.2, - repeat_writes: read_write_count.3, - proof_size: diff_pov, - keys: read_and_written_keys, - }); } - // Wipe the DB back to the genesis state. - $crate::benchmarking::wipe_db(); + // Time the storage root recalculation. + let start_storage_root = $crate::benchmarking::current_time(); + $crate::storage_root(); + let finish_storage_root = $crate::benchmarking::current_time(); + let elapsed_storage_root = finish_storage_root - start_storage_root; + + // TODO: Fix memory allocation issue then re-enable + let read_and_written_keys = $crate::benchmarking::get_read_and_written_keys(); + //let read_and_written_keys = Default::default(); + + results.push($crate::BenchmarkResults { + components: c.to_vec(), + extrinsic_time: elapsed_extrinsic, + storage_root_time: elapsed_storage_root, + reads: read_write_count.0, + repeat_reads: read_write_count.1, + writes: read_write_count.2, + repeat_writes: read_write_count.3, + proof_size: diff_pov, + keys: read_and_written_keys, + }); } + // Wipe the DB back to the genesis state. + $crate::benchmarking::wipe_db(); + Ok(()) }; if components.is_empty() { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - repeat_benchmark(1, Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; } - repeat_benchmark(repeat, Default::default(), &mut results, false, 1, 1)?; + do_benchmark(Default::default(), &mut results, false, 1, 1)?; } else { // Select the component we will be benchmarking. Each component will be benchmarked. for (idx, (name, low, high)) in components.iter().enumerate() { @@ -900,9 +890,9 @@ macro_rules! impl_benchmark { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - repeat_benchmark(1, &c, &mut $crate::Vec::new(), true, s, num_of_steps)?; + do_benchmark(&c, &mut $crate::Vec::new(), true, s, num_of_steps)?; } - repeat_benchmark(repeat, &c, &mut results, false, s, num_of_steps)?; + do_benchmark(&c, &mut results, false, s, num_of_steps)?; } } } @@ -1254,7 +1244,6 @@ pub fn show_benchmark_debug_info( lowest_range_values: &sp_std::prelude::Vec, highest_range_values: &sp_std::prelude::Vec, steps: &sp_std::prelude::Vec, - repeat: &u32, verify: &bool, error_message: &str, ) -> sp_runtime::RuntimeString { @@ -1264,7 +1253,6 @@ pub fn show_benchmark_debug_info( * Lowest_range_values: {:?}\n\ * Highest_range_values: {:?}\n\ * Steps: {:?}\n\ - * Repeat: {:?}\n\ * Verify: {:?}\n\ * Error message: {}", sp_std::str::from_utf8(instance_string) @@ -1274,7 +1262,6 @@ pub fn show_benchmark_debug_info( lowest_range_values, highest_range_values, steps, - repeat, verify, error_message, ) @@ -1355,7 +1342,6 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, - repeat, verify, extra, } = config; @@ -1371,7 +1357,6 @@ macro_rules! add_benchmark { &lowest_range_values[..], &highest_range_values[..], &steps[..], - *repeat, whitelist, *verify, ).map_err(|e| { @@ -1381,7 +1366,6 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, - repeat, verify, e, ) @@ -1398,7 +1382,6 @@ macro_rules! add_benchmark { &lowest_range_values[..], &highest_range_values[..], &steps[..], - *repeat, whitelist, *verify, ).map_err(|e| { @@ -1408,7 +1391,6 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, - repeat, verify, e, ) diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 33d479a0b54a7..a641bd6b666d6 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -105,8 +105,6 @@ pub struct BenchmarkConfig { pub highest_range_values: Vec, /// The number of samples to take across the range of values for components. pub steps: Vec, - /// The number of times to repeat a benchmark. - pub repeat: u32, /// Enable an extra benchmark iteration which runs the verification logic for a benchmark. pub verify: bool, /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a pallet. @@ -219,13 +217,11 @@ pub trait Benchmarking { /// - `steps`: The number of sample points you want to take across the range of parameters. /// - `lowest_range_values`: The lowest number for each range of parameters. /// - `highest_range_values`: The highest number for each range of parameters. - /// - `repeat`: The number of times you want to repeat a benchmark. fn run_benchmark( name: &[u8], lowest_range_values: &[u32], highest_range_values: &[u32], steps: &[u32], - repeat: u32, whitelist: &[TrackedStorageKey], verify: bool, ) -> Result, &'static str>; diff --git a/out b/out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/pallet_balances.rs b/pallet_balances.rs new file mode 100644 index 0000000000000..a6980d4d6e843 --- /dev/null +++ b/pallet_balances.rs @@ -0,0 +1,123 @@ +// This file is part of Substrate. + +// Copyright (C) 2021 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Autogenerated weights for pallet_balances +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Interpreted, CHAIN: Some("dev"), DB CACHE: 128 + +// Executed Command: +// target/release/substrate +// benchmark +// --chain=dev +// --steps=50 +// --repeat=10 +// --pallet=pallet_balances +// --extrinsic=* +// --execution=wasm +// --wasm-execution=interpreted-i-know-what-i-do +// --heap-pages=4096 +// --output=./ +// --template=./.maintain/frame-weight-template.hbs +// --raw + + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_balances. +pub trait WeightInfo { + fn force_transfer() -> Weight; + fn transfer_all() -> Weight; + fn transfer() -> Weight; + fn transfer_keep_alive() -> Weight; + fn set_balance_creating() -> Weight; + fn set_balance_killing() -> Weight; +} + +/// Weights for pallet_balances using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn force_transfer() -> Weight { + (330_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + fn transfer_all() -> Weight { + (327_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn transfer() -> Weight { + (335_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn transfer_keep_alive() -> Weight { + (262_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn set_balance_creating() -> Weight { + (103_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn set_balance_killing() -> Weight { + (124_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn force_transfer() -> Weight { + (330_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + fn transfer_all() -> Weight { + (327_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn transfer() -> Weight { + (335_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn transfer_keep_alive() -> Weight { + (262_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn set_balance_creating() -> Weight { + (103_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn set_balance_killing() -> Weight { + (124_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } +} diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 2ef9f3914a5d7..14e86e6240add 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -17,7 +17,7 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; -use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkSelector}; +use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector}; use frame_support::traits::StorageInfo; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; use sc_client_db::BenchmarkingState; @@ -31,7 +31,43 @@ use sp_externalities::Extensions; use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use sp_state_machine::StateMachine; -use std::{fmt::Debug, sync::Arc}; +use std::{collections::HashMap, fmt::Debug, sync::Arc}; + +// This takes multiple benchmark batches and combines all the results where the pallet, instance, +// and benchmark are the same. +fn combine_batches(batches: Vec) -> Vec { + if batches.is_empty() { + return batches + } + + let mut all_benchmarks = HashMap::<_, Vec>::new(); + + batches + .into_iter() + .for_each(|BenchmarkBatch { pallet, instance, benchmark, results }| { + // We use this key to uniquely identify a benchmark among batches. + let key = (pallet, instance, benchmark); + + match all_benchmarks.get_mut(&key) { + // We already have this benchmark, so we extend the results. + Some(x) => x.extend(results), + // New benchmark, so we add a new entry with the initial results. + None => { + all_benchmarks.insert(key, results); + }, + } + }); + + all_benchmarks + .into_iter() + .map(|((pallet, instance, benchmark), results)| BenchmarkBatch { + pallet, + instance, + benchmark, + results, + }) + .collect::>() +} impl BenchmarkCmd { /// Runs the command and benchmarks the chain. @@ -74,137 +110,145 @@ impl BenchmarkCmd { 2, // The runtime instances cache size. ); - let mut extensions = Extensions::default(); - extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); - let (offchain, _) = TestOffchainExt::new(); - let (pool, _) = TestTransactionPoolExt::new(); - extensions.register(OffchainWorkerExt::new(offchain.clone())); - extensions.register(OffchainDbExt::new(offchain)); - extensions.register(TransactionPoolExt::new(pool)); - - let result = StateMachine::<_, _, NumberFor, _>::new( - &state, - None, - &mut changes, - &executor, - "Benchmark_dispatch_benchmark", - &( - &self.pallet, - &self.extrinsic, - self.lowest_range_values.clone(), - self.highest_range_values.clone(), - self.steps.clone(), - self.repeat, - !self.no_verify, - self.extra, + let mut batches = Vec::new(); + let mut storage_info = Vec::new(); + + for r in 0..self.repeat { + let mut extensions = Extensions::default(); + extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); + let (offchain, _) = TestOffchainExt::new(); + let (pool, _) = TestTransactionPoolExt::new(); + extensions.register(OffchainWorkerExt::new(offchain.clone())); + extensions.register(OffchainDbExt::new(offchain)); + extensions.register(TransactionPoolExt::new(pool)); + + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_dispatch_benchmark", + &( + &self.pallet, + &self.extrinsic, + self.lowest_range_values.clone(), + self.highest_range_values.clone(), + self.steps.clone(), + r, + !self.no_verify, + self.extra, + ) + .encode(), + extensions, + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), ) - .encode(), - extensions, - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, - sp_core::testing::TaskExecutor::new(), - ) - .execute(strategy.into()) - .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - - let results = , Vec), String, > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))?; + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; - match results { - Ok((batches, storage_info)) => { - if let Some(output_path) = &self.output { - crate::writer::write_results(&batches, &storage_info, output_path, self)?; - } + batches.extend(batch); + storage_info = last_storage_info; + } + + let batches = combine_batches(batches); + + for b in batches.clone() { + println!( + "{:?}: {:?}", + String::from_utf8(b.pallet).unwrap(), + String::from_utf8(b.benchmark).unwrap(), + ); + } - for batch in batches.into_iter() { - // Print benchmark metadata - println!( - "Pallet: {:?}, Extrinsic: {:?}, Lowest values: {:?}, Highest values: {:?}, Steps: {:?}, Repeat: {:?}", - String::from_utf8(batch.pallet).expect("Encoded from String; qed"), - String::from_utf8(batch.benchmark).expect("Encoded from String; qed"), - self.lowest_range_values, - self.highest_range_values, - self.steps, - self.repeat, + if let Some(output_path) = &self.output { + crate::writer::write_results(&batches, &storage_info, output_path, self)?; + } + + for batch in batches.into_iter() { + // Print benchmark metadata + println!( + "Pallet: {:?}, Extrinsic: {:?}, Lowest values: {:?}, Highest values: {:?}, Steps: {:?}, Repeat: {:?}", + String::from_utf8(batch.pallet).expect("Encoded from String; qed"), + String::from_utf8(batch.benchmark).expect("Encoded from String; qed"), + self.lowest_range_values, + self.highest_range_values, + self.steps, + self.repeat, + ); + + // Skip raw data + analysis if there are no results + if batch.results.is_empty() { + continue + } + + if self.raw_data { + // Print the table header + batch.results[0].components.iter().for_each(|param| print!("{:?},", param.0)); + + print!("extrinsic_time_ns,storage_root_time_ns,reads,repeat_reads,writes,repeat_writes,proof_size_bytes\n"); + // Print the values + batch.results.iter().for_each(|result| { + let parameters = &result.components; + parameters.iter().for_each(|param| print!("{:?},", param.1)); + // Print extrinsic time and storage root time + print!( + "{:?},{:?},{:?},{:?},{:?},{:?},{:?}\n", + result.extrinsic_time, + result.storage_root_time, + result.reads, + result.repeat_reads, + result.writes, + result.repeat_writes, + result.proof_size, ); + }); - // Skip raw data + analysis if there are no results - if batch.results.is_empty() { - continue - } - - if self.raw_data { - // Print the table header - batch.results[0] - .components - .iter() - .for_each(|param| print!("{:?},", param.0)); - - print!("extrinsic_time_ns,storage_root_time_ns,reads,repeat_reads,writes,repeat_writes,proof_size_bytes\n"); - // Print the values - batch.results.iter().for_each(|result| { - let parameters = &result.components; - parameters.iter().for_each(|param| print!("{:?},", param.1)); - // Print extrinsic time and storage root time - print!( - "{:?},{:?},{:?},{:?},{:?},{:?},{:?}\n", - result.extrinsic_time, - result.storage_root_time, - result.reads, - result.repeat_reads, - result.writes, - result.repeat_writes, - result.proof_size, - ); - }); - - println!(); - } - - // Conduct analysis. - if !self.no_median_slopes { - println!("Median Slopes Analysis\n========"); - if let Some(analysis) = Analysis::median_slopes( - &batch.results, - BenchmarkSelector::ExtrinsicTime, - ) { - println!("-- Extrinsic Time --\n{}", analysis); - } - if let Some(analysis) = - Analysis::median_slopes(&batch.results, BenchmarkSelector::Reads) - { - println!("Reads = {:?}", analysis); - } - if let Some(analysis) = - Analysis::median_slopes(&batch.results, BenchmarkSelector::Writes) - { - println!("Writes = {:?}", analysis); - } - } - if !self.no_min_squares { - println!("Min Squares Analysis\n========"); - if let Some(analysis) = Analysis::min_squares_iqr( - &batch.results, - BenchmarkSelector::ExtrinsicTime, - ) { - println!("-- Extrinsic Time --\n{}", analysis); - } - if let Some(analysis) = - Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Reads) - { - println!("Reads = {:?}", analysis); - } - if let Some(analysis) = - Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Writes) - { - println!("Writes = {:?}", analysis); - } - } + println!(); + } + + // Conduct analysis. + if !self.no_median_slopes { + println!("Median Slopes Analysis\n========"); + if let Some(analysis) = + Analysis::median_slopes(&batch.results, BenchmarkSelector::ExtrinsicTime) + { + println!("-- Extrinsic Time --\n{}", analysis); + } + if let Some(analysis) = + Analysis::median_slopes(&batch.results, BenchmarkSelector::Reads) + { + println!("Reads = {:?}", analysis); + } + if let Some(analysis) = + Analysis::median_slopes(&batch.results, BenchmarkSelector::Writes) + { + println!("Writes = {:?}", analysis); + } + } + if !self.no_min_squares { + println!("Min Squares Analysis\n========"); + if let Some(analysis) = + Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::ExtrinsicTime) + { + println!("-- Extrinsic Time --\n{}", analysis); + } + if let Some(analysis) = + Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Reads) + { + println!("Reads = {:?}", analysis); } - }, - Err(error) => eprintln!("Error: {}", error), + if let Some(analysis) = + Analysis::min_squares_iqr(&batch.results, BenchmarkSelector::Writes) + { + println!("Writes = {:?}", analysis); + } + } } Ok(()) From 5cbc0fedc59bcf007d440d036618ae2d80004cdd Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 18 Jul 2021 22:49:50 -0400 Subject: [PATCH 38/73] remove r --- utils/frame/benchmarking-cli/src/command.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 14e86e6240add..ca1f0a318e2c3 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -134,7 +134,6 @@ impl BenchmarkCmd { self.lowest_range_values.clone(), self.highest_range_values.clone(), self.steps.clone(), - r, !self.no_verify, self.extra, ) From a7ed8868dffddbe0e8bda66e968bd3480efdc2bb Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Mon, 19 Jul 2021 02:57:33 +0000 Subject: [PATCH 39/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 76 ++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index d1e86ce45e4b3..faf354af9d4de 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -17,8 +17,8 @@ //! Autogenerated weights for pallet_balances //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -46,43 +46,49 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. pub trait WeightInfo { fn transfer() -> Weight; - fn transfer_keep_alive() -> Weight; fn set_balance_creating() -> Weight; - fn set_balance_killing() -> Weight; fn force_transfer() -> Weight; fn transfer_all() -> Weight; + fn transfer_keep_alive() -> Weight; + fn set_balance_killing() -> Weight; } /// Weights for pallet_balances using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (73_268_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (54_881_000 as Weight) + (76_264_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (29_853_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (36_007_000 as Weight) + (30_731_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (72_541_000 as Weight) + (74_715_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } + // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (67_360_000 as Weight) + (69_789_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn transfer_keep_alive() -> Weight { + (56_681_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn set_balance_killing() -> Weight { + (37_083_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -90,33 +96,39 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { + // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (73_268_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (54_881_000 as Weight) + (76_264_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (29_853_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (36_007_000 as Weight) + (30_731_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (72_541_000 as Weight) + (74_715_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } + // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (67_360_000 as Weight) + (69_789_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn transfer_keep_alive() -> Weight { + (56_681_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn set_balance_killing() -> Weight { + (37_083_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From 4079b3296190e0dbe39ea9894e6fceef0d937870 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Mon, 19 Jul 2021 03:32:21 +0000 Subject: [PATCH 40/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index faf354af9d4de..3925ec11b39c6 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -45,11 +45,11 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. pub trait WeightInfo { - fn transfer() -> Weight; fn set_balance_creating() -> Weight; + fn transfer_keep_alive() -> Weight; fn force_transfer() -> Weight; + fn transfer() -> Weight; fn transfer_all() -> Weight; - fn transfer_keep_alive() -> Weight; fn set_balance_killing() -> Weight; } @@ -57,38 +57,38 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (76_264_000 as Weight) + fn set_balance_creating() -> Weight { + (30_439_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_731_000 as Weight) + fn transfer_keep_alive() -> Weight { + (55_632_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (74_715_000 as Weight) + (74_593_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (69_789_000 as Weight) + fn transfer() -> Weight { + (75_298_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_keep_alive() -> Weight { - (56_681_000 as Weight) + fn transfer_all() -> Weight { + (68_792_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_083_000 as Weight) + (37_101_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -97,38 +97,38 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (76_264_000 as Weight) + fn set_balance_creating() -> Weight { + (30_439_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_731_000 as Weight) + fn transfer_keep_alive() -> Weight { + (55_632_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (74_715_000 as Weight) + (74_593_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (69_789_000 as Weight) + fn transfer() -> Weight { + (75_298_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_keep_alive() -> Weight { - (56_681_000 as Weight) + fn transfer_all() -> Weight { + (68_792_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_083_000 as Weight) + (37_101_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From fbd8e48d2896f616cb477af69a36f45341de6705 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Mon, 19 Jul 2021 04:33:00 +0000 Subject: [PATCH 41/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/staking/src/weights.rs | 810 ++++++++++++++++++++++++----------- 1 file changed, 549 insertions(+), 261 deletions(-) diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index cba4e68b5f61e..0dbd4ed66f0c0 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -17,8 +17,8 @@ //! Autogenerated weights for pallet_staking //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -45,409 +45,697 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_staking. pub trait WeightInfo { - fn bond() -> Weight; - fn bond_extra() -> Weight; - fn unbond() -> Weight; - fn withdraw_unbonded_update(s: u32, ) -> Weight; - fn withdraw_unbonded_kill(s: u32, ) -> Weight; - fn validate() -> Weight; fn kick(k: u32, ) -> Weight; - fn nominate(n: u32, ) -> Weight; - fn chill() -> Weight; - fn set_payee() -> Weight; fn set_controller() -> Weight; - fn set_validator_count() -> Weight; - fn force_no_eras() -> Weight; - fn force_new_era() -> Weight; fn force_new_era_always() -> Weight; - fn set_invulnerables(v: u32, ) -> Weight; + fn withdraw_unbonded_update(s: u32, ) -> Weight; fn force_unstake(s: u32, ) -> Weight; fn cancel_deferred_slash(s: u32, ) -> Weight; - fn payout_stakers_dead_controller(n: u32, ) -> Weight; + fn withdraw_unbonded_kill(s: u32, ) -> Weight; fn payout_stakers_alive_staked(n: u32, ) -> Weight; fn rebond(l: u32, ) -> Weight; - fn set_history_depth(e: u32, ) -> Weight; - fn reap_stash(s: u32, ) -> Weight; - fn new_era(v: u32, n: u32, ) -> Weight; fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight; + fn force_no_eras() -> Weight; + fn set_invulnerables(v: u32, ) -> Weight; + fn payout_stakers_dead_controller(n: u32, ) -> Weight; + fn chill() -> Weight; + fn set_payee() -> Weight; + fn nominate(n: u32, ) -> Weight; fn get_npos_targets(v: u32, ) -> Weight; + fn force_new_era() -> Weight; + fn set_history_depth(e: u32, ) -> Weight; fn set_staking_limits() -> Weight; + fn bond_extra() -> Weight; + fn validate() -> Weight; + fn set_validator_count() -> Weight; + fn unbond() -> Weight; + fn reap_stash(s: u32, ) -> Weight; + fn new_era(v: u32, n: u32, ) -> Weight; + fn bond() -> Weight; fn chill_other() -> Weight; } /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - fn bond() -> Weight { - (72_617_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - } - fn bond_extra() -> Weight { - (55_590_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - fn unbond() -> Weight { - (59_730_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_279_000 as Weight) - // Standard Error: 0 - .saturating_add((68_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_629_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_379_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - fn validate() -> Weight { - (32_393_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (36_986_000 as Weight) - // Standard Error: 13_000 - .saturating_add((16_574_000 as Weight).saturating_mul(k as Weight)) + (15_687_000 as Weight) + // Standard Error: 10_000 + .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } - fn nominate(n: u32, ) -> Weight { - (43_228_000 as Weight) - // Standard Error: 21_000 - .saturating_add((5_119_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - fn chill() -> Weight { - (17_800_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - } - fn set_payee() -> Weight { - (12_612_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (27_503_000 as Weight) + (26_437_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - fn set_validator_count() -> Weight { - (2_119_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn force_no_eras() -> Weight { - (2_320_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn force_new_era() -> Weight { - (2_269_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } + // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_334_000 as Weight) + (2_370_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - fn set_invulnerables(v: u32, ) -> Weight { - (2_354_000 as Weight) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (51_712_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_556_000 as Weight) + (61_438_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_377_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_367_105_000 as Weight) + (3_382_921_000 as Weight) // Standard Error: 222_000 - .saturating_add((19_817_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (47_229_000 as Weight) - // Standard Error: 53_000 - .saturating_add((48_365_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + // Storage: Staking Validators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (85_987_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (156_788_000 as Weight) - // Standard Error: 20_000 - .saturating_add((61_280_000 as Weight).saturating_mul(n as Weight)) + (154_336_000 as Weight) + // Standard Error: 22_000 + .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (47_815_000 as Weight) + (48_596_000 as Weight) // Standard Error: 1_000 - .saturating_add((65_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + // Storage: Staking SlashingSpans (r:21 w:0) + // Storage: Staking Validators (r:501 w:0) + // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) + // Storage: Staking Bonded (r:1500 w:0) + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 95_000 + .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 95_000 + .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_234_000 + .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_396_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_389_000 as Weight) + // Standard Error: 0 + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (117_261_000 as Weight) + // Standard Error: 15_000 + .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + fn chill() -> Weight { + (18_448_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) + fn set_payee() -> Weight { + (12_210_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking MinNominatorBond (r:1 w:0) + fn nominate(n: u32, ) -> Weight { + (41_518_000 as Weight) + // Standard Error: 11_000 + .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Validators (r:501 w:0) + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 28_000 + .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_332_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:2) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasValidatorPrefs (r:0 w:2) + // Storage: Staking HistoryDepth (r:1 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 74_000 - .saturating_add((34_945_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } + // Storage: Staking MaxValidatorsCount (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) + // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) + // Storage: Staking MaxNominatorsCount (r:0 w:1) + fn set_staking_limits() -> Weight { + (6_412_000 as Weight) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) + } + // Storage: Staking Bonded (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond_extra() -> Weight { + (56_614_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + fn validate() -> Weight { + (34_652_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_284_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + fn unbond() -> Weight { + (60_745_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Staking SpanSlash (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_483_000 as Weight) + (72_938_000 as Weight) // Standard Error: 0 - .saturating_add((2_384_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Bonded (r:101 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Nominators (r:101 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 846_000 - .saturating_add((305_234_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 847_000 + .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 42_000 - .saturating_add((48_280_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 99_000 - .saturating_add((25_735_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 99_000 - .saturating_add((28_122_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_388_000 - .saturating_add((21_500_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - } - fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 30_000 - .saturating_add((11_065_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - } - fn set_staking_limits() -> Weight { - (5_028_000 as Weight) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond() -> Weight { + (73_985_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MaxValidatorsCount (r:1 w:0) fn chill_other() -> Weight { - (35_758_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) + (61_381_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } } // For backwards compatibility and tests impl WeightInfo for () { - fn bond() -> Weight { - (72_617_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - } - fn bond_extra() -> Weight { - (55_590_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - fn unbond() -> Weight { - (59_730_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_279_000 as Weight) - // Standard Error: 0 - .saturating_add((68_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_629_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_379_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - fn validate() -> Weight { - (32_393_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (36_986_000 as Weight) - // Standard Error: 13_000 - .saturating_add((16_574_000 as Weight).saturating_mul(k as Weight)) + (15_687_000 as Weight) + // Standard Error: 10_000 + .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } - fn nominate(n: u32, ) -> Weight { - (43_228_000 as Weight) - // Standard Error: 21_000 - .saturating_add((5_119_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - fn chill() -> Weight { - (17_800_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - } - fn set_payee() -> Weight { - (12_612_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (27_503_000 as Weight) + (26_437_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - fn set_validator_count() -> Weight { - (2_119_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn force_no_eras() -> Weight { - (2_320_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn force_new_era() -> Weight { - (2_269_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } + // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_334_000 as Weight) + (2_370_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - fn set_invulnerables(v: u32, ) -> Weight { - (2_354_000 as Weight) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (51_712_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_556_000 as Weight) + (61_438_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_377_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_367_105_000 as Weight) + (3_382_921_000 as Weight) // Standard Error: 222_000 - .saturating_add((19_817_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (47_229_000 as Weight) - // Standard Error: 53_000 - .saturating_add((48_365_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + // Storage: Staking Validators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (85_987_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(8 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (156_788_000 as Weight) - // Standard Error: 20_000 - .saturating_add((61_280_000 as Weight).saturating_mul(n as Weight)) + (154_336_000 as Weight) + // Standard Error: 22_000 + .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (47_815_000 as Weight) + (48_596_000 as Weight) // Standard Error: 1_000 - .saturating_add((65_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: Staking SlashingSpans (r:21 w:0) + // Storage: Staking Validators (r:501 w:0) + // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) + // Storage: Staking Bonded (r:1500 w:0) + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 95_000 + .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 95_000 + .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_234_000 + .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_396_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_389_000 as Weight) + // Standard Error: 0 + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (117_261_000 as Weight) + // Standard Error: 15_000 + .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(10 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + fn chill() -> Weight { + (18_448_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) + fn set_payee() -> Weight { + (12_210_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking MinNominatorBond (r:1 w:0) + fn nominate(n: u32, ) -> Weight { + (41_518_000 as Weight) + // Standard Error: 11_000 + .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Validators (r:501 w:0) + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 28_000 + .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_332_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:2) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasValidatorPrefs (r:0 w:2) + // Storage: Staking HistoryDepth (r:1 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 74_000 - .saturating_add((34_945_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } + // Storage: Staking MaxValidatorsCount (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) + // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) + // Storage: Staking MaxNominatorsCount (r:0 w:1) + fn set_staking_limits() -> Weight { + (6_412_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + } + // Storage: Staking Bonded (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond_extra() -> Weight { + (56_614_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + fn validate() -> Weight { + (34_652_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_284_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + fn unbond() -> Weight { + (60_745_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + } + // Storage: Staking SpanSlash (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_483_000 as Weight) + (72_938_000 as Weight) // Standard Error: 0 - .saturating_add((2_384_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Bonded (r:101 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Nominators (r:101 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 846_000 - .saturating_add((305_234_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 847_000 + .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 42_000 - .saturating_add((48_280_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 99_000 - .saturating_add((25_735_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 99_000 - .saturating_add((28_122_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_388_000 - .saturating_add((21_500_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - } - fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 30_000 - .saturating_add((11_065_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - } - fn set_staking_limits() -> Weight { - (5_028_000 as Weight) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + fn bond() -> Weight { + (73_985_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MaxValidatorsCount (r:1 w:0) fn chill_other() -> Weight { - (35_758_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + (61_381_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } } From 05ee330708ee5192e0f44096d3f4d88e71750492 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 20 Jul 2021 23:01:33 -0400 Subject: [PATCH 42/73] use linked map to keep order --- Cargo.lock | 1 + utils/frame/benchmarking-cli/Cargo.toml | 1 + utils/frame/benchmarking-cli/src/command.rs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 6cfc2d19db81f..2f3420f2bea71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1800,6 +1800,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "handlebars", + "linked-hash-map", "parity-scale-codec", "sc-cli", "sc-client-db", diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 9bae971019779..e9445b03971f8 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -30,6 +30,7 @@ chrono = "0.4" serde = "1.0.126" handlebars = "3.5.0" Inflector = "0.11.4" +linked-hash-map = "0.5.4" [features] default = ["db"] diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index ca1f0a318e2c3..b2b37227bc752 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -19,6 +19,7 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector}; use frame_support::traits::StorageInfo; +use linked_hash_map::LinkedHashMap; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; use sc_client_db::BenchmarkingState; use sc_executor::NativeExecutor; @@ -40,7 +41,7 @@ fn combine_batches(batches: Vec) -> Vec { return batches } - let mut all_benchmarks = HashMap::<_, Vec>::new(); + let mut all_benchmarks = LinkedHashMap::<_, Vec>::new(); batches .into_iter() From 8cf07b4195f686d171a0689d999a585c28d63f40 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Wed, 21 Jul 2021 03:06:51 +0000 Subject: [PATCH 43/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index 3925ec11b39c6..aa5bc697a42dd 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -45,50 +45,50 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_balances. pub trait WeightInfo { - fn set_balance_creating() -> Weight; + fn transfer() -> Weight; fn transfer_keep_alive() -> Weight; + fn set_balance_creating() -> Weight; + fn set_balance_killing() -> Weight; fn force_transfer() -> Weight; - fn transfer() -> Weight; fn transfer_all() -> Weight; - fn set_balance_killing() -> Weight; } /// Weights for pallet_balances using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_439_000 as Weight) + fn transfer() -> Weight { + (78_138_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (55_632_000 as Weight) + (57_454_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) - fn force_transfer() -> Weight { - (74_593_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (75_298_000 as Weight) + fn set_balance_creating() -> Weight { + (31_664_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (68_792_000 as Weight) + fn set_balance_killing() -> Weight { + (37_901_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) + fn force_transfer() -> Weight { + (76_515_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } // Storage: System Account (r:1 w:1) - fn set_balance_killing() -> Weight { - (37_101_000 as Weight) + fn transfer_all() -> Weight { + (71_007_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -97,38 +97,38 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { // Storage: System Account (r:1 w:1) - fn set_balance_creating() -> Weight { - (30_439_000 as Weight) + fn transfer() -> Weight { + (78_138_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (55_632_000 as Weight) + (57_454_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) - fn force_transfer() -> Weight { - (74_593_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } // Storage: System Account (r:1 w:1) - fn transfer() -> Weight { - (75_298_000 as Weight) + fn set_balance_creating() -> Weight { + (31_664_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) - fn transfer_all() -> Weight { - (68_792_000 as Weight) + fn set_balance_killing() -> Weight { + (37_901_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + // Storage: System Account (r:2 w:2) + fn force_transfer() -> Weight { + (76_515_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } // Storage: System Account (r:1 w:1) - fn set_balance_killing() -> Weight { - (37_101_000 as Weight) + fn transfer_all() -> Weight { + (71_007_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From 4518215a8055934e175c17c17b1b5d30b85851c0 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 20 Jul 2021 23:08:44 -0400 Subject: [PATCH 44/73] Delete pallet_balances.rs --- pallet_balances.rs | 123 --------------------------------------------- 1 file changed, 123 deletions(-) delete mode 100644 pallet_balances.rs diff --git a/pallet_balances.rs b/pallet_balances.rs deleted file mode 100644 index a6980d4d6e843..0000000000000 --- a/pallet_balances.rs +++ /dev/null @@ -1,123 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for pallet_balances -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Interpreted, CHAIN: Some("dev"), DB CACHE: 128 - -// Executed Command: -// target/release/substrate -// benchmark -// --chain=dev -// --steps=50 -// --repeat=10 -// --pallet=pallet_balances -// --extrinsic=* -// --execution=wasm -// --wasm-execution=interpreted-i-know-what-i-do -// --heap-pages=4096 -// --output=./ -// --template=./.maintain/frame-weight-template.hbs -// --raw - - -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_balances. -pub trait WeightInfo { - fn force_transfer() -> Weight; - fn transfer_all() -> Weight; - fn transfer() -> Weight; - fn transfer_keep_alive() -> Weight; - fn set_balance_creating() -> Weight; - fn set_balance_killing() -> Weight; -} - -/// Weights for pallet_balances using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - fn force_transfer() -> Weight { - (330_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - fn transfer_all() -> Weight { - (327_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer() -> Weight { - (335_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (262_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_balance_creating() -> Weight { - (103_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (124_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - fn force_transfer() -> Weight { - (330_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - fn transfer_all() -> Weight { - (327_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn transfer() -> Weight { - (335_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn transfer_keep_alive() -> Weight { - (262_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn set_balance_creating() -> Weight { - (103_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - fn set_balance_killing() -> Weight { - (124_000_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } -} From 8de80431c5754a12e67495ee7df6b735ca4d0977 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 20 Jul 2021 23:08:55 -0400 Subject: [PATCH 45/73] Delete out --- out | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 out diff --git a/out b/out deleted file mode 100644 index e69de29bb2d1d..0000000000000 From 8c27b0b3dbdaa1a5a046728d6f338e93e2e9f8be Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Wed, 21 Jul 2021 04:10:27 +0000 Subject: [PATCH 46/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/staking/src/weights.rs | 962 +++++++++++++++++------------------ 1 file changed, 481 insertions(+), 481 deletions(-) diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index 0dbd4ed66f0c0..7d2b3363de554 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -45,696 +45,696 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_staking. pub trait WeightInfo { + fn bond() -> Weight; + fn bond_extra() -> Weight; + fn unbond() -> Weight; + fn withdraw_unbonded_update(s: u32, ) -> Weight; + fn withdraw_unbonded_kill(s: u32, ) -> Weight; + fn validate() -> Weight; fn kick(k: u32, ) -> Weight; + fn nominate(n: u32, ) -> Weight; + fn chill() -> Weight; + fn set_payee() -> Weight; fn set_controller() -> Weight; + fn set_validator_count() -> Weight; + fn force_no_eras() -> Weight; + fn force_new_era() -> Weight; fn force_new_era_always() -> Weight; - fn withdraw_unbonded_update(s: u32, ) -> Weight; + fn set_invulnerables(v: u32, ) -> Weight; fn force_unstake(s: u32, ) -> Weight; fn cancel_deferred_slash(s: u32, ) -> Weight; - fn withdraw_unbonded_kill(s: u32, ) -> Weight; + fn payout_stakers_dead_controller(n: u32, ) -> Weight; fn payout_stakers_alive_staked(n: u32, ) -> Weight; fn rebond(l: u32, ) -> Weight; - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight; - fn force_no_eras() -> Weight; - fn set_invulnerables(v: u32, ) -> Weight; - fn payout_stakers_dead_controller(n: u32, ) -> Weight; - fn chill() -> Weight; - fn set_payee() -> Weight; - fn nominate(n: u32, ) -> Weight; - fn get_npos_targets(v: u32, ) -> Weight; - fn force_new_era() -> Weight; fn set_history_depth(e: u32, ) -> Weight; - fn set_staking_limits() -> Weight; - fn bond_extra() -> Weight; - fn validate() -> Weight; - fn set_validator_count() -> Weight; - fn unbond() -> Weight; fn reap_stash(s: u32, ) -> Weight; fn new_era(v: u32, n: u32, ) -> Weight; - fn bond() -> Weight; + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight; + fn get_npos_targets(v: u32, ) -> Weight; + fn set_staking_limits() -> Weight; fn chill_other() -> Weight; } /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn bond() -> Weight { + (73_506_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + fn bond_extra() -> Weight { + (57_019_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn unbond() -> Weight { + (61_257_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Staking Ledger (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: System Account (r:1 w:1) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (52_060_000 as Weight) + // Standard Error: 0 + .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (86_303_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + fn validate() -> Weight { + (35_189_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (15_687_000 as Weight) + (16_161_000 as Weight) // Standard Error: 10_000 - .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking MinNominatorBond (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + fn nominate(n: u32, ) -> Weight { + (41_638_000 as Weight) + // Standard Error: 9_000 + .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + fn chill() -> Weight { + (18_707_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + fn set_payee() -> Weight { + (12_688_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_437_000 as Weight) + (26_726_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_309_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_508_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_483_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_370_000 as Weight) + (2_487_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (51_712_000 as Weight) + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_465_000 as Weight) // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_438_000 as Weight) + (62_075_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_382_921_000 as Weight) - // Standard Error: 222_000 - .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) + (3_403_675_000 as Weight) + // Standard Error: 223_000 + .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Staking Validators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:2) - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (85_987_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Staking Bonded (r:2 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (111_168_000 as Weight) + // Standard Error: 17_000 + .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } // Storage: Staking Ledger (r:2 w:2) // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:2 w:2) // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasRewardPoints (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (154_336_000 as Weight) + (148_375_000 as Weight) // Standard Error: 22_000 - .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Balances Locks (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_596_000 as Weight) - // Standard Error: 1_000 - .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) + (48_669_000 as Weight) + // Standard Error: 2_000 + .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Validators (r:501 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:2) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasValidatorPrefs (r:0 w:2) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) + fn set_history_depth(e: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 70_000 + .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) + } + // Storage: System Account (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) + fn reap_stash(s: u32, ) -> Weight { + (73_475_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().writes(8 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking Nominators (r:101 w:0) + // Storage: Staking Validators (r:2 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Bonded (r:101 w:0) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) + fn new_era(v: u32, n: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 970_000 + .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 48_000 + .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking Bonded (r:1500 w:0) // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking SlashingSpans (r:21 w:0) // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Validators (r:501 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { (0 as Weight) - // Standard Error: 95_000 - .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 95_000 - .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_234_000 - .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) + // Standard Error: 102_000 + .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 102_000 + .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_473_000 + .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking ForceEra (r:0 w:1) - fn force_no_eras() -> Weight { - (2_396_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Invulnerables (r:0 w:1) - fn set_invulnerables(v: u32, ) -> Weight { - (2_389_000 as Weight) - // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (117_261_000 as Weight) - // Standard Error: 15_000 - .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - fn chill() -> Weight { - (18_448_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - } - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:0) - fn set_payee() -> Weight { - (12_210_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - fn nominate(n: u32, ) -> Weight { - (41_518_000 as Weight) - // Standard Error: 11_000 - .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { (0 as Weight) - // Standard Error: 28_000 - .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 29_000 + .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) } - // Storage: Staking ForceEra (r:0 w:1) - fn force_new_era() -> Weight { - (2_332_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:2) - // Storage: Staking ErasValidatorReward (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking ErasValidatorPrefs (r:0 w:2) - // Storage: Staking HistoryDepth (r:1 w:1) - fn set_history_depth(e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 68_000 - .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) - } + // Storage: Staking MaxNominatorsCount (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_limits() -> Weight { - (6_412_000 as Weight) + (6_599_000 as Weight) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - fn bond_extra() -> Weight { - (56_614_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Validators (r:1 w:1) - fn validate() -> Weight { - (34_652_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) + fn chill_other() -> Weight { + (62_743_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: Staking ValidatorCount (r:0 w:1) - fn set_validator_count() -> Weight { - (2_284_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) +} + +// For backwards compatibility and tests +impl WeightInfo for () { + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn bond() -> Weight { + (73_506_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) + fn bond_extra() -> Weight { + (57_019_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) fn unbond() -> Weight { - (60_745_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + (61_257_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking SpanSlash (r:0 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Validators (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) // Storage: System Account (r:1 w:1) - fn reap_stash(s: u32, ) -> Weight { - (72_938_000 as Weight) + fn withdraw_unbonded_update(s: u32, ) -> Weight { + (52_060_000 as Weight) // Standard Error: 0 - .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: System BlockWeight (r:1 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:0 w:1) - // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking CounterForNominators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking Ledger (r:101 w:0) - // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) - fn new_era(v: u32, n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 847_000 - .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 42_000 - .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking Bonded (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) - fn bond() -> Weight { - (73_985_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Storage: Staking SpanSlash (r:0 w:2) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + (86_303_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(8 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Validators (r:1 w:1) // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking MaxValidatorsCount (r:1 w:0) - fn chill_other() -> Weight { - (61_381_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + fn validate() -> Weight { + (35_189_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } -} - -// For backwards compatibility and tests -impl WeightInfo for () { // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn kick(k: u32, ) -> Weight { - (15_687_000 as Weight) + (16_161_000 as Weight) // Standard Error: 10_000 - .saturating_add((16_772_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: Staking MinNominatorBond (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Validators (r:2 w:0) + fn nominate(n: u32, ) -> Weight { + (41_638_000 as Weight) + // Standard Error: 9_000 + .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + fn chill() -> Weight { + (18_707_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + } + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Payee (r:0 w:1) + fn set_payee() -> Weight { + (12_688_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_437_000 as Weight) + (26_726_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: Staking ValidatorCount (r:0 w:1) + fn set_validator_count() -> Weight { + (2_309_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_no_eras() -> Weight { + (2_508_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + // Storage: Staking ForceEra (r:0 w:1) + fn force_new_era() -> Weight { + (2_483_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_370_000 as Weight) + (2_487_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - fn withdraw_unbonded_update(s: u32, ) -> Weight { - (51_712_000 as Weight) + // Storage: Staking Invulnerables (r:0 w:1) + fn set_invulnerables(v: u32, ) -> Weight { + (2_465_000 as Weight) // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (61_438_000 as Weight) + (62_075_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_402_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_382_921_000 as Weight) - // Standard Error: 222_000 - .saturating_add((19_965_000 as Weight).saturating_mul(s as Weight)) + (3_403_675_000 as Weight) + // Standard Error: 223_000 + .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Staking Validators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:2) - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (85_987_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_355_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Staking Bonded (r:2 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:2 w:2) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking Payee (r:2 w:0) + fn payout_stakers_dead_controller(n: u32, ) -> Weight { + (111_168_000 as Weight) + // Standard Error: 17_000 + .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(RocksDbWeight::get().reads(10 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + } // Storage: Staking Ledger (r:2 w:2) // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:2 w:2) // Storage: Staking ErasValidatorPrefs (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasRewardPoints (r:1 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (154_336_000 as Weight) + (148_375_000 as Weight) // Standard Error: 22_000 - .saturating_add((62_041_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } + // Storage: Balances Locks (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_596_000 as Weight) - // Standard Error: 1_000 - .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) + (48_669_000 as Weight) + // Standard Error: 2_000 + .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Validators (r:501 w:0) - // Storage: Staking Ledger (r:1500 w:0) - // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Bonded (r:1500 w:0) - fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 95_000 - .saturating_add((26_312_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 95_000 - .saturating_add((28_536_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_234_000 - .saturating_add((31_154_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Staking ForceEra (r:0 w:1) - fn force_no_eras() -> Weight { - (2_396_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Invulnerables (r:0 w:1) - fn set_invulnerables(v: u32, ) -> Weight { - (2_389_000 as Weight) - // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (117_261_000 as Weight) - // Standard Error: 15_000 - .saturating_add((48_495_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - fn chill() -> Weight { - (18_448_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - } - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Ledger (r:1 w:0) - fn set_payee() -> Weight { - (12_210_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Validators (r:2 w:0) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - fn nominate(n: u32, ) -> Weight { - (41_518_000 as Weight) - // Standard Error: 11_000 - .saturating_add((5_416_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Staking Validators (r:501 w:0) - fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 28_000 - .saturating_add((11_364_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - } - // Storage: Staking ForceEra (r:0 w:1) - fn force_new_era() -> Weight { - (2_332_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:2) - // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasRewardPoints (r:0 w:1) // Storage: Staking ErasValidatorPrefs (r:0 w:2) - // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasTotalStake (r:0 w:1) + // Storage: Staking ErasStakers (r:0 w:2) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 68_000 - .saturating_add((35_020_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 70_000 + .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } - // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) - // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) - fn set_staking_limits() -> Weight { - (6_412_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - fn bond_extra() -> Weight { - (56_614_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) - fn validate() -> Weight { - (34_652_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Staking ValidatorCount (r:0 w:1) - fn set_validator_count() -> Weight { - (2_284_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) - fn unbond() -> Weight { - (60_745_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } - // Storage: Staking SpanSlash (r:0 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Validators (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (72_938_000 as Weight) - // Standard Error: 0 - .saturating_add((2_332_000 as Weight).saturating_mul(s as Weight)) + (73_475_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking ErasStakers (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking Nominators (r:101 w:0) // Storage: Staking Validators (r:2 w:0) - // Storage: Staking ErasValidatorPrefs (r:0 w:1) - // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking ErasStakers (r:0 w:1) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking ErasStakersClipped (r:0 w:1) + // Storage: System BlockWeight (r:1 w:1) + // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking CounterForNominators (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking Ledger (r:101 w:0) // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 847_000 - .saturating_add((302_646_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 42_000 - .saturating_add((47_997_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 970_000 + .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 48_000 + .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - fn bond() -> Weight { - (73_985_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking SlashingSpans (r:21 w:0) + // Storage: Staking Nominators (r:1001 w:0) + // Storage: Staking Validators (r:501 w:0) + fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 102_000 + .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 102_000 + .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_473_000 + .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) + } + // Storage: Staking Validators (r:501 w:0) + fn get_npos_targets(v: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 29_000 + .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } + // Storage: Staking MaxNominatorsCount (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) + // Storage: Staking MaxValidatorsCount (r:0 w:1) + // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking MinNominatorBond (r:0 w:1) + fn set_staking_limits() -> Weight { + (6_599_000 as Weight) + .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) - // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking Validators (r:1 w:1) // Storage: Staking MaxValidatorsCount (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking MinValidatorBond (r:1 w:0) fn chill_other() -> Weight { - (61_381_000 as Weight) + (62_743_000 as Weight) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From 69b56497d6eaed667e241de6ebe1bbd930e12b24 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 21 Jul 2021 21:14:24 -0400 Subject: [PATCH 47/73] steps and repeat to tuple (current_*, total_*) --- frame/benchmarking/src/lib.rs | 29 ++++++++++++--------- frame/benchmarking/src/utils.rs | 19 +++++++++++--- utils/frame/benchmarking-cli/src/command.rs | 3 ++- utils/frame/benchmarking-cli/src/lib.rs | 4 +-- utils/frame/benchmarking-cli/src/writer.rs | 2 +- 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 546c1f07bc41a..d323d1e0b0a64 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -711,7 +711,8 @@ macro_rules! impl_benchmark { extrinsic: &[u8], lowest_range_values: &[u32], highest_range_values: &[u32], - steps: &[u32], + steps: (u32, u32), + repeat: (u32, u32), whitelist: &[$crate::TrackedStorageKey], verify: bool, ) -> Result<$crate::Vec<$crate::BenchmarkResults>, &'static str> { @@ -742,8 +743,6 @@ macro_rules! impl_benchmark { >::components(&selected_benchmark); let mut progress = $crate::benchmarking::current_time(); - // Default number of steps for a component. - let mut prev_steps = 10; let mut do_benchmark = | c: &[($crate::BenchmarkParameter, u32)], @@ -857,11 +856,7 @@ macro_rules! impl_benchmark { // Select the component we will be benchmarking. Each component will be benchmarked. for (idx, (name, low, high)) in components.iter().enumerate() { // Get the number of steps for this component. - let steps = steps.get(idx).cloned().unwrap_or(prev_steps); - prev_steps = steps; - - // Skip this loop if steps is zero - if steps == 0 { continue } + let (_current_step, total_steps) = steps; let lowest = lowest_range_values.get(idx).cloned().unwrap_or(*low); let highest = highest_range_values.get(idx).cloned().unwrap_or(*high); @@ -869,7 +864,7 @@ macro_rules! impl_benchmark { let diff = highest - lowest; // Create up to `STEPS` steps for that component between high and low. - let step_size = (diff / steps).max(1); + let step_size = (diff / total_steps).max(1); let num_of_steps = diff / step_size + 1; for s in 0..num_of_steps { @@ -1243,7 +1238,8 @@ pub fn show_benchmark_debug_info( benchmark: &[u8], lowest_range_values: &sp_std::prelude::Vec, highest_range_values: &sp_std::prelude::Vec, - steps: &sp_std::prelude::Vec, + steps: &(u32, u32), + repeat: &(u32, u32), verify: &bool, error_message: &str, ) -> sp_runtime::RuntimeString { @@ -1253,6 +1249,7 @@ pub fn show_benchmark_debug_info( * Lowest_range_values: {:?}\n\ * Highest_range_values: {:?}\n\ * Steps: {:?}\n\ + * Repeat: {:?}\n\ * Verify: {:?}\n\ * Error message: {}", sp_std::str::from_utf8(instance_string) @@ -1261,7 +1258,8 @@ pub fn show_benchmark_debug_info( .expect("it's all just strings ran through the wasm interface. qed"), lowest_range_values, highest_range_values, - steps, + steps.1, + repeat.1, verify, error_message, ) @@ -1342,6 +1340,7 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, + repeat, verify, extra, } = config; @@ -1356,7 +1355,8 @@ macro_rules! add_benchmark { benchmark, &lowest_range_values[..], &highest_range_values[..], - &steps[..], + *steps, + *repeat, whitelist, *verify, ).map_err(|e| { @@ -1366,6 +1366,7 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, + repeat, verify, e, ) @@ -1381,7 +1382,8 @@ macro_rules! add_benchmark { &benchmark[..], &lowest_range_values[..], &highest_range_values[..], - &steps[..], + *steps, + *repeat, whitelist, *verify, ).map_err(|e| { @@ -1391,6 +1393,7 @@ macro_rules! add_benchmark { lowest_range_values, highest_range_values, steps, + repeat, verify, e, ) diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index a641bd6b666d6..02c23a2dd346a 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -103,8 +103,10 @@ pub struct BenchmarkConfig { pub lowest_range_values: Vec, /// An optional manual override to the highest values used in the `steps` range. pub highest_range_values: Vec, - /// The number of samples to take across the range of values for components. - pub steps: Vec, + /// The number of samples to take across the range of values for components. (current_step, total_steps) + pub steps: (u32, u32), + /// The number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeat) + pub repeat: (u32, u32), /// Enable an extra benchmark iteration which runs the verification logic for a benchmark. pub verify: bool, /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a pallet. @@ -114,6 +116,13 @@ pub struct BenchmarkConfig { sp_api::decl_runtime_apis! { /// Runtime api for benchmarking a FRAME runtime. pub trait Benchmark { + /// Get the benchmarks available for this runtime. + /// + /// Parameters + /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be + /// needed for weight calculation. + //fn benchmarks(extra: bool) -> Vec<(&'static [u8], Vec<&'static [u8])>; + /// Dispatch the given benchmark. fn dispatch_benchmark(config: BenchmarkConfig) -> Result<(Vec, Vec), sp_runtime::RuntimeString>; @@ -214,14 +223,16 @@ pub trait Benchmarking { /// Parameters /// - `name`: The name of extrinsic function or benchmark you want to benchmark encoded as /// bytes. - /// - `steps`: The number of sample points you want to take across the range of parameters. /// - `lowest_range_values`: The lowest number for each range of parameters. /// - `highest_range_values`: The highest number for each range of parameters. + /// - `steps`: The number of sample points you want to take across the range of parameters. (current_step, total_steps) + /// - `repeat`: The total number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeats) fn run_benchmark( name: &[u8], lowest_range_values: &[u32], highest_range_values: &[u32], - steps: &[u32], + steps: (u32, u32), + repeat: (u32, u32), whitelist: &[TrackedStorageKey], verify: bool, ) -> Result, &'static str>; diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index b2b37227bc752..ddec0b65045ba 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -134,7 +134,8 @@ impl BenchmarkCmd { &self.extrinsic, self.lowest_range_values.clone(), self.highest_range_values.clone(), - self.steps.clone(), + (self.steps, self.steps), + (r, self.repeat), !self.no_verify, self.extra, ) diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index 0642ddabc1374..e5cf568c5d179 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -39,8 +39,8 @@ pub struct BenchmarkCmd { pub extrinsic: String, /// Select how many samples we should take across the variable components. - #[structopt(short, long, use_delimiter = true)] - pub steps: Vec, + #[structopt(short, long, default_value = "1")] + pub steps: u32, /// Indicates lowest values for each of the component ranges. #[structopt(long = "low", use_delimiter = true)] diff --git a/utils/frame/benchmarking-cli/src/writer.rs b/utils/frame/benchmarking-cli/src/writer.rs index 16c93081ac6e1..d80a17e1b2dba 100644 --- a/utils/frame/benchmarking-cli/src/writer.rs +++ b/utils/frame/benchmarking-cli/src/writer.rs @@ -71,7 +71,7 @@ struct BenchmarkData { // This forwards some specific metadata from the `BenchmarkCmd` #[derive(Serialize, Default, Debug, Clone)] struct CmdData { - steps: Vec, + steps: u32, repeat: u32, lowest_range_values: Vec, highest_range_values: Vec, From bf949d028ede5bebc51297521aa80b14749f7283 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 21 Jul 2021 23:41:21 -0400 Subject: [PATCH 48/73] idea for list command --- bin/node/runtime/src/lib.rs | 15 ++++++ frame/benchmarking/src/utils.rs | 8 ++- utils/frame/benchmarking-cli/src/command.rs | 59 +++++++++++++++++++++ utils/frame/benchmarking-cli/src/lib.rs | 4 ++ 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 90bd11d484b26..d7b1bdce8ff01 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1534,6 +1534,21 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { + fn benchmarks(extra: bool) -> Vec { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + + let benchmarks = Assets::benchmarks(extra) + .iter() + .map(|b| b.to_vec()) + .collect::>(); + let list = BenchmarkList { + pallet: b"Balances".to_vec(), + benchmarks: benchmarks.to_vec(), + }; + + return vec![list] + } + fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result< diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 02c23a2dd346a..b13a7477632cc 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -113,6 +113,12 @@ pub struct BenchmarkConfig { pub extra: bool, } +#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] +pub struct BenchmarkList { + pub pallet: Vec, + pub benchmarks: Vec>, +} + sp_api::decl_runtime_apis! { /// Runtime api for benchmarking a FRAME runtime. pub trait Benchmark { @@ -121,7 +127,7 @@ sp_api::decl_runtime_apis! { /// Parameters /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be /// needed for weight calculation. - //fn benchmarks(extra: bool) -> Vec<(&'static [u8], Vec<&'static [u8])>; + fn benchmarks(extra: bool) -> Vec; /// Dispatch the given benchmark. fn dispatch_benchmark(config: BenchmarkConfig) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index ddec0b65045ba..030ef83021058 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -79,6 +79,7 @@ impl BenchmarkCmd { ::Hash: std::str::FromStr, ExecDispatch: NativeExecutionDispatch + 'static, { + if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { return Err("Output file or path is invalid!".into()) @@ -123,6 +124,34 @@ impl BenchmarkCmd { extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); + if self.list { + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_benchmarks", + &(self.extra).encode(), + extensions, + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), + ) + .execute(strategy.into()) + .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; + + let lists = as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + + for list in lists { + println!("{}", String::from_utf8(list.pallet).unwrap()); + for benchmark in list.benchmarks { + println!("- {}", String::from_utf8(benchmark).unwrap()); + } + } + + return Ok(()) + } + let result = StateMachine::<_, _, NumberFor, _>::new( &state, None, @@ -268,3 +297,33 @@ impl CliConfiguration for BenchmarkCmd { }) } } + +// fn list(extra: bool) -> Result<()> +// where +// BB: BlockT + Debug, +// <<::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug, +// ::Hash: std::str::FromStr, +// { +// let result = StateMachine::<_, _, NumberFor, _>::new( +// &state, +// None, +// &mut changes, +// &executor, +// "Benchmark_benchmarks", +// &(extra).encode(), +// extensions, +// &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, +// sp_core::testing::TaskExecutor::new(), +// ) +// .execute(strategy.into()) +// .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; + +// let list = , +// String, +// > as Decode>::decode(&mut &result[..]) +// .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))??; + +// println!("{:?}", list); +// Ok(()) +// } diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index e5cf568c5d179..d66e59bde0cbd 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -129,4 +129,8 @@ pub struct BenchmarkCmd { /// Limit the memory the database cache can use. #[structopt(long = "db-cache", value_name = "MiB", default_value = "128")] pub database_cache_size: u32, + + /// List the benchmarks available + #[structopt(long)] + pub list: bool, } From 19553a7ae95a99f5c4fdf44d9f4fa577b84091e7 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 29 Jul 2021 22:17:07 +0200 Subject: [PATCH 49/73] fmt --- utils/frame/benchmarking-cli/src/command.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 030ef83021058..15808c282f23d 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -79,7 +79,6 @@ impl BenchmarkCmd { ::Hash: std::str::FromStr, ExecDispatch: NativeExecutionDispatch + 'static, { - if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { return Err("Output file or path is invalid!".into()) @@ -139,8 +138,9 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let lists = as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + let lists = + as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; for list in lists { println!("{}", String::from_utf8(list.pallet).unwrap()); From bea002961e24d76698703bea2466e82f1a94aa62 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 12:22:58 +0200 Subject: [PATCH 50/73] use benchmark list in cli --- bin/node/runtime/src/lib.rs | 64 ++++++-- frame/benchmarking/src/lib.rs | 100 ++++++------ frame/benchmarking/src/utils.rs | 1 + utils/frame/benchmarking-cli/src/command.rs | 163 +++++++++----------- 4 files changed, 168 insertions(+), 160 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d7b1bdce8ff01..419178d9500eb 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1535,18 +1535,54 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmarks(extra: bool) -> Vec { - use frame_benchmarking::{Benchmarking, BenchmarkList}; - - let benchmarks = Assets::benchmarks(extra) - .iter() - .map(|b| b.to_vec()) - .collect::>(); - let list = BenchmarkList { - pallet: b"Balances".to_vec(), - benchmarks: benchmarks.to_vec(), - }; - - return vec![list] + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + + // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency + // issues. To get around that, we separated the Session benchmarks into its own crate, + // which is why we need these two lines below. + use pallet_session_benchmarking::Pallet as SessionBench; + use pallet_offences_benchmarking::Pallet as OffencesBench; + use frame_system_benchmarking::Pallet as SystemBench; + + impl pallet_session_benchmarking::Config for Runtime {} + impl pallet_offences_benchmarking::Config for Runtime {} + impl frame_system_benchmarking::Config for Runtime {} + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, pallet_assets, Assets); + list_benchmark!(list, extra, pallet_babe, Babe); + list_benchmark!(list, extra, pallet_balances, Balances); + list_benchmark!(list, extra, pallet_bounties, Bounties); + list_benchmark!(list, extra, pallet_collective, Council); + list_benchmark!(list, extra, pallet_contracts, Contracts); + list_benchmark!(list, extra, pallet_democracy, Democracy); + list_benchmark!(list, extra, pallet_election_provider_multi_phase, ElectionProviderMultiPhase); + list_benchmark!(list, extra, pallet_elections_phragmen, Elections); + list_benchmark!(list, extra, pallet_gilt, Gilt); + list_benchmark!(list, extra, pallet_grandpa, Grandpa); + list_benchmark!(list, extra, pallet_identity, Identity); + list_benchmark!(list, extra, pallet_im_online, ImOnline); + list_benchmark!(list, extra, pallet_indices, Indices); + list_benchmark!(list, extra, pallet_lottery, Lottery); + list_benchmark!(list, extra, pallet_membership, TechnicalMembership); + list_benchmark!(list, extra, pallet_mmr, Mmr); + list_benchmark!(list, extra, pallet_multisig, Multisig); + list_benchmark!(list, extra, pallet_offences, OffencesBench::); + list_benchmark!(list, extra, pallet_proxy, Proxy); + list_benchmark!(list, extra, pallet_scheduler, Scheduler); + list_benchmark!(list, extra, pallet_session, SessionBench::); + list_benchmark!(list, extra, pallet_staking, Staking); + list_benchmark!(list, extra, frame_system, SystemBench::); + list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_tips, Tips); + list_benchmark!(list, extra, pallet_transaction_storage, TransactionStorage); + list_benchmark!(list, extra, pallet_treasury, Treasury); + list_benchmark!(list, extra, pallet_uniques, Uniques); + list_benchmark!(list, extra, pallet_utility, Utility); + list_benchmark!(list, extra, pallet_vesting, Vesting); + + return list } fn dispatch_benchmark( @@ -1565,10 +1601,6 @@ impl_runtime_apis! { use pallet_offences_benchmarking::Pallet as OffencesBench; use frame_system_benchmarking::Pallet as SystemBench; - impl pallet_session_benchmarking::Config for Runtime {} - impl pallet_offences_benchmarking::Config for Runtime {} - impl frame_system_benchmarking::Config for Runtime {} - let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index d323d1e0b0a64..f6952c5a4beb2 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -1344,62 +1344,50 @@ macro_rules! add_benchmark { verify, extra, } = config; - if &pallet[..] == &name_string[..] || &pallet[..] == &b"*"[..] { - if &pallet[..] == &b"*"[..] || &benchmark[..] == &b"*"[..] { - for benchmark in $( $location )*::benchmarks(*extra).into_iter() { - $batches.push($crate::BenchmarkBatch { - pallet: name_string.to_vec(), - instance: instance_string.to_vec(), - benchmark: benchmark.to_vec(), - results: $( $location )*::run_benchmark( - benchmark, - &lowest_range_values[..], - &highest_range_values[..], - *steps, - *repeat, - whitelist, - *verify, - ).map_err(|e| { - $crate::show_benchmark_debug_info( - instance_string, - benchmark, - lowest_range_values, - highest_range_values, - steps, - repeat, - verify, - e, - ) - })?, - }); - } - } else { - $batches.push($crate::BenchmarkBatch { - pallet: name_string.to_vec(), - instance: instance_string.to_vec(), - benchmark: benchmark.clone(), - results: $( $location )*::run_benchmark( - &benchmark[..], - &lowest_range_values[..], - &highest_range_values[..], - *steps, - *repeat, - whitelist, - *verify, - ).map_err(|e| { - $crate::show_benchmark_debug_info( - instance_string, - benchmark, - lowest_range_values, - highest_range_values, - steps, - repeat, - verify, - e, - ) - })?, - }); - } + if &pallet[..] == &name_string[..] { + $batches.push($crate::BenchmarkBatch { + pallet: name_string.to_vec(), + instance: instance_string.to_vec(), + benchmark: benchmark.clone(), + results: $( $location )*::run_benchmark( + &benchmark[..], + &lowest_range_values[..], + &highest_range_values[..], + *steps, + *repeat, + whitelist, + *verify, + ).map_err(|e| { + $crate::show_benchmark_debug_info( + instance_string, + benchmark, + lowest_range_values, + highest_range_values, + steps, + repeat, + verify, + e, + ) + })? + }); } ) } + +#[macro_export] +macro_rules! list_benchmark { + ( $list:ident, $extra:ident, $name:path, $( $location:tt )* ) => ( + let pallet_string = stringify!($name).as_bytes(); + let instance_string = stringify!( $( $location )* ).as_bytes(); + let benchmarks = $( $location )*::benchmarks($extra) + .iter() + .map(|b| b.to_vec()) + .collect::>(); + let pallet_benchmarks = BenchmarkList { + pallet: pallet_string.to_vec(), + instance: instance_string.to_vec(), + benchmarks: benchmarks.to_vec(), + }; + $list.push(pallet_benchmarks) + ) +} diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index b13a7477632cc..87e5e024cf21d 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -116,6 +116,7 @@ pub struct BenchmarkConfig { #[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] pub struct BenchmarkList { pub pallet: Vec, + pub instance: Vec, pub benchmarks: Vec>, } diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 15808c282f23d..531e377db191e 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -100,6 +100,8 @@ impl BenchmarkCmd { let spec = config.chain_spec; let wasm_method = self.wasm_method.into(); let strategy = self.execution.unwrap_or(ExecutionStrategy::Native); + let pallet = self.pallet.as_bytes(); + let extrinsic = self.extrinsic.as_bytes(); let genesis_storage = spec.build_storage()?; let mut changes = Default::default(); @@ -114,7 +116,7 @@ impl BenchmarkCmd { let mut batches = Vec::new(); let mut storage_info = Vec::new(); - for r in 0..self.repeat { + let extensions = || -> Extensions { let mut extensions = Extensions::default(); extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); let (offchain, _) = TestOffchainExt::new(); @@ -122,80 +124,95 @@ impl BenchmarkCmd { extensions.register(OffchainWorkerExt::new(offchain.clone())); extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); + return extensions + }; + + // Get Benchmark List + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_benchmarks", + &(self.extra).encode(), + extensions(), + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), + ) + .execute(strategy.into()) + .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; + + let list = + as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + + if self.list { + // Show the list and exit early + for item in list { + println!("{}", String::from_utf8(item.pallet).unwrap()); + for benchmark in item.benchmarks { + println!("- {}", String::from_utf8(benchmark).unwrap()); + } + } + return Ok(()) + } - if self.list { + // Use the benchmark list and the user input to determine the set of benchmarks to run. + let mut benchmarks_to_run = Vec::new(); + for item in list { + if pallet == &item.pallet[..] || pallet == &b"*"[..] { + if &pallet[..] == &b"*"[..] || &extrinsic[..] == &b"*"[..] { + for benchmark in item.benchmarks { + benchmarks_to_run.push((item.pallet.clone(), benchmark)); + } + } else { + benchmarks_to_run.push((pallet.to_vec(), extrinsic.to_vec())); + } + } + } + + // Run the benchmarks + for (pallet, extrinsic) in benchmarks_to_run { + for r in 0..self.repeat { let result = StateMachine::<_, _, NumberFor, _>::new( &state, None, &mut changes, &executor, - "Benchmark_benchmarks", - &(self.extra).encode(), - extensions, + "Benchmark_dispatch_benchmark", + &( + &pallet, + &extrinsic, + self.lowest_range_values.clone(), + self.highest_range_values.clone(), + (self.steps, self.steps), + (r, self.repeat), + !self.no_verify, + self.extra, + ) + .encode(), + extensions(), &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, sp_core::testing::TaskExecutor::new(), ) .execute(strategy.into()) - .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - - let lists = - as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - for list in lists { - println!("{}", String::from_utf8(list.pallet).unwrap()); - for benchmark in list.benchmarks { - println!("- {}", String::from_utf8(benchmark).unwrap()); - } - } + let (batch, last_storage_info) = , Vec), + String, + > as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; - return Ok(()) + batches.extend(batch); + storage_info = last_storage_info; } - - let result = StateMachine::<_, _, NumberFor, _>::new( - &state, - None, - &mut changes, - &executor, - "Benchmark_dispatch_benchmark", - &( - &self.pallet, - &self.extrinsic, - self.lowest_range_values.clone(), - self.highest_range_values.clone(), - (self.steps, self.steps), - (r, self.repeat), - !self.no_verify, - self.extra, - ) - .encode(), - extensions, - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, - sp_core::testing::TaskExecutor::new(), - ) - .execute(strategy.into()) - .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - - let (batch, last_storage_info) = , Vec), - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; - - batches.extend(batch); - storage_info = last_storage_info; } + // Combine all of the benchmark results, so that benchmarks of the same pallet/function + // are together. let batches = combine_batches(batches); - for b in batches.clone() { - println!( - "{:?}: {:?}", - String::from_utf8(b.pallet).unwrap(), - String::from_utf8(b.benchmark).unwrap(), - ); - } - if let Some(output_path) = &self.output { crate::writer::write_results(&batches, &storage_info, output_path, self)?; } @@ -297,33 +314,3 @@ impl CliConfiguration for BenchmarkCmd { }) } } - -// fn list(extra: bool) -> Result<()> -// where -// BB: BlockT + Debug, -// <<::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug, -// ::Hash: std::str::FromStr, -// { -// let result = StateMachine::<_, _, NumberFor, _>::new( -// &state, -// None, -// &mut changes, -// &executor, -// "Benchmark_benchmarks", -// &(extra).encode(), -// extensions, -// &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, -// sp_core::testing::TaskExecutor::new(), -// ) -// .execute(strategy.into()) -// .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - -// let list = , -// String, -// > as Decode>::decode(&mut &result[..]) -// .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))??; - -// println!("{:?}", list); -// Ok(()) -// } From 80d5ab3e6e85d8ed2b818ab00cd3bb16332d5125 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 13:15:02 +0200 Subject: [PATCH 51/73] handle steps in cli --- frame/benchmarking/src/lib.rs | 58 ++++++++++-------- utils/frame/benchmarking-cli/src/command.rs | 68 +++++++++++---------- 2 files changed, 68 insertions(+), 58 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index f6952c5a4beb2..576683ca1b9a0 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -846,17 +846,20 @@ macro_rules! impl_benchmark { Ok(()) }; + let (current_step, total_steps) = steps; + if components.is_empty() { - if verify { - // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + // The CLI could ask to do more steps than is sensible, so we skip those. + if current_step == 0 { + if verify { + // If `--verify` is used, run the benchmark once to verify it would complete. + do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + } + do_benchmark(Default::default(), &mut results, false, 1, 1)?; } - do_benchmark(Default::default(), &mut results, false, 1, 1)?; } else { // Select the component we will be benchmarking. Each component will be benchmarked. for (idx, (name, low, high)) in components.iter().enumerate() { - // Get the number of steps for this component. - let (_current_step, total_steps) = steps; let lowest = lowest_range_values.get(idx).cloned().unwrap_or(*low); let highest = highest_range_values.get(idx).cloned().unwrap_or(*high); @@ -867,28 +870,31 @@ macro_rules! impl_benchmark { let step_size = (diff / total_steps).max(1); let num_of_steps = diff / step_size + 1; - for s in 0..num_of_steps { - // This is the value we will be testing for component `name` - let component_value = lowest + step_size * s; - - // Select the max value for all the other components. - let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components.iter() - .enumerate() - .map(|(idx, (n, _, h))| - if n == name { - (*n, component_value) - } else { - (*n, *highest_range_values.get(idx).unwrap_or(h)) - } - ) - .collect(); + // The CLI could ask to do more steps than is sensible, so we just skip those. + if current_step >= num_of_steps { + continue; + } - if verify { - // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(&c, &mut $crate::Vec::new(), true, s, num_of_steps)?; - } - do_benchmark(&c, &mut results, false, s, num_of_steps)?; + // This is the value we will be testing for component `name` + let component_value = lowest + step_size * current_step; + + // Select the max value for all the other components. + let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components.iter() + .enumerate() + .map(|(idx, (n, _, h))| + if n == name { + (*n, component_value) + } else { + (*n, *highest_range_values.get(idx).unwrap_or(h)) + } + ) + .collect(); + + if verify { + // If `--verify` is used, run the benchmark once to verify it would complete. + do_benchmark(&c, &mut $crate::Vec::new(), true, current_step, num_of_steps)?; } + do_benchmark(&c, &mut results, false, current_step, num_of_steps)?; } } return Ok(results); diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 531e377db191e..7bf3e7c903ece 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -173,39 +173,43 @@ impl BenchmarkCmd { // Run the benchmarks for (pallet, extrinsic) in benchmarks_to_run { - for r in 0..self.repeat { - let result = StateMachine::<_, _, NumberFor, _>::new( - &state, - None, - &mut changes, - &executor, - "Benchmark_dispatch_benchmark", - &( - &pallet, - &extrinsic, - self.lowest_range_values.clone(), - self.highest_range_values.clone(), - (self.steps, self.steps), - (r, self.repeat), - !self.no_verify, - self.extra, + for s in 0..self.steps { + for r in 0..self.repeat { + // This should run only a single instance of a benchmark for `pallet` and + // `extrinsic`. All loops happen above. + let result = StateMachine::<_, _, NumberFor, _>::new( + &state, + None, + &mut changes, + &executor, + "Benchmark_dispatch_benchmark", + &( + &pallet, + &extrinsic, + self.lowest_range_values.clone(), + self.highest_range_values.clone(), + (s, self.steps), + (r, self.repeat), + !self.no_verify, + self.extra, + ) + .encode(), + extensions(), + &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + sp_core::testing::TaskExecutor::new(), ) - .encode(), - extensions(), - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, - sp_core::testing::TaskExecutor::new(), - ) - .execute(strategy.into()) - .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - - let (batch, last_storage_info) = , Vec), - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; - - batches.extend(batch); - storage_info = last_storage_info; + .execute(strategy.into()) + .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; + + let (batch, last_storage_info) = , Vec), + String, + > as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; + + batches.extend(batch); + storage_info = last_storage_info; + } } } From 6f06056c8466edd5f953a46e3f3df0d1606408ce Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 18:05:48 +0200 Subject: [PATCH 52/73] move log update to cli --- Cargo.lock | 1 + frame/benchmarking/src/lib.rs | 22 +++------------ utils/frame/benchmarking-cli/Cargo.toml | 1 + utils/frame/benchmarking-cli/src/command.rs | 31 +++++++++++++++++---- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f3420f2bea71..3d22e0c0b6bd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1801,6 +1801,7 @@ dependencies = [ "frame-support", "handlebars", "linked-hash-map", + "log", "parity-scale-codec", "sc-cli", "sc-client-db", diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 576683ca1b9a0..d43748bdc842a 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -748,8 +748,6 @@ macro_rules! impl_benchmark { c: &[($crate::BenchmarkParameter, u32)], results: &mut $crate::Vec<$crate::BenchmarkResults>, verify: bool, - step: u32, - num_steps: u32, | -> Result<(), &'static str> { // Set up the externalities environment for the setup we want to // benchmark. @@ -805,18 +803,6 @@ macro_rules! impl_benchmark { "Read/Write Count {:?}", read_write_count ); - let time = $crate::benchmarking::current_time(); - if time.saturating_sub(progress) > 5000000000 { - progress = $crate::benchmarking::current_time(); - $crate::log::info!( - target: "benchmark", - "Benchmarking {} {}/{}", - extrinsic, - step, - num_steps, - ); - } - // Time the storage root recalculation. let start_storage_root = $crate::benchmarking::current_time(); $crate::storage_root(); @@ -853,9 +839,9 @@ macro_rules! impl_benchmark { if current_step == 0 { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?; + do_benchmark(Default::default(), &mut $crate::Vec::new(), true)?; } - do_benchmark(Default::default(), &mut results, false, 1, 1)?; + do_benchmark(Default::default(), &mut results, false)?; } } else { // Select the component we will be benchmarking. Each component will be benchmarked. @@ -892,9 +878,9 @@ macro_rules! impl_benchmark { if verify { // If `--verify` is used, run the benchmark once to verify it would complete. - do_benchmark(&c, &mut $crate::Vec::new(), true, current_step, num_of_steps)?; + do_benchmark(&c, &mut $crate::Vec::new(), true)?; } - do_benchmark(&c, &mut results, false, current_step, num_of_steps)?; + do_benchmark(&c, &mut results, false)?; } } return Ok(results); diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index e9445b03971f8..93616b590f61e 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -31,6 +31,7 @@ serde = "1.0.126" handlebars = "3.5.0" Inflector = "0.11.4" linked-hash-map = "0.5.4" +log = "0.4.8" [features] default = ["db"] diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 7bf3e7c903ece..a14939b716b18 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -142,9 +142,8 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let list = - as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + let list = as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; if self.list { // Show the list and exit early @@ -172,6 +171,7 @@ impl BenchmarkCmd { } // Run the benchmarks + let mut timer = time::SystemTime::now(); for (pallet, extrinsic) in benchmarks_to_run { for s in 0..self.steps { for r in 0..self.repeat { @@ -184,8 +184,8 @@ impl BenchmarkCmd { &executor, "Benchmark_dispatch_benchmark", &( - &pallet, - &extrinsic, + &pallet.clone(), + &extrinsic.clone(), self.lowest_range_values.clone(), self.highest_range_values.clone(), (s, self.steps), @@ -195,7 +195,8 @@ impl BenchmarkCmd { ) .encode(), extensions(), - &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, + &sp_state_machine::backend::BackendRuntimeCode::new(&state) + .runtime_code()?, sp_core::testing::TaskExecutor::new(), ) .execute(strategy.into()) @@ -209,6 +210,24 @@ impl BenchmarkCmd { batches.extend(batch); storage_info = last_storage_info; + + // Show progress information + if let Some(elapsed) = timer.elapsed().ok() { + if elapsed >= time::Duration::from_secs(5) { + timer = time::SystemTime::now(); + log::info!( + "Running Benchmark:\t{}\t{}\t{}/{}\t{}/{}", + String::from_utf8(pallet.clone()) + .expect("Encoded from String; qed"), + String::from_utf8(extrinsic.clone()) + .expect("Encoded from String; qed"), + s, + self.steps, + r, + self.repeat, + ); + } + } } } } From 7f88e7f7e6885fa7a14466fd59c3a8a9bdfc9455 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 18:32:14 +0200 Subject: [PATCH 53/73] remove old todo --- frame/benchmarking/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index d43748bdc842a..d5bd859ed2df5 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -809,9 +809,7 @@ macro_rules! impl_benchmark { let finish_storage_root = $crate::benchmarking::current_time(); let elapsed_storage_root = finish_storage_root - start_storage_root; - // TODO: Fix memory allocation issue then re-enable let read_and_written_keys = $crate::benchmarking::get_read_and_written_keys(); - //let read_and_written_keys = Default::default(); results.push($crate::BenchmarkResults { components: c.to_vec(), From cc4479a2b044a5248cb28dc45818e7385586991f Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 18:36:39 +0200 Subject: [PATCH 54/73] line width --- frame/benchmarking/src/utils.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 87e5e024cf21d..db9dc7af2b81d 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -232,8 +232,10 @@ pub trait Benchmarking { /// bytes. /// - `lowest_range_values`: The lowest number for each range of parameters. /// - `highest_range_values`: The highest number for each range of parameters. - /// - `steps`: The number of sample points you want to take across the range of parameters. (current_step, total_steps) - /// - `repeat`: The total number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeats) + /// - `steps`: The number of sample points you want to take across the range of parameters. + /// (current_step, total_steps) + /// - `repeat`: The total number times to repeat each benchmark to increase accuracy of results. + /// (current_repeat, total_repeats) fn run_benchmark( name: &[u8], lowest_range_values: &[u32], From 83e5a491cebcc5e66884cf8b120ac730845b650c Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Fri, 30 Jul 2021 16:48:16 +0000 Subject: [PATCH 55/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index aa5bc697a42dd..bc69d0128ca95 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -58,37 +58,37 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_138_000 as Weight) + (78_536_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (57_454_000 as Weight) + (58_474_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (31_664_000 as Weight) + (33_002_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_901_000 as Weight) + (39_321_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (76_515_000 as Weight) + (77_973_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_007_000 as Weight) + (71_563_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -98,37 +98,37 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_138_000 as Weight) + (78_536_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (57_454_000 as Weight) + (58_474_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (31_664_000 as Weight) + (33_002_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (37_901_000 as Weight) + (39_321_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (76_515_000 as Weight) + (77_973_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_007_000 as Weight) + (71_563_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From 33a8243504e7092cc9647b8d146a58b76f13d486 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 19:06:39 +0200 Subject: [PATCH 56/73] benchmark metadata function --- bin/node/runtime/src/lib.rs | 25 +++++++++------------ frame/benchmarking/src/utils.rs | 5 ++--- utils/frame/benchmarking-cli/src/command.rs | 17 ++++++-------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 419178d9500eb..aa4d62a9ae086 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1534,8 +1534,9 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { - fn benchmarks(extra: bool) -> Vec { + fn benchmark_metadata(extra: bool) -> (Vec, Vec) { use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency // issues. To get around that, we separated the Session benchmarks into its own crate, @@ -1544,10 +1545,6 @@ impl_runtime_apis! { use pallet_offences_benchmarking::Pallet as OffencesBench; use frame_system_benchmarking::Pallet as SystemBench; - impl pallet_session_benchmarking::Config for Runtime {} - impl pallet_offences_benchmarking::Config for Runtime {} - impl frame_system_benchmarking::Config for Runtime {} - let mut list = Vec::::new(); list_benchmark!(list, extra, pallet_assets, Assets); @@ -1582,17 +1579,15 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); - return list + let storage_info = AllPalletsWithSystem::storage_info(); + + return (list, storage_info) } fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig - ) -> Result< - (Vec, Vec), - sp_runtime::RuntimeString, - > { + ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; - use frame_support::traits::StorageInfoTrait; // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency // issues. To get around that, we separated the Session benchmarks into its own crate, @@ -1601,6 +1596,10 @@ impl_runtime_apis! { use pallet_offences_benchmarking::Pallet as OffencesBench; use frame_system_benchmarking::Pallet as SystemBench; + impl pallet_session_benchmarking::Config for Runtime {} + impl pallet_offences_benchmarking::Config for Runtime {} + impl frame_system_benchmarking::Config for Runtime {} + let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), @@ -1616,8 +1615,6 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(), ]; - let storage_info = AllPalletsWithSystem::storage_info(); - let mut batches = Vec::::new(); let params = (&config, &whitelist); @@ -1654,7 +1651,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_vesting, Vesting); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok((batches, storage_info)) + Ok(batches) } } } diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index db9dc7af2b81d..440845929fb85 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -128,11 +128,10 @@ sp_api::decl_runtime_apis! { /// Parameters /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be /// needed for weight calculation. - fn benchmarks(extra: bool) -> Vec; + fn benchmark_metadata(extra: bool) -> (Vec, Vec); /// Dispatch the given benchmark. - fn dispatch_benchmark(config: BenchmarkConfig) - -> Result<(Vec, Vec), sp_runtime::RuntimeString>; + fn dispatch_benchmark(config: BenchmarkConfig) -> Result, sp_runtime::RuntimeString>; } } diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index a14939b716b18..151e889a59871 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -17,7 +17,7 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; -use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector}; +use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector, BenchmarkList}; use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; @@ -113,9 +113,6 @@ impl BenchmarkCmd { 2, // The runtime instances cache size. ); - let mut batches = Vec::new(); - let mut storage_info = Vec::new(); - let extensions = || -> Extensions { let mut extensions = Extensions::default(); extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr)); @@ -133,7 +130,7 @@ impl BenchmarkCmd { None, &mut changes, &executor, - "Benchmark_benchmarks", + "Benchmark_benchmark_metadata", &(self.extra).encode(), extensions(), &sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?, @@ -142,8 +139,8 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let list = as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark list: {:?}", e))?; + let (list, storage_info) = <(Vec, Vec) as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; if self.list { // Show the list and exit early @@ -171,6 +168,7 @@ impl BenchmarkCmd { } // Run the benchmarks + let mut batches = Vec::new(); let mut timer = time::SystemTime::now(); for (pallet, extrinsic) in benchmarks_to_run { for s in 0..self.steps { @@ -202,14 +200,13 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - let (batch, last_storage_info) = , Vec), + let batch = , String, > as Decode>::decode(&mut &result[..]) .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; batches.extend(batch); - storage_info = last_storage_info; // Show progress information if let Some(elapsed) = timer.elapsed().ok() { From a366ed2a60403249fb8d3932ed25c27e182f6c4e Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 19:18:38 +0200 Subject: [PATCH 57/73] don't need this warm up --- frame/benchmarking/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index d5bd859ed2df5..f6e8b31bf712a 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -734,10 +734,6 @@ macro_rules! impl_benchmark { whitelist.push(whitelisted_caller_key.into()); $crate::benchmarking::set_whitelist(whitelist); - // Warm up the DB - $crate::benchmarking::commit_db(); - $crate::benchmarking::wipe_db(); - let components = < SelectedBenchmark as $crate::BenchmarkingSetup >::components(&selected_benchmark); From 60cdd0642f2ca63eba0994298eda270f271db14e Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Fri, 30 Jul 2021 17:25:35 +0000 Subject: [PATCH 58/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/balances/src/weights.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index bc69d0128ca95..df609b74840d2 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -58,37 +58,37 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_536_000 as Weight) + (78_358_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (58_474_000 as Weight) + (59_001_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (33_002_000 as Weight) + (32_698_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (39_321_000 as Weight) + (38_746_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (77_973_000 as Weight) + (77_622_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_563_000 as Weight) + (72_020_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -98,37 +98,37 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (78_536_000 as Weight) + (78_358_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (58_474_000 as Weight) + (59_001_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (33_002_000 as Weight) + (32_698_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (39_321_000 as Weight) + (38_746_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (77_973_000 as Weight) + (77_622_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (71_563_000 as Weight) + (72_020_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } From a2c2dbd0a569c9330f8860841b6ae6cf88c248f3 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 19:41:09 +0200 Subject: [PATCH 59/73] fix warnings --- frame/benchmarking/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index f6e8b31bf712a..bba558d241523 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -712,7 +712,7 @@ macro_rules! impl_benchmark { lowest_range_values: &[u32], highest_range_values: &[u32], steps: (u32, u32), - repeat: (u32, u32), + _repeat: (u32, u32), whitelist: &[$crate::TrackedStorageKey], verify: bool, ) -> Result<$crate::Vec<$crate::BenchmarkResults>, &'static str> { @@ -738,9 +738,7 @@ macro_rules! impl_benchmark { SelectedBenchmark as $crate::BenchmarkingSetup >::components(&selected_benchmark); - let mut progress = $crate::benchmarking::current_time(); - - let mut do_benchmark = | + let do_benchmark = | c: &[($crate::BenchmarkParameter, u32)], results: &mut $crate::Vec<$crate::BenchmarkResults>, verify: bool, From c8f7ce1252d6c813bc656c0370747da7a3ff0f33 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 20:37:00 +0200 Subject: [PATCH 60/73] fix node-template --- bin/node-template/runtime/src/lib.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index f9eaa96153eba..d93dc775d927a 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -446,12 +446,26 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> (Vec, Vec) { + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, frame_system, SystemBench::); + list_benchmark!(list, extra, pallet_balances, Balances); + list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_template, TemplateModule); + + let storage_info = AllPalletsWithSystem::storage_info(); + + return (list, storage_info) + } + fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig - ) -> Result< - (Vec, Vec), - sp_runtime::RuntimeString, - > { + ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_support::traits::StorageInfoTrait; @@ -471,8 +485,6 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), ]; - let storage_info = AllPalletsWithSystem::storage_info(); - let mut batches = Vec::::new(); let params = (&config, &whitelist); @@ -482,7 +494,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_template, TemplateModule); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok((batches, storage_info)) + Ok(batches) } } } From 0a3043b919164836d73dbdb67ed912a8e0ca8b2a Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 30 Jul 2021 20:37:22 +0200 Subject: [PATCH 61/73] fix --- bin/node-template/runtime/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index d93dc775d927a..f94c7d982b27f 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -467,7 +467,6 @@ impl_runtime_apis! { config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; - use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} From 04df7e8f8761798fd5794f4ef13eb5375b0d2059 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 10:37:16 +0200 Subject: [PATCH 62/73] fmt --- utils/frame/benchmarking-cli/src/command.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 151e889a59871..645df887c6a8a 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -17,7 +17,9 @@ use crate::BenchmarkCmd; use codec::{Decode, Encode}; -use frame_benchmarking::{Analysis, BenchmarkBatch, BenchmarkResults, BenchmarkSelector, BenchmarkList}; +use frame_benchmarking::{ + Analysis, BenchmarkBatch, BenchmarkList, BenchmarkResults, BenchmarkSelector, +}; use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; @@ -139,8 +141,9 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error getting benchmark list: {:?}", e))?; - let (list, storage_info) = <(Vec, Vec) as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; + let (list, storage_info) = + <(Vec, Vec) as Decode>::decode(&mut &result[..]) + .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; if self.list { // Show the list and exit early @@ -200,11 +203,11 @@ impl BenchmarkCmd { .execute(strategy.into()) .map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?; - let batch = , - String, - > as Decode>::decode(&mut &result[..]) - .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; + let batch = + , String> as Decode>::decode( + &mut &result[..], + ) + .map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??; batches.extend(batch); From 2a0d85e9b2c43a8a3a15f72da6fb89dae4d34d8c Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 10:43:15 +0200 Subject: [PATCH 63/73] line width --- bin/node-template/runtime/src/lib.rs | 5 ++++- bin/node/runtime/src/lib.rs | 5 ++++- frame/benchmarking/src/utils.rs | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index f94c7d982b27f..63da72102df3d 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -446,7 +446,10 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> (Vec, Vec) { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index aa4d62a9ae086..181f5fd423767 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1534,7 +1534,10 @@ impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> (Vec, Vec) { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 440845929fb85..efb2a01c1557d 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -103,13 +103,16 @@ pub struct BenchmarkConfig { pub lowest_range_values: Vec, /// An optional manual override to the highest values used in the `steps` range. pub highest_range_values: Vec, - /// The number of samples to take across the range of values for components. (current_step, total_steps) + /// The number of samples to take across the range of values for components. (current_step, + /// total_steps) pub steps: (u32, u32), - /// The number times to repeat each benchmark to increase accuracy of results. (current_repeat, total_repeat) + /// The number times to repeat each benchmark to increase accuracy of results. (current_repeat, + /// total_repeat) pub repeat: (u32, u32), /// Enable an extra benchmark iteration which runs the verification logic for a benchmark. pub verify: bool, - /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a pallet. + /// Enable benchmarking of "extra" extrinsics, i.e. those that are not directly used in a + /// pallet. pub extra: bool, } From 20ccbc74d512cb3e96260e56809bee93ff82e333 Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Sat, 31 Jul 2021 09:47:12 +0000 Subject: [PATCH 64/73] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/staking/src/weights.rs | 486 +++++++++++++++++------------------ 1 file changed, 243 insertions(+), 243 deletions(-) diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index 7d2b3363de554..fb4ed160d8325 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-07-21, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -78,208 +78,208 @@ pub trait WeightInfo { /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (73_506_000 as Weight) + (77_492_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } - // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn bond_extra() -> Weight { - (57_019_000 as Weight) + (59_476_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: System Account (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) fn unbond() -> Weight { - (61_257_000 as Weight) + (63_655_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: System Account (r:1 w:1) fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_060_000 as Weight) + (54_534_000 as Weight) // Standard Error: 0 - .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((24_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Balances Locks (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_303_000 as Weight) + (89_850_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_396_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (35_189_000 as Weight) + (36_726_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) fn kick(k: u32, ) -> Weight { - (16_161_000 as Weight) - // Standard Error: 10_000 - .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) + (19_497_000 as Weight) + // Standard Error: 15_000 + .saturating_add((17_057_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Validators (r:2 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) fn nominate(n: u32, ) -> Weight { - (41_638_000 as Weight) - // Standard Error: 9_000 - .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + (45_146_000 as Weight) + // Standard Error: 13_000 + .saturating_add((5_527_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) fn chill() -> Weight { - (18_707_000 as Weight) + (18_986_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) fn set_payee() -> Weight { - (12_688_000 as Weight) + (13_348_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_726_000 as Weight) + (28_148_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (2_309_000 as Weight) + (2_909_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (2_508_000 as Weight) + (3_163_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (2_483_000 as Weight) + (3_141_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_487_000 as Weight) + (3_220_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking Invulnerables (r:0 w:1) fn set_invulnerables(v: u32, ) -> Weight { - (2_465_000 as Weight) + (3_569_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((58_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: Staking Payee (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (62_075_000 as Weight) + (65_753_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_420_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_403_675_000 as Weight) - // Standard Error: 223_000 - .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) + (3_056_514_000 as Weight) + // Standard Error: 218_000 + .saturating_add((21_159_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (111_168_000 as Weight) - // Standard Error: 17_000 - .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + (121_794_000 as Weight) + // Standard Error: 19_000 + .saturating_add((49_467_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking ErasValidatorPrefs (r:1 w:0) // Storage: Staking Ledger (r:2 w:2) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Payee (r:2 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:2 w:2) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: System Account (r:2 w:2) // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Payee (r:2 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (148_375_000 as Weight) - // Standard Error: 22_000 - .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) + (147_049_000 as Weight) + // Standard Error: 30_000 + .saturating_add((64_428_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) @@ -289,89 +289,89 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_669_000 as Weight) - // Standard Error: 2_000 - .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) + (52_184_000 as Weight) + // Standard Error: 1_000 + .saturating_add((35_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking ErasValidatorReward (r:0 w:1) // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:2) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 70_000 - .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 57_000 + .saturating_add((30_689_000 as Weight).saturating_mul(e as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } - // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:1) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Payee (r:0 w:1) // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_475_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) + (75_836_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_423_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System BlockWeight (r:1 w:1) // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:1) // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking Validators (r:2 w:0) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) - // Storage: System BlockWeight (r:1 w:1) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking CounterForNominators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Validators (r:2 w:0) // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 970_000 - .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 48_000 - .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_492_000 + .saturating_add((299_860_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 99_000 + .saturating_add((47_937_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } + // Storage: Staking Validators (r:501 w:0) // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) // Storage: Staking Ledger (r:1500 w:0) // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Validators (r:501 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { (0 as Weight) - // Standard Error: 102_000 - .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 102_000 - .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_473_000 - .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) + // Standard Error: 101_000 + .saturating_add((27_304_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 101_000 + .saturating_add((29_893_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_441_000 + .saturating_add((91_111_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -380,29 +380,29 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { (0 as Weight) - // Standard Error: 29_000 - .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 32_000 + .saturating_add((11_692_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) } // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxValidatorsCount (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_limits() -> Weight { - (6_599_000 as Weight) + (7_325_000 as Weight) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } - // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) fn chill_other() -> Weight { - (62_743_000 as Weight) + (62_683_000 as Weight) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -410,208 +410,208 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (73_506_000 as Weight) + (77_492_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } - // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn bond_extra() -> Weight { - (57_019_000 as Weight) + (59_476_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: System Account (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) fn unbond() -> Weight { - (61_257_000 as Weight) + (63_655_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: System Account (r:1 w:1) fn withdraw_unbonded_update(s: u32, ) -> Weight { - (52_060_000 as Weight) + (54_534_000 as Weight) // Standard Error: 0 - .saturating_add((22_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((24_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Balances Locks (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) // Storage: Staking Payee (r:0 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (86_303_000 as Weight) + (89_850_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_425_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_396_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(8 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (35_189_000 as Weight) + (36_726_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } - // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) fn kick(k: u32, ) -> Weight { - (16_161_000 as Weight) - // Standard Error: 10_000 - .saturating_add((16_898_000 as Weight).saturating_mul(k as Weight)) + (19_497_000 as Weight) + // Standard Error: 15_000 + .saturating_add((17_057_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) // Storage: Staking Validators (r:2 w:0) + // Storage: Staking MaxNominatorsCount (r:1 w:0) fn nominate(n: u32, ) -> Weight { - (41_638_000 as Weight) - // Standard Error: 9_000 - .saturating_add((5_582_000 as Weight).saturating_mul(n as Weight)) + (45_146_000 as Weight) + // Standard Error: 13_000 + .saturating_add((5_527_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:0) fn chill() -> Weight { - (18_707_000 as Weight) + (18_986_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) } - // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Ledger (r:1 w:0) fn set_payee() -> Weight { - (12_688_000 as Weight) + (13_348_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (26_726_000 as Weight) + (28_148_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (2_309_000 as Weight) + (2_909_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (2_508_000 as Weight) + (3_163_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (2_483_000 as Weight) + (3_141_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (2_487_000 as Weight) + (3_220_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Staking Invulnerables (r:0 w:1) fn set_invulnerables(v: u32, ) -> Weight { - (2_465_000 as Weight) + (3_569_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((58_000 as Weight).saturating_mul(v as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: Staking Payee (r:0 w:1) + // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Payee (r:0 w:1) + // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) // Storage: Staking SpanSlash (r:0 w:2) fn force_unstake(s: u32, ) -> Weight { - (62_075_000 as Weight) + (65_753_000 as Weight) // Standard Error: 1_000 - .saturating_add((2_454_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((2_420_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(6 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } // Storage: Staking UnappliedSlashes (r:1 w:1) fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_403_675_000 as Weight) - // Standard Error: 223_000 - .saturating_add((19_948_000 as Weight).saturating_mul(s as Weight)) + (3_056_514_000 as Weight) + // Standard Error: 218_000 + .saturating_add((21_159_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - // Storage: System Account (r:2 w:2) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Staking Payee (r:2 w:0) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking ErasValidatorPrefs (r:1 w:0) fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (111_168_000 as Weight) - // Standard Error: 17_000 - .saturating_add((48_615_000 as Weight).saturating_mul(n as Weight)) + (121_794_000 as Weight) + // Standard Error: 19_000 + .saturating_add((49_467_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } + // Storage: Staking ErasValidatorPrefs (r:1 w:0) // Storage: Staking Ledger (r:2 w:2) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Payee (r:2 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) // Storage: Balances Locks (r:2 w:2) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: System Account (r:2 w:2) // Storage: Staking ErasRewardPoints (r:1 w:0) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Staking ErasStakersClipped (r:1 w:0) + // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Payee (r:2 w:0) fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (148_375_000 as Weight) - // Standard Error: 22_000 - .saturating_add((62_213_000 as Weight).saturating_mul(n as Weight)) + (147_049_000 as Weight) + // Standard Error: 30_000 + .saturating_add((64_428_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) @@ -621,89 +621,89 @@ impl WeightInfo for () { // Storage: Staking Ledger (r:1 w:1) // Storage: System Account (r:1 w:1) fn rebond(l: u32, ) -> Weight { - (48_669_000 as Weight) - // Standard Error: 2_000 - .saturating_add((63_000 as Weight).saturating_mul(l as Weight)) + (52_184_000 as Weight) + // Standard Error: 1_000 + .saturating_add((35_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking ErasValidatorReward (r:0 w:1) // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking ErasValidatorReward (r:0 w:1) + // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:2) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStakers (r:0 w:2) + // Storage: Staking ErasRewardPoints (r:0 w:1) + // Storage: Staking HistoryDepth (r:1 w:1) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) fn set_history_depth(e: u32, ) -> Weight { (0 as Weight) - // Standard Error: 70_000 - .saturating_add((34_853_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 57_000 + .saturating_add((30_689_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } - // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:1) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking SpanSlash (r:0 w:1) // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: System Account (r:1 w:1) // Storage: Staking Payee (r:0 w:1) // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - // Storage: Staking SpanSlash (r:0 w:1) fn reap_stash(s: u32, ) -> Weight { - (73_475_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_390_000 as Weight).saturating_mul(s as Weight)) + (75_836_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_423_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } - // Storage: Staking HistoryDepth (r:1 w:0) + // Storage: System BlockWeight (r:1 w:1) // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking ErasStakersClipped (r:0 w:1) // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking Validators (r:2 w:0) // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking ErasStakersClipped (r:0 w:1) - // Storage: System BlockWeight (r:1 w:1) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking CounterForNominators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking ErasStartSessionIndex (r:0 w:1) // Storage: Staking Ledger (r:101 w:0) + // Storage: Staking Validators (r:2 w:0) // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking CounterForValidators (r:1 w:0) + // Storage: Staking CounterForNominators (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:0 w:1) + // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:1) + // Storage: Staking MinimumValidatorCount (r:1 w:0) + // Storage: Staking ErasTotalStake (r:0 w:1) fn new_era(v: u32, n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 970_000 - .saturating_add((308_475_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 48_000 - .saturating_add((48_379_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_492_000 + .saturating_add((299_860_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 99_000 + .saturating_add((47_937_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) } + // Storage: Staking Validators (r:501 w:0) // Storage: Staking Bonded (r:1500 w:0) + // Storage: Staking Nominators (r:1001 w:0) // Storage: Staking Ledger (r:1500 w:0) // Storage: Staking SlashingSpans (r:21 w:0) - // Storage: Staking Nominators (r:1001 w:0) - // Storage: Staking Validators (r:501 w:0) fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { (0 as Weight) - // Standard Error: 102_000 - .saturating_add((26_408_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 102_000 - .saturating_add((28_824_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 3_473_000 - .saturating_add((49_400_000 as Weight).saturating_mul(s as Weight)) + // Standard Error: 101_000 + .saturating_add((27_304_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 101_000 + .saturating_add((29_893_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 3_441_000 + .saturating_add((91_111_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -712,29 +712,29 @@ impl WeightInfo for () { // Storage: Staking Validators (r:501 w:0) fn get_npos_targets(v: u32, ) -> Weight { (0 as Weight) - // Standard Error: 29_000 - .saturating_add((11_333_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 32_000 + .saturating_add((11_692_000 as Weight).saturating_mul(v as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) } // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxValidatorsCount (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) + // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_limits() -> Weight { - (6_599_000 as Weight) + (7_325_000 as Weight) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } - // Storage: Staking CounterForValidators (r:1 w:1) + // Storage: Staking MinValidatorBond (r:1 w:0) + // Storage: Staking ChillThreshold (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) // Storage: Staking Validators (r:1 w:1) + // Storage: Staking CounterForValidators (r:1 w:1) // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) fn chill_other() -> Weight { - (62_743_000 as Weight) + (62_683_000 as Weight) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From 4f1a56075a92fda575e9bda2088a578331e4a27e Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 12:13:42 +0200 Subject: [PATCH 65/73] improve docs --- frame/benchmarking/src/lib.rs | 20 ++++++++++++++++++++ frame/benchmarking/src/utils.rs | 7 +++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index bba558d241523..ba1ca21481afb 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -1358,6 +1358,26 @@ macro_rules! add_benchmark { ) } +/// This macro allows users to easily generate a list of benchmarks for the pallets configured +/// in the runtime. +/// +/// To use this macro, first create a an object to store the list: +/// +/// ``` +/// let mut list = Vec::::new(); +/// ``` +/// +/// Then pass this `list` to the macro, along with the `extra` boolean, the pallet crate, and +/// pallet struct: +/// +/// ``` +/// list_benchmark!(list, extra, pallet_balances, Balances); +/// list_benchmark!(list, extra, pallet_session, SessionBench::); +/// list_benchmark!(list, extra, frame_system, SystemBench::); +/// ``` +/// +/// This should match what exists with the `add_benchmark!` macro. + #[macro_export] macro_rules! list_benchmark { ( $list:ident, $extra:ident, $name:path, $( $location:tt )* ) => ( diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index efb2a01c1557d..82c6e44796fae 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -116,6 +116,9 @@ pub struct BenchmarkConfig { pub extra: bool, } +/// A list of benchmarks available for a particular pallet and instance. +/// +/// All `Vec` must be valid utf8 strings. #[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] pub struct BenchmarkList { pub pallet: Vec, @@ -126,10 +129,10 @@ pub struct BenchmarkList { sp_api::decl_runtime_apis! { /// Runtime api for benchmarking a FRAME runtime. pub trait Benchmark { - /// Get the benchmarks available for this runtime. + /// Get the benchmark metadata available for this runtime. /// /// Parameters - /// - `extra`: Also return benchmarks marked "extra" which would otherwise not be + /// - `extra`: Also list benchmarks marked "extra" which would otherwise not be /// needed for weight calculation. fn benchmark_metadata(extra: bool) -> (Vec, Vec); From e743100c94c32d4d12e1d1662b892cdab2ed61ce Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 14:21:01 +0200 Subject: [PATCH 66/73] improve cli --- frame/benchmarking/src/lib.rs | 4 +- utils/frame/benchmarking-cli/src/command.rs | 68 +++++++++++++++------ utils/frame/benchmarking-cli/src/lib.rs | 14 +++-- 3 files changed, 62 insertions(+), 24 deletions(-) diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index ba1ca21481afb..7149ddc82f59d 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -1363,14 +1363,14 @@ macro_rules! add_benchmark { /// /// To use this macro, first create a an object to store the list: /// -/// ``` +/// ```ignore /// let mut list = Vec::::new(); /// ``` /// /// Then pass this `list` to the macro, along with the `extra` boolean, the pallet crate, and /// pallet struct: /// -/// ``` +/// ```ignore /// list_benchmark!(list, extra, pallet_balances, Balances); /// list_benchmark!(list, extra, pallet_session, SessionBench::); /// list_benchmark!(list, extra, frame_system, SystemBench::); diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 645df887c6a8a..00e4bc342493e 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -40,7 +40,7 @@ use std::{collections::HashMap, fmt::Debug, sync::Arc}; // and benchmark are the same. fn combine_batches(batches: Vec) -> Vec { if batches.is_empty() { - return batches + return batches; } let mut all_benchmarks = LinkedHashMap::<_, Vec>::new(); @@ -57,7 +57,7 @@ fn combine_batches(batches: Vec) -> Vec { // New benchmark, so we add a new entry with the initial results. None => { all_benchmarks.insert(key, results); - }, + } } }); @@ -83,27 +83,29 @@ impl BenchmarkCmd { { if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { - return Err("Output file or path is invalid!".into()) + return Err("Output file or path is invalid!".into()); } } if let Some(header_file) = &self.header { if !header_file.is_file() { - return Err("Header file is invalid!".into()) + return Err("Header file is invalid!".into()); }; } if let Some(handlebars_template_file) = &self.template { if !handlebars_template_file.is_file() { - return Err("Handlebars template file is invalid!".into()) + return Err("Handlebars template file is invalid!".into()); }; } let spec = config.chain_spec; let wasm_method = self.wasm_method.into(); let strategy = self.execution.unwrap_or(ExecutionStrategy::Native); - let pallet = self.pallet.as_bytes(); - let extrinsic = self.extrinsic.as_bytes(); + let pallet = self.pallet.clone().unwrap_or_else(|| String::new()); + let pallet = pallet.as_bytes(); + let extrinsic = self.extrinsic.clone().unwrap_or_else(|| String::new()); + let extrinsic = extrinsic.as_bytes(); let genesis_storage = spec.build_storage()?; let mut changes = Default::default(); @@ -123,7 +125,7 @@ impl BenchmarkCmd { extensions.register(OffchainWorkerExt::new(offchain.clone())); extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); - return extensions + return extensions; }; // Get Benchmark List @@ -146,14 +148,8 @@ impl BenchmarkCmd { .map_err(|e| format!("Failed to decode benchmark metadata: {:?}", e))?; if self.list { - // Show the list and exit early - for item in list { - println!("{}", String::from_utf8(item.pallet).unwrap()); - for benchmark in item.benchmarks { - println!("- {}", String::from_utf8(benchmark).unwrap()); - } - } - return Ok(()) + list_benchmark(pallet, extrinsic, list); + return Ok(()); } // Use the benchmark list and the user input to determine the set of benchmarks to run. @@ -254,7 +250,7 @@ impl BenchmarkCmd { // Skip raw data + analysis if there are no results if batch.results.is_empty() { - continue + continue; } if self.raw_data { @@ -337,3 +333,41 @@ impl CliConfiguration for BenchmarkCmd { }) } } + +/// List the benchmarks available in the runtime, in a CSV friendly format. +/// +/// If `pallet_input` and `extrinsic_input` is empty, we list everything. +/// +/// If `pallet_input` is present, we only list the benchmarks for that pallet. +/// +/// If `extrinsic_input` is `*`, we will hide the individual benchmarks for each pallet, and just +/// show a single line for each available pallet. +fn list_benchmark(pallet_input: &[u8], extrinsic_input: &[u8], list: Vec) { + let filtered_list = list + .into_iter() + .filter(|item| pallet_input.is_empty() || pallet_input == &item.pallet) + .collect::>(); + + if filtered_list.is_empty() { + println!("Pallet not found."); + return; + } + + println!("pallet, benchmark"); + for item in filtered_list { + let pallet_string = + String::from_utf8(item.pallet.clone()).expect("Encoded from String; qed"); + + if extrinsic_input == &b"*"[..] { + println!("{}, *", pallet_string) + } else { + for benchmark in item.benchmarks { + println!( + "{}, {}", + pallet_string, + String::from_utf8(benchmark).expect("Encoded from String; qed"), + ); + } + } + } +} diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index d66e59bde0cbd..41629a866f726 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -31,12 +31,12 @@ fn parse_pallet_name(pallet: &str) -> String { #[derive(Debug, structopt::StructOpt)] pub struct BenchmarkCmd { /// Select a FRAME Pallet to benchmark, or `*` for all (in which case `extrinsic` must be `*`). - #[structopt(short, long, parse(from_str = parse_pallet_name))] - pub pallet: String, + #[structopt(short, long, parse(from_str = parse_pallet_name), required_unless = "list")] + pub pallet: Option, /// Select an extrinsic inside the pallet to benchmark, or `*` for all. - #[structopt(short, long)] - pub extrinsic: String, + #[structopt(short, long, required_unless = "list")] + pub extrinsic: Option, /// Select how many samples we should take across the variable components. #[structopt(short, long, default_value = "1")] @@ -130,7 +130,11 @@ pub struct BenchmarkCmd { #[structopt(long = "db-cache", value_name = "MiB", default_value = "128")] pub database_cache_size: u32, - /// List the benchmarks available + /// List the benchmarks available. + /// + /// * If nothing else is specified, all pallets and benchmarks will be listed. + /// * If the `pallet` argument is passed, then we will only list benchmarks for that pallet. + /// * If the `extrinsic` argument is set to `*`, we will hide the individual benchmarks. #[structopt(long)] pub list: bool, } From f1fdbac68dd4d961c2ca537ea8efd3d64867fab7 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 31 Jul 2021 15:29:24 +0200 Subject: [PATCH 67/73] fix format --- utils/frame/benchmarking-cli/src/command.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 00e4bc342493e..3ca6ca9d26e29 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -40,7 +40,7 @@ use std::{collections::HashMap, fmt::Debug, sync::Arc}; // and benchmark are the same. fn combine_batches(batches: Vec) -> Vec { if batches.is_empty() { - return batches; + return batches } let mut all_benchmarks = LinkedHashMap::<_, Vec>::new(); @@ -57,7 +57,7 @@ fn combine_batches(batches: Vec) -> Vec { // New benchmark, so we add a new entry with the initial results. None => { all_benchmarks.insert(key, results); - } + }, } }); @@ -83,19 +83,19 @@ impl BenchmarkCmd { { if let Some(output_path) = &self.output { if !output_path.is_dir() && output_path.file_name().is_none() { - return Err("Output file or path is invalid!".into()); + return Err("Output file or path is invalid!".into()) } } if let Some(header_file) = &self.header { if !header_file.is_file() { - return Err("Header file is invalid!".into()); + return Err("Header file is invalid!".into()) }; } if let Some(handlebars_template_file) = &self.template { if !handlebars_template_file.is_file() { - return Err("Handlebars template file is invalid!".into()); + return Err("Handlebars template file is invalid!".into()) }; } @@ -125,7 +125,7 @@ impl BenchmarkCmd { extensions.register(OffchainWorkerExt::new(offchain.clone())); extensions.register(OffchainDbExt::new(offchain)); extensions.register(TransactionPoolExt::new(pool)); - return extensions; + return extensions }; // Get Benchmark List @@ -149,7 +149,7 @@ impl BenchmarkCmd { if self.list { list_benchmark(pallet, extrinsic, list); - return Ok(()); + return Ok(()) } // Use the benchmark list and the user input to determine the set of benchmarks to run. @@ -250,7 +250,7 @@ impl BenchmarkCmd { // Skip raw data + analysis if there are no results if batch.results.is_empty() { - continue; + continue } if self.raw_data { @@ -350,7 +350,7 @@ fn list_benchmark(pallet_input: &[u8], extrinsic_input: &[u8], list: Vec Date: Sun, 1 Aug 2021 10:51:05 +0200 Subject: [PATCH 68/73] fix bug? --- Cargo.lock | 2 +- frame/metadata/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- frame/support/test/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d22e0c0b6bd9..25acd8206351e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1851,7 +1851,7 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "14.0.0-dev" +version = "4.0.0-dev" dependencies = [ "parity-scale-codec", "serde", diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 332ce5b70c26e..68054da927de7 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-metadata" -version = "14.0.0-dev" +version = "4.0.0-dev" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index ed3a2f45a2e14..45f7d55ebfae9 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] serde = { version = "1.0.126", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] } -frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../metadata" } +frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../metadata" } sp-std = { version = "4.0.0-dev", default-features = false, path = "../../primitives/std" } sp-io = { version = "4.0.0-dev", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "4.0.0-dev", default-features = false, path = "../../primitives/runtime" } diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index c8f746c7cb9d4..c2391a080a762 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -23,7 +23,7 @@ sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../pri trybuild = "1.0.43" pretty_assertions = "0.6.1" rustversion = "1.0.0" -frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../../metadata" } +frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../../metadata" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } # The "std" feature for this pallet is never activated on purpose, in order to test construct_runtime error message test-pallet = { package = "frame-support-test-pallet", default-features = false, path = "pallet" } From 17f33f8325b5808cc2d87fac1809eb566b3f0311 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Aug 2021 11:00:29 +0200 Subject: [PATCH 69/73] Revert "fix bug?" This reverts commit 8051bf1bf9bae862ff28dfff386e7045cd3f045e. --- Cargo.lock | 2 +- frame/metadata/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- frame/support/test/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25acd8206351e..3d22e0c0b6bd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1851,7 +1851,7 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "4.0.0-dev" +version = "14.0.0-dev" dependencies = [ "parity-scale-codec", "serde", diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 68054da927de7..332ce5b70c26e 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-metadata" -version = "4.0.0-dev" +version = "14.0.0-dev" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 45f7d55ebfae9..ed3a2f45a2e14 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] serde = { version = "1.0.126", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] } -frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../metadata" } +frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../metadata" } sp-std = { version = "4.0.0-dev", default-features = false, path = "../../primitives/std" } sp-io = { version = "4.0.0-dev", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "4.0.0-dev", default-features = false, path = "../../primitives/runtime" } diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index c2391a080a762..c8f746c7cb9d4 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -23,7 +23,7 @@ sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../pri trybuild = "1.0.43" pretty_assertions = "0.6.1" rustversion = "1.0.0" -frame-metadata = { version = "4.0.0-dev", default-features = false, path = "../../metadata" } +frame-metadata = { version = "14.0.0-dev", default-features = false, path = "../../metadata" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } # The "std" feature for this pallet is never activated on purpose, in order to test construct_runtime error message test-pallet = { package = "frame-support-test-pallet", default-features = false, path = "pallet" } From 70eeb9f47f111349befa6ce8ab900db1dc5cc6d6 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Aug 2021 11:01:40 +0200 Subject: [PATCH 70/73] skip frame-metadata --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cef2d8badcc9..ca76ae86666b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,7 @@ variables: &default-vars CI_IMAGE: "paritytech/ci-linux:production" # FIXME set to release CARGO_UNLEASH_INSTALL_PARAMS: "--version 1.0.0-alpha.12" - CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder" + CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder frame-metadata" default: cache: {} @@ -273,7 +273,7 @@ node-bench-regression-guard: CI_IMAGE: "paritytech/node-bench-regression-guard:latest" before_script: [""] script: - - 'node-bench-regression-guard --reference artifacts/benches/master-* + - 'node-bench-regression-guard --reference artifacts/benches/master-* --compare-with artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA' cargo-check-subkey: @@ -578,7 +578,7 @@ build-rust-doc: - buildah push --format=v2s2 "$IMAGE_NAME:latest" after_script: - buildah logout "$IMAGE_NAME" - # pass artifacts to the trigger-simnet job + # pass artifacts to the trigger-simnet job - echo "IMAGE_NAME=${IMAGE_NAME}" | tee -a ./artifacts/$PRODUCT/build.env - IMAGE_TAG="$(cat ./artifacts/$PRODUCT/VERSION)" - echo "IMAGE_TAG=${IMAGE_TAG}" | tee -a ./artifacts/$PRODUCT/build.env @@ -713,7 +713,7 @@ trigger-simnet: - if: $CI_COMMIT_REF_NAME == "master" needs: - job: publish-docker-substrate - # `build.env` brings here `$IMAGE_NAME` and `$IMAGE_TAG` (`$VERSION` here, + # `build.env` brings here `$IMAGE_NAME` and `$IMAGE_TAG` (`$VERSION` here, # i.e. `2643-0.8.29-5f689e0a-6b24dc54`). variables: TRGR_PROJECT: ${CI_PROJECT_NAME} From 048b452549ab0c66095cc83d2588087508ee6902 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Aug 2021 16:43:21 +0200 Subject: [PATCH 71/73] Update .gitlab-ci.yml --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca76ae86666b4..9608d380d9fd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,7 @@ variables: &default-vars CI_IMAGE: "paritytech/ci-linux:production" # FIXME set to release CARGO_UNLEASH_INSTALL_PARAMS: "--version 1.0.0-alpha.12" - CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder frame-metadata" + CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder" default: cache: {} From 0c0e11282b2c3858aa56100adc50e932da049d27 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Aug 2021 16:53:37 +0200 Subject: [PATCH 72/73] fix import --- utils/frame/benchmarking-cli/src/command.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index d065ff99e5f66..925cfd07d03e2 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -34,7 +34,7 @@ use sp_externalities::Extensions; use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use sp_state_machine::StateMachine; -use std::{fmt::Debug, sync::Arc}; +use std::{fmt::Debug, sync::Arc, time}; // This takes multiple benchmark batches and combines all the results where the pallet, instance, // and benchmark are the same. From fec5ee2bff3e70ef4da1e90441ce9354cb2d9b6e Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Aug 2021 17:58:35 +0200 Subject: [PATCH 73/73] Update .gitlab-ci.yml --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9608d380d9fd5..f954ac23cba23 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -343,6 +343,7 @@ unleash-check: - mkdir -p target/unleash - export CARGO_TARGET_DIR=target/unleash - cargo unleash check ${CARGO_UNLEASH_PKG_DEF} + allow_failure: true test-frame-examples-compile-to-wasm: # into one job