mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 08:41:02 +00:00
[ci] Upstream benchmark script changes from https://github.com/paritytech/substrate/pull/11493 (#5586)
* [ci] Upstream benchmark script changes from https://github.com/paritytech/substrate/pull/11493 * Update scripts/ci/run_benches_for_runtime.sh Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update scripts/ci/run_benches_for_runtime.sh Co-authored-by: Chevdor <chevdor@users.noreply.github.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
This commit is contained in:
@@ -1,54 +1,71 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Runs all benchmarks for all pallets, for a given runtime, provided by $1
|
# Runs all benchmarks for all pallets, for a given runtime, provided by $1
|
||||||
# Should be run on a reference machine to gain accurate benchmarks
|
# Should be run on a reference machine to gain accurate benchmarks
|
||||||
# current reference machine: https://github.com/paritytech/substrate/pull/5848
|
# current reference machine: https://github.com/paritytech/substrate/pull/5848
|
||||||
|
|
||||||
runtime="$1"
|
runtime="$1"
|
||||||
|
|
||||||
echo "[+] Running all benchmarks for $runtime"
|
echo "[+] Compiling benchmarks..."
|
||||||
|
cargo build --profile production --locked --features=runtime-benchmarks
|
||||||
|
|
||||||
cargo +nightly build --profile production --locked --features=runtime-benchmarks
|
# Load all pallet names in an array.
|
||||||
|
PALLETS=($(
|
||||||
|
./target/production/polkadot benchmark pallet --list --chain="${runtime}-dev" |\
|
||||||
|
tail -n+2 |\
|
||||||
|
cut -d',' -f1 |\
|
||||||
|
sort |\
|
||||||
|
uniq
|
||||||
|
))
|
||||||
|
|
||||||
./target/production/polkadot benchmark pallet \
|
echo "[+] Benchmarking ${#PALLETS[@]} pallets for runtime $runtime"
|
||||||
--chain "${runtime}-dev" \
|
|
||||||
--list |\
|
|
||||||
tail -n+2 |\
|
|
||||||
cut -d',' -f1 |\
|
|
||||||
uniq > "${runtime}_pallets"
|
|
||||||
|
|
||||||
# For each pallet found in the previous command, run benches on each function
|
# Define the error file.
|
||||||
while read -r line; do
|
ERR_FILE="benchmarking_errors.txt"
|
||||||
pallet="$(echo "$line" | cut -d' ' -f1)";
|
# Delete the error file before each run.
|
||||||
echo "Runtime: $runtime. Pallet: $pallet";
|
rm -f $ERR_FILE
|
||||||
# '!' has the side effect of bypassing errexit / set -e
|
|
||||||
! ./target/production/polkadot benchmark pallet \
|
# Benchmark each pallet.
|
||||||
|
for PALLET in "${PALLETS[@]}"; do
|
||||||
|
echo "[+] Benchmarking $PALLET for $runtime";
|
||||||
|
|
||||||
|
OUTPUT=$(
|
||||||
|
./target/production/polkadot benchmark pallet \
|
||||||
--chain="${runtime}-dev" \
|
--chain="${runtime}-dev" \
|
||||||
--steps=50 \
|
--steps=50 \
|
||||||
--repeat=20 \
|
--repeat=20 \
|
||||||
--pallet="$pallet" \
|
--pallet="$PALLET" \
|
||||||
--extrinsic="*" \
|
--extrinsic="*" \
|
||||||
--execution=wasm \
|
--execution=wasm \
|
||||||
--wasm-execution=compiled \
|
--wasm-execution=compiled \
|
||||||
--heap-pages=4096 \
|
|
||||||
--header=./file_header.txt \
|
--header=./file_header.txt \
|
||||||
--output="./runtime/${runtime}/src/weights/${pallet/::/_}.rs"
|
--output="./runtime/${runtime}/src/weights/${PALLET/::/_}.rs" 2>&1
|
||||||
done < "${runtime}_pallets"
|
)
|
||||||
rm "${runtime}_pallets"
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "$OUTPUT" >> "$ERR_FILE"
|
||||||
|
echo "[-] Failed to benchmark $PALLET. Error written to $ERR_FILE; continuing..."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Benchmark base weights
|
# Update the block and extrinsic overhead weights.
|
||||||
! ./target/production/polkadot benchmark overhead \
|
echo "[+] Benchmarking block and extrinsic overheads..."
|
||||||
|
OUTPUT=$(
|
||||||
|
./target/production/polkadot benchmark overhead \
|
||||||
--chain="${runtime}-dev" \
|
--chain="${runtime}-dev" \
|
||||||
--execution=wasm \
|
--execution=wasm \
|
||||||
--wasm-execution=compiled \
|
--wasm-execution=compiled \
|
||||||
--weight-path="runtime/${runtime}/constants/src/weights/" \
|
--weight-path="runtime/${runtime}/constants/src/weights/" \
|
||||||
--warmup=10 \
|
--warmup=10 \
|
||||||
--repeat=100
|
--repeat=100
|
||||||
|
)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "$OUTPUT" >> "$ERR_FILE"
|
||||||
|
echo "[-] Failed to benchmark the block and extrinsic overheads. Error written to $ERR_FILE; continuing..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the error file exists.
|
||||||
# This true makes sure that $? is 0 instead of
|
if [ -f "$ERR_FILE" ]; then
|
||||||
# carrying over a failure which would otherwise cause
|
echo "[-] Some benchmarks failed. See: $ERR_FILE"
|
||||||
# the whole CI job to abort.
|
else
|
||||||
true
|
echo "[+] All benchmarks passed."
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user