From 561d2402447fed02f583524f8e54e41a2480c57d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 29 Aug 2024 15:59:32 +0200 Subject: [PATCH] runtime-benchmarks --- justfile | 48 ++++++++++++++----- runtimes/polimec/src/lib.rs | 4 +- .../cumulus_pallet_parachain_system.rs | 33 +++++++------ 3 files changed, 53 insertions(+), 32 deletions(-) diff --git a/justfile b/justfile index 8c45bf550..f63a1e39f 100644 --- a/justfile +++ b/justfile @@ -41,19 +41,41 @@ 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:-10} + repeat=${5:-5} + + weightsDir=./runtimes/polimec/src/weights + chainSpec="polimec-paseo-local" + runtime="./target/release/wbuild/polimec-runtime/polimec_runtime.wasm" + binaryRun="cargo run --features runtime-benchmarks --profile=production -p polimec-node benchmark pallet" + + # Load all pallet names in an array. + pallets=($( + ${binaryRun} --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 + ${binaryRun} \ + --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 diff --git a/runtimes/polimec/src/lib.rs b/runtimes/polimec/src/lib.rs index 7a701ab37..6d57a77ed 100644 --- a/runtimes/polimec/src/lib.rs +++ b/runtimes/polimec/src/lib.rs @@ -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 = Some(( xcm_config::HereLocation::get(), diff --git a/runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs b/runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs index a4a264aa9..1ea572d81 100644 --- a/runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs +++ b/runtimes/polimec/src/weights/cumulus_pallet_parachain_system.rs @@ -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: `` +//! 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)] @@ -46,13 +45,13 @@ impl 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()))) } }