Update benchmarking macros (#3934)

Current benchmarking macro returns a closure with the captured
benchmarked code.
This can cause issues when the benchmarked code has complex lifetime
requirements.

This PR updates the existing macro by injecting the recording parameter
and invoking the start / stop method around the benchmarked block
instead of returning a closure

One other added benefit is that you can write this kind of code now as
well:

```rust
let v;
#[block]
{ v = func.call(); }
dbg!(v); // or assert something on v
```


[Weights compare
link](https://weights.tasty.limo/compare?unit=weight&ignore_errors=true&threshold=10&method=asymptotic&repo=polkadot-sdk&old=pg/fix-weights&new=pg/bench_update&path_pattern=substrate/frame/**/src/weights.rs,polkadot/runtime/*/src/weights/**/*.rs,polkadot/bridges/modules/*/src/weights.rs,cumulus/**/weights/*.rs,cumulus/**/weights/xcm/*.rs,cumulus/**/src/weights.rs)

---------

Co-authored-by: command-bot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
PG Herveou
2024-04-10 08:44:46 +02:00
committed by GitHub
parent ddb53c87f5
commit d38f6e6728
65 changed files with 11402 additions and 10551 deletions
+93 -90
View File
@@ -17,26 +17,29 @@
//! Autogenerated weights for `pallet_migrations`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-12-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-04-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `loud1`, CPU: `AMD EPYC 7282 16-Core Processor`
//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
// Executed Command:
// target/release/substrate-node
// ./target/production/substrate-node
// benchmark
// pallet
// --chain
// dev
// --pallet
// pallet-migrations
// --extrinsic
//
// --output
// weight.rs
// --template
// ../../polkadot-sdk/substrate/.maintain/frame-weight-template.hbs
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_migrations
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./substrate/frame/migrations/src/weights.rs
// --header=./substrate/HEADER-APACHE2
// --template=./substrate/.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -71,10 +74,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
fn onboard_new_mbms() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Measured: `276`
// Estimated: `67035`
// Minimum execution time: 13_980_000 picoseconds.
Weight::from_parts(14_290_000, 67035)
// Minimum execution time: 7_762_000 picoseconds.
Weight::from_parts(8_100_000, 67035)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -82,10 +85,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn progress_mbms_none() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Measured: `142`
// Estimated: `67035`
// Minimum execution time: 3_770_000 picoseconds.
Weight::from_parts(4_001_000, 67035)
// Minimum execution time: 2_077_000 picoseconds.
Weight::from_parts(2_138_000, 67035)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
@@ -96,8 +99,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `134`
// Estimated: `3599`
// Minimum execution time: 10_900_000 picoseconds.
Weight::from_parts(11_251_000, 3599)
// Minimum execution time: 5_868_000 picoseconds.
Weight::from_parts(6_143_000, 3599)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -107,10 +110,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_skipped_historic() -> Weight {
// Proof Size summary in bytes:
// Measured: `297`
// Estimated: `3762`
// Minimum execution time: 17_891_000 picoseconds.
Weight::from_parts(18_501_000, 3762)
// Measured: `330`
// Estimated: `3795`
// Minimum execution time: 10_283_000 picoseconds.
Weight::from_parts(10_964_000, 3795)
.saturating_add(T::DbWeight::get().reads(2_u64))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
@@ -119,10 +122,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_advance() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Estimated: `3731`
// Minimum execution time: 18_271_000 picoseconds.
Weight::from_parts(18_740_000, 3731)
// Measured: `276`
// Estimated: `3741`
// Minimum execution time: 9_900_000 picoseconds.
Weight::from_parts(10_396_000, 3741)
.saturating_add(T::DbWeight::get().reads(2_u64))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
@@ -131,10 +134,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_complete() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Estimated: `3731`
// Minimum execution time: 21_241_000 picoseconds.
Weight::from_parts(21_911_000, 3731)
// Measured: `276`
// Estimated: `3741`
// Minimum execution time: 11_411_000 picoseconds.
Weight::from_parts(11_956_000, 3741)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -146,10 +149,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn exec_migration_fail() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Estimated: `3731`
// Minimum execution time: 22_740_000 picoseconds.
Weight::from_parts(23_231_000, 3731)
// Measured: `276`
// Estimated: `3741`
// Minimum execution time: 12_398_000 picoseconds.
Weight::from_parts(12_910_000, 3741)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -157,8 +160,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 440_000 picoseconds.
Weight::from_parts(500_000, 0)
// Minimum execution time: 166_000 picoseconds.
Weight::from_parts(193_000, 0)
}
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
@@ -166,8 +169,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_751_000 picoseconds.
Weight::from_parts(5_950_000, 0)
// Minimum execution time: 2_686_000 picoseconds.
Weight::from_parts(2_859_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
@@ -176,8 +179,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_350_000 picoseconds.
Weight::from_parts(6_560_000, 0)
// Minimum execution time: 3_070_000 picoseconds.
Weight::from_parts(3_250_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
@@ -186,10 +189,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
fn force_onboard_mbms() -> Weight {
// Proof Size summary in bytes:
// Measured: `218`
// Measured: `251`
// Estimated: `67035`
// Minimum execution time: 11_121_000 picoseconds.
Weight::from_parts(11_530_000, 67035)
// Minimum execution time: 5_901_000 picoseconds.
Weight::from_parts(6_320_000, 67035)
.saturating_add(T::DbWeight::get().reads(2_u64))
}
/// Storage: `MultiBlockMigrations::Historic` (r:256 w:256)
@@ -197,12 +200,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// The range of component `n` is `[0, 256]`.
fn clear_historic(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1089 + n * (271 ±0)`
// Measured: `1122 + n * (271 ±0)`
// Estimated: `3834 + n * (2740 ±0)`
// Minimum execution time: 21_891_000 picoseconds.
Weight::from_parts(18_572_306, 3834)
// Standard Error: 3_236
.saturating_add(Weight::from_parts(1_648_429, 0).saturating_mul(n.into()))
// Minimum execution time: 15_952_000 picoseconds.
Weight::from_parts(14_358_665, 3834)
// Standard Error: 3_358
.saturating_add(Weight::from_parts(1_323_674, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
@@ -218,10 +221,10 @@ impl WeightInfo for () {
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
fn onboard_new_mbms() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Measured: `276`
// Estimated: `67035`
// Minimum execution time: 13_980_000 picoseconds.
Weight::from_parts(14_290_000, 67035)
// Minimum execution time: 7_762_000 picoseconds.
Weight::from_parts(8_100_000, 67035)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -229,10 +232,10 @@ impl WeightInfo for () {
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn progress_mbms_none() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Measured: `142`
// Estimated: `67035`
// Minimum execution time: 3_770_000 picoseconds.
Weight::from_parts(4_001_000, 67035)
// Minimum execution time: 2_077_000 picoseconds.
Weight::from_parts(2_138_000, 67035)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
@@ -243,8 +246,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `134`
// Estimated: `3599`
// Minimum execution time: 10_900_000 picoseconds.
Weight::from_parts(11_251_000, 3599)
// Minimum execution time: 5_868_000 picoseconds.
Weight::from_parts(6_143_000, 3599)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -254,10 +257,10 @@ impl WeightInfo for () {
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_skipped_historic() -> Weight {
// Proof Size summary in bytes:
// Measured: `297`
// Estimated: `3762`
// Minimum execution time: 17_891_000 picoseconds.
Weight::from_parts(18_501_000, 3762)
// Measured: `330`
// Estimated: `3795`
// Minimum execution time: 10_283_000 picoseconds.
Weight::from_parts(10_964_000, 3795)
.saturating_add(RocksDbWeight::get().reads(2_u64))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
@@ -266,10 +269,10 @@ impl WeightInfo for () {
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_advance() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Estimated: `3731`
// Minimum execution time: 18_271_000 picoseconds.
Weight::from_parts(18_740_000, 3731)
// Measured: `276`
// Estimated: `3741`
// Minimum execution time: 9_900_000 picoseconds.
Weight::from_parts(10_396_000, 3741)
.saturating_add(RocksDbWeight::get().reads(2_u64))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
@@ -278,10 +281,10 @@ impl WeightInfo for () {
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_complete() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Estimated: `3731`
// Minimum execution time: 21_241_000 picoseconds.
Weight::from_parts(21_911_000, 3731)
// Measured: `276`
// Estimated: `3741`
// Minimum execution time: 11_411_000 picoseconds.
Weight::from_parts(11_956_000, 3741)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -293,10 +296,10 @@ impl WeightInfo for () {
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn exec_migration_fail() -> Weight {
// Proof Size summary in bytes:
// Measured: `243`
// Estimated: `3731`
// Minimum execution time: 22_740_000 picoseconds.
Weight::from_parts(23_231_000, 3731)
// Measured: `276`
// Estimated: `3741`
// Minimum execution time: 12_398_000 picoseconds.
Weight::from_parts(12_910_000, 3741)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -304,8 +307,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 440_000 picoseconds.
Weight::from_parts(500_000, 0)
// Minimum execution time: 166_000 picoseconds.
Weight::from_parts(193_000, 0)
}
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
@@ -313,8 +316,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_751_000 picoseconds.
Weight::from_parts(5_950_000, 0)
// Minimum execution time: 2_686_000 picoseconds.
Weight::from_parts(2_859_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
@@ -323,8 +326,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_350_000 picoseconds.
Weight::from_parts(6_560_000, 0)
// Minimum execution time: 3_070_000 picoseconds.
Weight::from_parts(3_250_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
@@ -333,10 +336,10 @@ impl WeightInfo for () {
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
fn force_onboard_mbms() -> Weight {
// Proof Size summary in bytes:
// Measured: `218`
// Measured: `251`
// Estimated: `67035`
// Minimum execution time: 11_121_000 picoseconds.
Weight::from_parts(11_530_000, 67035)
// Minimum execution time: 5_901_000 picoseconds.
Weight::from_parts(6_320_000, 67035)
.saturating_add(RocksDbWeight::get().reads(2_u64))
}
/// Storage: `MultiBlockMigrations::Historic` (r:256 w:256)
@@ -344,12 +347,12 @@ impl WeightInfo for () {
/// The range of component `n` is `[0, 256]`.
fn clear_historic(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1089 + n * (271 ±0)`
// Measured: `1122 + n * (271 ±0)`
// Estimated: `3834 + n * (2740 ±0)`
// Minimum execution time: 21_891_000 picoseconds.
Weight::from_parts(18_572_306, 3834)
// Standard Error: 3_236
.saturating_add(Weight::from_parts(1_648_429, 0).saturating_mul(n.into()))
// Minimum execution time: 15_952_000 picoseconds.
Weight::from_parts(14_358_665, 3834)
// Standard Error: 3_358
.saturating_add(Weight::from_parts(1_323_674, 0).saturating_mul(n.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into())))
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into())))