Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add benchmarking to rococo; Remove weights from runtime_parachains (#…
Browse files Browse the repository at this point in the history
…3914)

* Add benchmarking to rococo; Remove weights from runtime_parachains

* cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs --header=./file_header.txt

* Impl TestWeightInfo for Paras and Configuration

* fmt

* cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::configuration --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_configuration.rs --header=./file_header.txt

* Fix CI complaint: error: unused variable: `c`

* polkadot-runtime-common & polkadot-test-runtime compile

* xcm-simulator compile

* change TestWeightInfo to max_block

* cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs --header=./file_header.txt

* ordering

* cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs --header=./file_header.txt

* Replace max_block with Weight::MAX

Co-authored-by: Parity Bot <[email protected]>
Co-authored-by: Keith Yeung <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2021
1 parent 8216c79 commit c764a21
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 60 deletions.
4 changes: 2 additions & 2 deletions runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ impl pallet_balances::Config for Test {
}

impl configuration::Config for Test {
type WeightInfo = configuration::weights::WeightInfo<Test>;
type WeightInfo = configuration::TestWeightInfo;
}

impl shared::Config for Test {}

impl paras::Config for Test {
type Origin = Origin;
type Event = Event;
type WeightInfo = paras::weights::WeightInfo<Test>;
type WeightInfo = paras::TestWeightInfo;
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,11 @@ mod tests {
impl paras::Config for Test {
type Origin = Origin;
type Event = Event;
type WeightInfo = paras::weights::WeightInfo<Test>;
type WeightInfo = paras::TestWeightInfo;
}

impl configuration::Config for Test {
type WeightInfo = configuration::weights::WeightInfo<Test>;
type WeightInfo = configuration::TestWeightInfo;
}

parameter_types! {
Expand Down
23 changes: 22 additions & 1 deletion runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use sp_std::prelude::*;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pub mod weights;

pub use pallet::*;

Expand Down Expand Up @@ -278,6 +277,28 @@ pub trait WeightInfo {
fn set_hrmp_open_request_ttl() -> Weight;
}

pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn set_config_with_block_number() -> Weight {
Weight::MAX
}
fn set_config_with_u32() -> Weight {
Weight::MAX
}
fn set_config_with_option_u32() -> Weight {
Weight::MAX
}
fn set_config_with_weight() -> Weight {
Weight::MAX
}
fn set_config_with_balance() -> Weight {
Weight::MAX
}
fn set_hrmp_open_request_ttl() -> Weight {
Weight::MAX
}
}

#[frame_support::pallet]
pub mod pallet {
use super::*;
Expand Down
4 changes: 2 additions & 2 deletions runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ impl crate::initializer::Config for Test {
}

impl crate::configuration::Config for Test {
type WeightInfo = crate::configuration::weights::WeightInfo<Test>;
type WeightInfo = crate::configuration::TestWeightInfo;
}

impl crate::shared::Config for Test {}

impl crate::paras::Config for Test {
type Origin = Origin;
type Event = Event;
type WeightInfo = crate::paras::weights::WeightInfo<Test>;
type WeightInfo = crate::paras::TestWeightInfo;
}

impl crate::dmp::Config for Test {}
Expand Down
20 changes: 19 additions & 1 deletion runtime/parachains/src/paras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub use crate::Origin as ParachainOrigin;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pub mod weights;

pub use pallet::*;

Expand Down Expand Up @@ -279,6 +278,25 @@ pub trait WeightInfo {
fn force_queue_action() -> Weight;
}

pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn force_set_current_code(_c: u32) -> Weight {
Weight::MAX
}
fn force_set_current_head(_s: u32) -> Weight {
Weight::MAX
}
fn force_schedule_code_upgrade(_c: u32) -> Weight {
Weight::MAX
}
fn force_note_new_head(_s: u32) -> Weight {
Weight::MAX
}
fn force_queue_action() -> Weight {
Weight::MAX
}
}

#[frame_support::pallet]
pub mod pallet {
use super::*;
Expand Down
8 changes: 6 additions & 2 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ impl pallet_authorship::Config for Runtime {
impl parachains_origin::Config for Runtime {}

impl parachains_configuration::Config for Runtime {
type WeightInfo = parachains_configuration::weights::WeightInfo<Runtime>;
type WeightInfo = weights::runtime_parachains_configuration::WeightInfo<Runtime>;
}

impl parachains_shared::Config for Runtime {}
Expand All @@ -599,7 +599,7 @@ impl parachains_inclusion::Config for Runtime {
impl parachains_paras::Config for Runtime {
type Origin = Origin;
type Event = Event;
type WeightInfo = parachains_paras::weights::WeightInfo<Runtime>;
type WeightInfo = weights::runtime_parachains_paras::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -1599,7 +1599,9 @@ sp_api::impl_runtime_apis! {

let mut list = Vec::<BenchmarkList>::new();

list_benchmark!(list, extra, runtime_parachains::configuration, Configuration);
list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes);
list_benchmark!(list, extra, runtime_parachains::paras, Paras);

let storage_info = AllPalletsWithSystem::storage_info();

Expand Down Expand Up @@ -1629,7 +1631,9 @@ sp_api::impl_runtime_apis! {
];
let params = (&config, &whitelist);

add_benchmark!(params, batches, runtime_parachains::configuration, Configuration);
add_benchmark!(params, batches, runtime_parachains::disputes, ParasDisputes);
add_benchmark!(params, batches, runtime_parachains::paras, Paras);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down
19 changes: 19 additions & 0 deletions runtime/rococo/src/weights/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
// Copyright (C) 2020 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.

//! A list of the different weight modules for our runtime.
pub mod runtime_parachains_configuration;
pub mod runtime_parachains_disputes;
pub mod runtime_parachains_paras;
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `runtime_parachains::configuration`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128
//! DATE: 2021-09-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 128
// Executed Command:
// ./target/release/polkadot
// target/release/polkadot
// benchmark
// --chain
// westend-dev
// --chain=rococo-dev
// --steps=50
// --repeat=20
// --pallet=runtime_parachains::configuration
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --pallet
// runtime_parachains::configuration
// --steps
// 50
// --repeat
// 20
// --raw
// --extrinsic
// *
// --output
// runtime/parachains/src/configuration/weights.rs
// --heap-pages=4096
// --output=./runtime/rococo/src/weights/runtime_parachains_configuration.rs
// --header=./file_header.txt


#![cfg_attr(rustfmt, rustfmt_skip)]
Expand All @@ -34,36 +43,36 @@ use sp_std::marker::PhantomData;

/// Weight functions for `runtime_parachains::configuration`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> super::WeightInfo for WeightInfo<T> {
impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> {
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0)
fn set_config_with_block_number() -> Weight {
(16_730_000 as Weight)
(13_098_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0)
fn set_config_with_u32() -> Weight {
(16_592_000 as Weight)
(13_216_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0)
fn set_config_with_option_u32() -> Weight {
(16_419_000 as Weight)
(13_080_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0)
fn set_config_with_weight() -> Weight {
(16_732_000 as Weight)
(13_178_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
Expand All @@ -75,7 +84,7 @@ impl<T: frame_system::Config> super::WeightInfo for WeightInfo<T> {
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0)
fn set_config_with_balance() -> Weight {
(16_752_000 as Weight)
(13_080_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `runtime_parachains::paras`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-09-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128
//! DATE: 2021-09-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 128
// Executed Command:
// ./target/release/polkadot
// target/release/polkadot
// benchmark
// --chain
// westend-dev
// --chain=rococo-dev
// --steps=50
// --repeat=20
// --pallet=runtime_parachains::paras
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --pallet
// runtime_parachains::paras
// --steps
// 50
// --repeat
// 20
// --raw
// --extrinsic
// *
// --output
// runtime/parachains/src/paras/weights.rs
// --heap-pages=4096
// --output=./runtime/rococo/src/weights/runtime_parachains_paras.rs
// --header=./file_header.txt


#![cfg_attr(rustfmt, rustfmt_skip)]
Expand All @@ -34,25 +43,25 @@ use sp_std::marker::PhantomData;

/// Weight functions for `runtime_parachains::paras`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> super::WeightInfo for WeightInfo<T> {
impl<T: frame_system::Config> runtime_parachains::paras::WeightInfo for WeightInfo<T> {
// Storage: Paras CurrentCodeHash (r:1 w:1)
// Storage: Paras CodeByHashRefs (r:1 w:1)
// Storage: Paras PastCodeMeta (r:1 w:1)
// Storage: Paras PastCodePruning (r:1 w:1)
// Storage: Paras PastCodeHash (r:0 w:1)
// Storage: Paras CodeByHash (r:0 w:1)
fn force_set_current_code(c: u32, ) -> Weight {
(14_669_000 as Weight)
(0 as Weight)
// Standard Error: 0
.saturating_add((3_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Paras Heads (r:0 w:1)
fn force_set_current_head(s: u32, ) -> Weight {
(0 as Weight)
(18_653_000 as Weight)
// Standard Error: 0
.saturating_add((2_000 as Weight).saturating_mul(s as Weight))
.saturating_add((1_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Configuration ActiveConfig (r:1 w:0)
Expand All @@ -65,7 +74,7 @@ impl<T: frame_system::Config> super::WeightInfo for WeightInfo<T> {
// Storage: Paras FutureCodeHash (r:0 w:1)
// Storage: Paras UpgradeRestrictionSignal (r:0 w:1)
fn force_schedule_code_upgrade(c: u32, ) -> Weight {
(37_383_000 as Weight)
(0 as Weight)
// Standard Error: 0
.saturating_add((3_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
Expand All @@ -81,16 +90,16 @@ impl<T: frame_system::Config> super::WeightInfo for WeightInfo<T> {
// Storage: Paras PastCodeHash (r:0 w:1)
// Storage: Paras UpgradeGoAheadSignal (r:0 w:1)
fn force_note_new_head(s: u32, ) -> Weight {
(60_855_000 as Weight)
(69_515_000 as Weight)
// Standard Error: 0
.saturating_add((2_000 as Weight).saturating_mul(s as Weight))
.saturating_add((1_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(9 as Weight))
}
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
// Storage: Paras ActionsQueue (r:1 w:1)
fn force_queue_action() -> Weight {
(32_014_000 as Weight)
(26_804_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
Expand Down
Loading

0 comments on commit c764a21

Please sign in to comment.