Add benchmarking for parachain runtime paras pallet (#3888)

* Crate basic barebones benchmarking infrastructure for paras

* Fill in benchmarking contents

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

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

* Use autogenerated WeightInfos for kusama and westend

* cargo fmt

* Use saturating_sub

* Add missing import

* Try and hit the worst possible time complexity as much as possible

* cargo fmt

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

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

* Add a MAX_HEAD_DATA_SIZE constant

* Prefill vectors with sample data for worst case complexity

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

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

* Improve comment on SAMPLE_SIZE constant

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Keith Yeung
2021-09-21 18:14:12 -07:00
committed by GitHub
parent 5bbcb665d9
commit db0b7e0048
16 changed files with 493 additions and 6 deletions
@@ -22,7 +22,7 @@ use crate::shared;
use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_PER_MILLIS};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode};
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_POV_SIZE};
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE};
use sp_runtime::traits::Zero;
use sp_std::prelude::*;
@@ -256,6 +256,13 @@ impl<BlockNumber: Zero> HostConfiguration<BlockNumber> {
)
}
if self.max_head_data_size > MAX_HEAD_DATA_SIZE {
panic!(
"`max_head_data_size` ({}) is bigger than allowed by the client ({})",
self.max_head_data_size, MAX_HEAD_DATA_SIZE
)
}
if self.max_pov_size > MAX_POV_SIZE {
panic!("`max_pov_size` is bigger than allowed by the client")
}
@@ -390,6 +397,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::set_config_with_u32())]
pub fn set_max_head_data_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_HEAD_DATA_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_head_data_size, new) != new
});