From c97d0493eb4f23e19ede4890e5984e0c5b00b0f5 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 20 Feb 2023 08:17:03 +0100 Subject: [PATCH 1/2] Benchmarks script improvements --- scripts/benchmarks-ci.sh | 77 +++++++++------------------------------- scripts/benchmarks.sh | 18 ++++++---- 2 files changed, 27 insertions(+), 68 deletions(-) diff --git a/scripts/benchmarks-ci.sh b/scripts/benchmarks-ci.sh index 09f3d536885..9a88719814e 100755 --- a/scripts/benchmarks-ci.sh +++ b/scripts/benchmarks-ci.sh @@ -1,70 +1,25 @@ #!/usr/bin/env bash -steps=50 -repeat=20 category=$1 runtimeName=$2 artifactsDir=$3 +steps=${4:-50} +repeat=${5:-20} benchmarkOutput=./parachains/runtimes/$category/$runtimeName/src/weights benchmarkRuntimeName="$runtimeName-dev" -if [[ $runtimeName == "statemint" ]] || [[ $runtimeName == "statemine" ]] || [[ $runtimeName == "westmint" ]]; then - pallets=( - pallet_assets - pallet_balances - pallet_collator_selection - pallet_multisig - pallet_proxy - pallet_session - pallet_timestamp - pallet_utility - pallet_uniques - cumulus_pallet_xcmp_queue - frame_system - pallet_xcm_benchmarks::generic - pallet_xcm_benchmarks::fungible - ) -elif [[ $runtimeName == "collectives-polkadot" ]]; then - pallets=( - pallet_alliance - pallet_balances - pallet_collator_selection - pallet_collective - pallet_multisig - pallet_proxy - pallet_session - pallet_timestamp - pallet_utility - cumulus_pallet_xcmp_queue - frame_system - ) -elif [[ $runtimeName == "bridge-hub-kusama" ]] || [[ $runtimeName == "bridge-hub-polkadot" ]]; then - pallets=( - frame_system - pallet_balances - pallet_collator_selection - pallet_multisig - pallet_session - pallet_timestamp - pallet_utility - cumulus_pallet_xcmp_queue - pallet_xcm_benchmarks::generic - pallet_xcm_benchmarks::fungible - ) -elif [[ $runtimeName == "bridge-hub-rococo" ]]; then - pallets=( - frame_system - pallet_balances - pallet_collator_selection - pallet_multisig - pallet_session - pallet_timestamp - pallet_utility - cumulus_pallet_xcmp_queue - pallet_xcm_benchmarks::generic - pallet_xcm_benchmarks::fungible - ) +# Load all pallet names in an array. +pallets=($( + ${artifactsDir}/polkadot-parachain benchmark pallet --list --chain="${benchmarkRuntimeName}" |\ + tail -n+2 |\ + cut -d',' -f1 |\ + sort |\ + uniq +)) + +if [ ${#pallets[@]} -ne 0 ]; then + echo "[+] Benchmarking ${#pallets[@]} pallets for runtime $runtime" else echo "$runtimeName pallet list not found in benchmarks-ci.sh" exit 1 @@ -75,10 +30,10 @@ do output_file="${pallet//::/_}" extra_args="" # a little hack for pallet_xcm_benchmarks - we want to force custom implementation for XcmWeightInfo - if [[ "$pallet" == "pallet_xcm_benchmarks::generic" ]] || [[ "$pallet" == "pallet_xcm_benchmarks::fungible" ]]; then + if [[ "$pallet" == "pallet_xcm_benchmarks::generic" ]] || [[ "$pallet" == "pallet_xcm_benchmarks::fungible" ]]; then output_file="xcm/$output_file" extra_args="--template=./templates/xcm-bench-template.hbs" - fi + fi $artifactsDir/polkadot-parachain benchmark pallet \ $extra_args \ --chain=$benchmarkRuntimeName \ @@ -91,4 +46,4 @@ do --json \ --header=./file_header.txt \ --output="${benchmarkOutput}/${output_file}.rs" >> $artifactsDir/${pallet}_benchmark.json -done +done \ No newline at end of file diff --git a/scripts/benchmarks.sh b/scripts/benchmarks.sh index 19fa54adb30..0db74102f24 100755 --- a/scripts/benchmarks.sh +++ b/scripts/benchmarks.sh @@ -1,13 +1,17 @@ #!/usr/bin/env bash +target=${1:-production} +steps=${2:-50} +repeat=${3:-20} + __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -${__dir}/benchmarks-ci.sh collectives collectives-polkadot target/production +${__dir}/benchmarks-ci.sh collectives collectives-polkadot target/$target $steps $repeat -${__dir}/benchmarks-ci.sh assets statemine target/production -${__dir}/benchmarks-ci.sh assets statemint target/production -${__dir}/benchmarks-ci.sh assets westmint target/production +${__dir}/benchmarks-ci.sh assets statemine target/$target $steps $repeat +${__dir}/benchmarks-ci.sh assets statemint target/$target $steps $repeat +${__dir}/benchmarks-ci.sh assets westmint target/$target $steps $repeat -${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-polkadot target/production -${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-kusama target/production -${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-rococo target/production +${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-polkadot target/$target $steps $repeat +${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-kusama target/$target $steps $repeat +${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-rococo target/$target $steps $repeat From d3bf0769a20d5513a7e1570e82147f2d3fa4501c Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 20 Feb 2023 08:22:47 +0100 Subject: [PATCH 2/2] EOF --- scripts/benchmarks-ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/benchmarks-ci.sh b/scripts/benchmarks-ci.sh index 9a88719814e..4b465400198 100755 --- a/scripts/benchmarks-ci.sh +++ b/scripts/benchmarks-ci.sh @@ -46,4 +46,4 @@ do --json \ --header=./file_header.txt \ --output="${benchmarkOutput}/${output_file}.rs" >> $artifactsDir/${pallet}_benchmark.json -done \ No newline at end of file +done