mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
1b27ae9549
* initial impl * add template test * linear fit proof size * always record proof when tracking storage * calculate worst case pov * remove duplicate worst case * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_assets --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/assets/src/weights.rs --template=./.maintain/frame-weight-template.hbs * more comment output * add cli for worst case map size * update name * clap does not support underscores * rename * expose worst case map values * improve some comments * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_assets --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/assets/src/weights.rs --template=./.maintain/frame-weight-template.hbs * update template * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_assets --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/assets/src/weights.rs --template=./.maintain/frame-weight-template.hbs * fix fmt * more fmt * more fmt * Dont panic when there is no proof Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix test features Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Whitelist :extrinsic_index Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use whitelist when recording proof Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add logs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add PoV testing pallet Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Deploy PoV testing pallet Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Storage benches reside in the PoV pallet Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Linear regress PoV per component Splits the PoV calculation into "measured" and "estimated". The measured part is reported by the Proof recorder and linear regressed over all components at once. The estimated part is calculated as worst-case by using the max PoV size per storage access and calculating one linear regress per component. This gives each component a (possibly) independent PoV. For now the measured size will always be lower than the PoV on Polkadot since it is measured on an empty snapshot. The measured part is therefor only used as diagnostic for debugging. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Put PoV into the weight templates Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Extra alanysis choise for PoV Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add+Fix tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make benches faster Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Cleanup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use same template comments Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/bench-bot.sh" pallet dev pallet_balances * ".git/.scripts/bench-bot.sh" pallet dev pallet_democracy * Update referenda mock BlockWeights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Take measured value size into account Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/bench-bot.sh" pallet dev pallet_scheduler * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * proof_size: None Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ugly, but works Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * wup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add pov_mode attribute to the benchmarks! macro Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use pov_mode attribute in PoV benchmarking Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Scheduler, Whitelist: Add pov_mode attr Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update PoV weights * Add CLI arg: default-pov-mode Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fix Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Update PoV weights" This reverts commit 2f3ac2387396470b118122a6ff8fa4ee12216f4b. * Revert "WIP" This reverts commit c34b538cd2bc45da4544e887180184e30957904a. * Revert first approach This reverts commit range 8ddaa2fffe5930f225a30bee314d0b7c94c344dd^..4c84f8748e5395852a9e0e25b0404953fee1a59e Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add extra benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_alliance * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_whitelist * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_scheduler * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy 🤦 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add reference benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix doc comments Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Undo logging Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add 'Ignored' pov_mode Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Allow multiple attributes per benchmark Turns out that the current benchmarking syntax does not support multiple attributes per bench 🤦. Changing it to support that since otherwise the `pov_mode` would conflict with the others. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Validate pov_mode syntax Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Ignore PoV for all contract benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Bump macro recursion limit Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update contract weights They dont have a PoV component anymore. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fix test ffs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * pov_mode is unsupported in V2 syntax Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix pallet ui tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * update pallet ui Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix pallet ui tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <> Co-authored-by: Your Name <you@example.com>
169 lines
4.6 KiB
Bash
Executable File
169 lines
4.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This file is part of Substrate.
|
|
# Copyright (C) 2022 Parity Technologies (UK) Ltd.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# This script has three parts which all use the Substrate runtime:
|
|
# - Pallet benchmarking to update the pallet weights
|
|
# - Overhead benchmarking for the Extrinsic and Block weights
|
|
# - Machine benchmarking
|
|
#
|
|
# Should be run on a reference machine to gain accurate benchmarks
|
|
# current reference machine: https://github.com/paritytech/substrate/pull/5848
|
|
|
|
while getopts 'bfp:v' flag; do
|
|
case "${flag}" in
|
|
b)
|
|
# Skip build.
|
|
skip_build='true'
|
|
;;
|
|
f)
|
|
# Fail if any sub-command in a pipe fails, not just the last one.
|
|
set -o pipefail
|
|
# Fail on undeclared variables.
|
|
set -u
|
|
# Fail if any sub-command fails.
|
|
set -e
|
|
# Fail on traps.
|
|
set -E
|
|
;;
|
|
p)
|
|
# Start at pallet
|
|
start_pallet="${OPTARG}"
|
|
;;
|
|
v)
|
|
# Echo all executed commands.
|
|
set -x
|
|
;;
|
|
*)
|
|
# Exit early.
|
|
echo "Bad options. Check Script."
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
if [ "$skip_build" != true ]
|
|
then
|
|
echo "[+] Compiling Substrate benchmarks..."
|
|
cargo build --profile=production --locked --features=runtime-benchmarks
|
|
fi
|
|
|
|
# The executable to use.
|
|
SUBSTRATE=./target/production/substrate
|
|
|
|
# Manually exclude some pallets.
|
|
EXCLUDED_PALLETS=(
|
|
# Helper pallets
|
|
"pallet_election_provider_support_benchmarking"
|
|
# Pallets without automatic benchmarking
|
|
"pallet_babe"
|
|
"pallet_grandpa"
|
|
"pallet_mmr"
|
|
"pallet_offences"
|
|
# Only used for testing, does not need real weights.
|
|
"frame_benchmarking_pallet_pov"
|
|
)
|
|
|
|
# Load all pallet names in an array.
|
|
ALL_PALLETS=($(
|
|
$SUBSTRATE benchmark pallet --list --chain=dev |\
|
|
tail -n+2 |\
|
|
cut -d',' -f1 |\
|
|
sort |\
|
|
uniq
|
|
))
|
|
|
|
# Filter out the excluded pallets by concatenating the arrays and discarding duplicates.
|
|
PALLETS=($({ printf '%s\n' "${ALL_PALLETS[@]}" "${EXCLUDED_PALLETS[@]}"; } | sort | uniq -u))
|
|
|
|
echo "[+] Benchmarking ${#PALLETS[@]} Substrate pallets by excluding ${#EXCLUDED_PALLETS[@]} from ${#ALL_PALLETS[@]}."
|
|
|
|
# Define the error file.
|
|
ERR_FILE="benchmarking_errors.txt"
|
|
# Delete the error file before each run.
|
|
rm -f $ERR_FILE
|
|
|
|
# Benchmark each pallet.
|
|
for PALLET in "${PALLETS[@]}"; do
|
|
# If `-p` is used, skip benchmarks until the start pallet.
|
|
if [ ! -z "$start_pallet" ] && [ "$start_pallet" != "$PALLET" ]
|
|
then
|
|
echo "[+] Skipping ${PALLET}..."
|
|
continue
|
|
else
|
|
unset start_pallet
|
|
fi
|
|
|
|
FOLDER="$(echo "${PALLET#*_}" | tr '_' '-')";
|
|
WEIGHT_FILE="./frame/${FOLDER}/src/weights.rs"
|
|
echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE";
|
|
|
|
OUTPUT=$(
|
|
$SUBSTRATE benchmark pallet \
|
|
--chain=dev \
|
|
--steps=50 \
|
|
--repeat=20 \
|
|
--pallet="$PALLET" \
|
|
--extrinsic="*" \
|
|
--execution=wasm \
|
|
--wasm-execution=compiled \
|
|
--heap-pages=4096 \
|
|
--output="$WEIGHT_FILE" \
|
|
--header="./HEADER-APACHE2" \
|
|
--template=./.maintain/frame-weight-template.hbs 2>&1
|
|
)
|
|
if [ $? -ne 0 ]; then
|
|
echo "$OUTPUT" >> "$ERR_FILE"
|
|
echo "[-] Failed to benchmark $PALLET. Error written to $ERR_FILE; continuing..."
|
|
fi
|
|
done
|
|
|
|
# Update the block and extrinsic overhead weights.
|
|
echo "[+] Benchmarking block and extrinsic overheads..."
|
|
OUTPUT=$(
|
|
$SUBSTRATE benchmark overhead \
|
|
--chain=dev \
|
|
--execution=wasm \
|
|
--wasm-execution=compiled \
|
|
--weight-path="./frame/support/src/weights/" \
|
|
--header="./HEADER-APACHE2" \
|
|
--warmup=10 \
|
|
--repeat=100 2>&1
|
|
)
|
|
if [ $? -ne 0 ]; then
|
|
echo "$OUTPUT" >> "$ERR_FILE"
|
|
echo "[-] Failed to benchmark the block and extrinsic overheads. Error written to $ERR_FILE; continuing..."
|
|
fi
|
|
|
|
echo "[+] Benchmarking the machine..."
|
|
OUTPUT=$(
|
|
$SUBSTRATE benchmark machine --chain=dev 2>&1
|
|
)
|
|
if [ $? -ne 0 ]; then
|
|
# Do not write the error to the error file since it is not a benchmarking error.
|
|
echo "[-] Failed the machine benchmark:\n$OUTPUT"
|
|
fi
|
|
|
|
# Check if the error file exists.
|
|
if [ -f "$ERR_FILE" ]; then
|
|
echo "[-] Some benchmarks failed. See: $ERR_FILE"
|
|
exit 1
|
|
else
|
|
echo "[+] All benchmarks passed."
|
|
exit 0
|
|
fi
|