Skip to content

Commit

Permalink
runtime-benchmarks (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios authored Sep 3, 2024
1 parent 56918d4 commit bd6303c
Show file tree
Hide file tree
Showing 26 changed files with 2,075 additions and 1,462 deletions.
49 changes: 36 additions & 13 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,42 @@ dry-run-benchmarks mode="fast-mode" pallet="*" extrinsic="*" :
--heap-pages=4096
done

# src: https://github.com/polkadot-fellows/runtimes/blob/48ccfae6141d2924f579d81e8b1877efd208693f/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs
# Benchmark a specific pallet on the "Polimec" Runtime
# Use mode="production" to generate production weights.
benchmark-runtime chain="polimec-paseo-local" pallet="pallet-elections-phragmen" mode="release":
cargo run --features runtime-benchmarks --profile {{mode}} -p polimec-node benchmark pallet \
--chain={{ chain }} \
--steps=50 \
--repeat=20 \
--pallet={{ pallet }} \
--extrinsic=* \
--wasm-execution=compiled \
--heap-pages=4096 \
--output=runtimes/polimec/src/weights/{{ replace(pallet, "-", "_") }}.rs
benchmark-runtime:
#!/bin/bash
steps=${4:-50}
repeat=${5:-20}

weightsDir=./runtimes/polimec/src/weights
chainSpec="polimec-paseo-local"
benchmarkCommand="./target/production/polimec-node benchmark pallet"


cargo run --features runtime-benchmarks --profile=production -p polimec-node benchmark pallet
# Load all pallet names in an array.
pallets=($(
${benchmarkCommand} --list --chain=${chainSpec} |\
tail -n+2 |\
cut -d',' -f1 |\
sort |\
uniq
))

echo "[+] Benchmarking ${#pallets[@]} pallets"

for pallet in ${pallets[@]}
do
output_pallet=$(echo $pallet | tr '-' '_')
echo $output_pallet
${benchmarkCommand} \
--chain=${chainSpec} \
--wasm-execution=compiled \
--pallet=$pallet \
--extrinsic='*' \
--steps=$steps \
--repeat=$repeat \
--output=$weightsDir/$output_pallet.rs

done

# src: https://github.com/paritytech/polkadot-sdk/blob/bc2e5e1fe26e2c2c8ee766ff9fe7be7e212a0c62/substrate/frame/nfts/src/weights.rs
# Run the Runtime benchmarks for a specific pallet
Expand Down
4 changes: 2 additions & 2 deletions runtimes/polimec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,8 +1488,8 @@ impl_runtime_apis! {

use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
use xcm::latest::prelude::*;
/// TODO: Update these benchmarks once we enable PLMC Teleportation and upgrade pallet_xcm. New version has
/// a better and quite different trait
// TODO: Update these benchmarks once we enable PLMC Teleportation and upgrade pallet_xcm. New version has
// a better and quite different trait
parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
xcm_config::HereLocation::get(),
Expand Down
25 changes: 12 additions & 13 deletions runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@

//! Autogenerated weights for `cumulus_pallet_parachain_system`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-04-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 39.0.0
//! DATE: 2024-08-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ip-172-31-23-147`, CPU: `AMD EPYC 9R14`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-local")`, DB CACHE: 1024
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-paseo-local")`, DB CACHE: 1024

// Executed Command:
// ./target/production/polimec-node
// benchmark
// pallet
// --chain=polimec-local
// --steps=50
// --repeat=20
// --chain=polimec-paseo-local
// --wasm-execution=compiled
// --pallet=cumulus_pallet_parachain_system
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --output=runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs
// --steps=50
// --repeat=20
// --output=./runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand Down Expand Up @@ -46,11 +45,11 @@ impl<T: frame_system::Config> cumulus_pallet_parachain_system::WeightInfo for We
// Proof Size summary in bytes:
// Measured: `12`
// Estimated: `3517`
// Minimum execution time: 2_060_000 picoseconds.
Weight::from_parts(2_150_000, 0)
// Minimum execution time: 1_990_000 picoseconds.
Weight::from_parts(2_090_000, 0)
.saturating_add(Weight::from_parts(0, 3517))
// Standard Error: 19_164
.saturating_add(Weight::from_parts(169_295_388, 0).saturating_mul(n.into()))
// Standard Error: 21_455
.saturating_add(Weight::from_parts(187_017_461, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
Expand Down
75 changes: 37 additions & 38 deletions runtimes/polimec/src/weights/cumulus_pallet_xcmp_queue.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@

//! Autogenerated weights for `cumulus_pallet_xcmp_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-04-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 39.0.0
//! DATE: 2024-08-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ip-172-31-23-147`, CPU: `AMD EPYC 9R14`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-local")`, DB CACHE: 1024
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-paseo-local")`, DB CACHE: 1024

// Executed Command:
// ./target/production/polimec-node
// benchmark
// pallet
// --chain=polimec-local
// --steps=50
// --repeat=20
// --chain=polimec-paseo-local
// --wasm-execution=compiled
// --pallet=cumulus_pallet_xcmp_queue
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --output=runtimes/polimec/src/weights/cumulus_pallet_xcmp_queue.rs
// --steps=50
// --repeat=20
// --output=./runtimes/polimec/src/weights/cumulus_pallet_xcmp_queue.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -32,67 +31,67 @@ use core::marker::PhantomData;
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> cumulus_pallet_xcmp_queue::WeightInfo for WeightInfo<T> {
/// Storage: `XcmpQueue::QueueConfig` (r:1 w:1)
/// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`)
fn set_config_with_u32() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `1594`
// Minimum execution time: 4_040_000 picoseconds.
Weight::from_parts(4_200_000, 0)
.saturating_add(Weight::from_parts(0, 1594))
// Estimated: `1497`
// Minimum execution time: 3_850_000 picoseconds.
Weight::from_parts(4_090_000, 0)
.saturating_add(Weight::from_parts(0, 1497))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmpQueue::QueueConfig` (r:1 w:0)
/// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
/// Storage: `XcmpQueue::InboundXcmpSuspended` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `XcmpQueue::InboundXcmpSuspended` (`max_values`: Some(1), `max_size`: Some(4002), added: 4497, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:0 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65585), added: 68060, mode: `MaxEncodedLen`)
fn enqueue_xcmp_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `115`
// Estimated: `3517`
// Minimum execution time: 10_010_000 picoseconds.
Weight::from_parts(10_320_000, 0)
.saturating_add(Weight::from_parts(0, 3517))
// Estimated: `5487`
// Minimum execution time: 9_630_000 picoseconds.
Weight::from_parts(10_170_000, 0)
.saturating_add(Weight::from_parts(0, 5487))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
fn suspend_channel() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `1594`
// Minimum execution time: 2_800_000 picoseconds.
Weight::from_parts(2_900_000, 0)
.saturating_add(Weight::from_parts(0, 1594))
// Estimated: `2767`
// Minimum execution time: 2_780_000 picoseconds.
Weight::from_parts(3_020_000, 0)
.saturating_add(Weight::from_parts(0, 2767))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
fn resume_channel() -> Weight {
// Proof Size summary in bytes:
// Measured: `144`
// Estimated: `1629`
// Minimum execution time: 3_750_000 picoseconds.
Weight::from_parts(3_980_000, 0)
.saturating_add(Weight::from_parts(0, 1629))
// Estimated: `2767`
// Minimum execution time: 3_560_000 picoseconds.
Weight::from_parts(3_850_000, 0)
.saturating_add(Weight::from_parts(0, 2767))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
fn take_first_concatenated_xcm() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 60_200_000 picoseconds.
Weight::from_parts(60_431_000, 0)
// Minimum execution time: 5_560_000 picoseconds.
Weight::from_parts(5_690_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: UNKNOWN KEY `0x7b3237373ffdfeb1cab4222e3b520d6b345d8e88afa015075c945637c07e8f20` (r:1 w:1)
Expand All @@ -104,17 +103,17 @@ impl<T: frame_system::Config> cumulus_pallet_xcmp_queue::WeightInfo for WeightIn
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
/// Storage: `XcmpQueue::QueueConfig` (r:1 w:0)
/// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`)
/// Storage: `XcmpQueue::InboundXcmpSuspended` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `XcmpQueue::InboundXcmpSuspended` (`max_values`: Some(1), `max_size`: Some(4002), added: 4497, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:0 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65585), added: 68060, mode: `MaxEncodedLen`)
fn on_idle_good_msg() -> Weight {
// Proof Size summary in bytes:
// Measured: `65744`
// Estimated: `69209`
// Minimum execution time: 96_810_000 picoseconds.
Weight::from_parts(102_230_000, 0)
// Minimum execution time: 100_270_000 picoseconds.
Weight::from_parts(103_031_000, 0)
.saturating_add(Weight::from_parts(0, 69209))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(5))
Expand All @@ -127,8 +126,8 @@ impl<T: frame_system::Config> cumulus_pallet_xcmp_queue::WeightInfo for WeightIn
// Proof Size summary in bytes:
// Measured: `65743`
// Estimated: `69208`
// Minimum execution time: 43_200_000 picoseconds.
Weight::from_parts(44_860_000, 0)
// Minimum execution time: 38_800_000 picoseconds.
Weight::from_parts(41_200_000, 0)
.saturating_add(Weight::from_parts(0, 69208))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
Expand Down
Loading

0 comments on commit bd6303c

Please sign in to comment.