Skip to content

Commit

Permalink
runtime-benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed Aug 30, 2024
1 parent 0905da2 commit 0a26d75
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 32 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
33 changes: 16 additions & 17 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: `10`, REPEAT: `5`, 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
//! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-paseo-local")`, DB CACHE: 1024

// Executed Command:
// ./target/production/polimec-node
// 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=10
// --repeat=5
// --output=./runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand Down Expand Up @@ -46,13 +45,13 @@ 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: 2_000_000 picoseconds.
Weight::from_parts(2_000_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()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(4))
// Standard Error: 4_978_022
.saturating_add(Weight::from_parts(190_485_071, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
}
}

0 comments on commit 0a26d75

Please sign in to comment.