Skip to content

Commit

Permalink
Migrating polkadot-runtime-parachains configuration benchmarking to V2 (
Browse files Browse the repository at this point in the history
#6607)

# Description
Migrating polkadot-runtime-parachains configuration benchmarking to the
new benchmarking syntax v2.
This is a part of #6202

---------

Co-authored-by: Giuseppe Re <giuseppe.re@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: seemantaggarwal <32275622+seemantaggarwal@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 4, 2025
1 parent b07abee commit ac7037e
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 60 deletions.
94 changes: 70 additions & 24 deletions polkadot/runtime/parachains/src/configuration/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,91 @@

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
#![cfg(feature = "runtime-benchmarks")]

use crate::configuration::*;
use frame_benchmarking::{benchmarks, BenchmarkError, BenchmarkResult};
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
use polkadot_primitives::{ExecutorParam, ExecutorParams, PvfExecKind, PvfPrepKind};
use sp_runtime::traits::One;

benchmarks! {
set_config_with_block_number {}: set_code_retention_period(RawOrigin::Root, One::one())
#[benchmarks]
mod benchmarks {
use super::*;

set_config_with_u32 {}: set_max_code_size(RawOrigin::Root, 100)
#[benchmark]
fn set_config_with_block_number() {
#[extrinsic_call]
set_code_retention_period(RawOrigin::Root, One::one());
}

set_config_with_option_u32 {}: set_max_validators(RawOrigin::Root, Some(10))
#[benchmark]
fn set_config_with_u32() {
#[extrinsic_call]
set_max_code_size(RawOrigin::Root, 100);
}

set_hrmp_open_request_ttl {}: {
Err(BenchmarkError::Override(
BenchmarkResult::from_weight(T::BlockWeights::get().max_block)
))?;
#[benchmark]
fn set_config_with_option_u32() {
#[extrinsic_call]
set_max_validators(RawOrigin::Root, Some(10));
}

set_config_with_balance {}: set_hrmp_sender_deposit(RawOrigin::Root, 100_000_000_000)
#[benchmark]
fn set_hrmp_open_request_ttl() -> Result<(), BenchmarkError> {
#[block]
{
Err(BenchmarkError::Override(BenchmarkResult::from_weight(
T::BlockWeights::get().max_block,
)))?;
}
Ok(())
}

set_config_with_executor_params {}: set_executor_params(RawOrigin::Root, ExecutorParams::from(&[
ExecutorParam::MaxMemoryPages(2080),
ExecutorParam::StackLogicalMax(65536),
ExecutorParam::StackNativeMax(256 * 1024 * 1024),
ExecutorParam::WasmExtBulkMemory,
ExecutorParam::PrecheckingMaxMemory(2 * 1024 * 1024 * 1024),
ExecutorParam::PvfPrepTimeout(PvfPrepKind::Precheck, 60_000),
ExecutorParam::PvfPrepTimeout(PvfPrepKind::Prepare, 360_000),
ExecutorParam::PvfExecTimeout(PvfExecKind::Backing, 2_000),
ExecutorParam::PvfExecTimeout(PvfExecKind::Approval, 12_000),
][..]))
#[benchmark]
fn set_config_with_balance() {
#[extrinsic_call]
set_hrmp_sender_deposit(RawOrigin::Root, 100_000_000_000);
}

set_config_with_perbill {}: set_on_demand_fee_variability(RawOrigin::Root, Perbill::from_percent(100))
#[benchmark]
fn set_config_with_executor_params() {
#[extrinsic_call]
set_executor_params(
RawOrigin::Root,
ExecutorParams::from(
&[
ExecutorParam::MaxMemoryPages(2080),
ExecutorParam::StackLogicalMax(65536),
ExecutorParam::StackNativeMax(256 * 1024 * 1024),
ExecutorParam::WasmExtBulkMemory,
ExecutorParam::PrecheckingMaxMemory(2 * 1024 * 1024 * 1024),
ExecutorParam::PvfPrepTimeout(PvfPrepKind::Precheck, 60_000),
ExecutorParam::PvfPrepTimeout(PvfPrepKind::Prepare, 360_000),
ExecutorParam::PvfExecTimeout(PvfExecKind::Backing, 2_000),
ExecutorParam::PvfExecTimeout(PvfExecKind::Approval, 12_000),
][..],
),
);
}

set_node_feature{}: set_node_feature(RawOrigin::Root, 255, true)
#[benchmark]
fn set_config_with_perbill() {
#[extrinsic_call]
set_on_demand_fee_variability(RawOrigin::Root, Perbill::from_percent(100));
}

#[benchmark]
fn set_node_feature() {
#[extrinsic_call]
set_node_feature(RawOrigin::Root, 255, true);
}

set_config_with_scheduler_params {} : set_scheduler_params(RawOrigin::Root, SchedulerParams::default())
#[benchmark]
fn set_config_with_scheduler_params() {
#[extrinsic_call]
set_scheduler_params(RawOrigin::Root, SchedulerParams::default());
}

impl_benchmark_test_suite!(
Pallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//! Autogenerated weights for `polkadot_runtime_parachains::configuration`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-02-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `13d69b199c54`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
// Executed Command:
Expand Down Expand Up @@ -61,8 +61,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_055_000 picoseconds.
Weight::from_parts(11_488_000, 0)
// Minimum execution time: 10_901_000 picoseconds.
Weight::from_parts(11_468_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -77,8 +77,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_125_000 picoseconds.
Weight::from_parts(11_591_000, 0)
// Minimum execution time: 10_847_000 picoseconds.
Weight::from_parts(11_499_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -93,8 +93,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_127_000 picoseconds.
Weight::from_parts(11_499_000, 0)
// Minimum execution time: 11_143_000 picoseconds.
Weight::from_parts(11_488_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -119,8 +119,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_955_000 picoseconds.
Weight::from_parts(11_407_000, 0)
// Minimum execution time: 11_126_000 picoseconds.
Weight::from_parts(11_416_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -135,8 +135,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 13_162_000 picoseconds.
Weight::from_parts(13_403_000, 0)
// Minimum execution time: 13_119_000 picoseconds.
Weight::from_parts(13_612_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -151,8 +151,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_868_000 picoseconds.
Weight::from_parts(11_438_000, 0)
// Minimum execution time: 11_072_000 picoseconds.
Weight::from_parts(11_412_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -167,8 +167,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 13_354_000 picoseconds.
Weight::from_parts(14_407_000, 0)
// Minimum execution time: 13_268_000 picoseconds.
Weight::from_parts(13_664_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -183,8 +183,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_283_000 picoseconds.
Weight::from_parts(12_054_000, 0)
// Minimum execution time: 11_047_000 picoseconds.
Weight::from_parts(11_298_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//! Autogenerated weights for `polkadot_runtime_parachains::configuration`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-02-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `3a2e9ae8a8f5`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `13d69b199c54`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
// Executed Command:
Expand Down Expand Up @@ -61,8 +61,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_475_000 picoseconds.
Weight::from_parts(11_132_000, 0)
// Minimum execution time: 10_838_000 picoseconds.
Weight::from_parts(11_218_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -77,8 +77,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_419_000 picoseconds.
Weight::from_parts(11_052_000, 0)
// Minimum execution time: 10_949_000 picoseconds.
Weight::from_parts(11_200_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -93,8 +93,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_613_000 picoseconds.
Weight::from_parts(11_170_000, 0)
// Minimum execution time: 10_975_000 picoseconds.
Weight::from_parts(11_519_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -119,8 +119,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_818_000 picoseconds.
Weight::from_parts(11_183_000, 0)
// Minimum execution time: 10_729_000 picoseconds.
Weight::from_parts(11_195_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -135,8 +135,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 12_672_000 picoseconds.
Weight::from_parts(13_154_000, 0)
// Minimum execution time: 12_949_000 picoseconds.
Weight::from_parts(13_251_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -151,8 +151,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_814_000 picoseconds.
Weight::from_parts(11_120_000, 0)
// Minimum execution time: 10_683_000 picoseconds.
Weight::from_parts(11_196_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -167,8 +167,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 12_919_000 picoseconds.
Weight::from_parts(13_455_000, 0)
// Minimum execution time: 12_855_000 picoseconds.
Weight::from_parts(13_484_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -183,8 +183,8 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::configuration::Weight
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_495_000 picoseconds.
Weight::from_parts(11_189_000, 0)
// Minimum execution time: 10_933_000 picoseconds.
Weight::from_parts(11_367_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
Expand Down

0 comments on commit ac7037e

Please sign in to comment.