Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame Omni Bencher integration #1319

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ Latest commit hash in PR branch will be built and used for benchmarking.
### How to execute
Usage
```
# [chain names] - Use "," for multiple runtimes. Available values are: astar-dev, shiden-dev, shibuya-dev, dev
# [chain names] - Use "," for multiple runtimes. Available values are: astar, shiden, shibuya
# [pallet names] - Use "," for multiple pallets, "all" for all pallets
/bench [chain names] [pallet names]
```
```
# benchmark a pallet
/bench astar-dev pallet_balances
/bench astar pallet_balances

# benchmark multiple pallets
/bench astar-dev pallet_balances,pallet_dapps_staking
/bench astar pallet_balances,pallet_dapps_staking

# benchmark all pallets
/bench astar-dev all
/bench astar all

# benchmark multiple runtimes with multiple pallets
/bench astar-dev,shibuya-dev pallet_balances,pallet_dapps_staking
/bench astar,shibuya pallet_balances,pallet_dapps_staking
```


Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ jobs:
- name: Check targets are installed correctly
run: rustup target list --installed

- name: Install frame-omni bencher tool
run: cargo install frame-omni-bencher

- name: Execute benchmarking
run: |
mkdir -p ./benchmark-results
Expand Down
36 changes: 20 additions & 16 deletions scripts/run_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ while getopts 'bc:fo:p:v' flag; do
;;
c)
chains=$(echo ${OPTARG} | tr '[:upper:]' '[:lower:]')
chains_default=("astar-dev" "shiden-dev" "shibuya-dev" "dev")
chains_default=("astar" "shiden" "shibuya")
for chain in ${chains//,/ }; do
if [[ ! " ${chains_default[*]} " =~ " ${chain} " ]]; then
echo "Chain input is invalid. ${chain} not included in ${chains_default[*]}"
Expand Down Expand Up @@ -73,11 +73,12 @@ done
if [ "$skip_build" != true ]
then
echo "[+] Compiling astar-collator benchmarks..."
CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="-C codegen-units=1" cargo build --release --verbose --features=runtime-benchmarks
CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="-C codegen-units=1" cargo build --release --verbose --features=runtime-benchmarks \
-p astar-runtime -p shiden-runtime -p shibuya-runtime
fi

# The executable to use.
ASTAR_COLLATOR=./target/release/astar-collator
BENCHMARK_TOOL="frame-omni-bencher v1"

# Manually exclude some pallets.
EXCLUDED_PALLETS=(
Expand All @@ -86,7 +87,7 @@ EXCLUDED_PALLETS=(

# Load all pallet names in an array.
ALL_PALLETS=($(
$ASTAR_COLLATOR benchmark pallet --list --chain=$chain |\
$BENCHMARK_TOOL benchmark pallet --list --runtime ./target/release/wbuild/${chain}-runtime/${chain}_runtime.compact.compressed.wasm |\
tail -n+2 |\
cut -d',' -f1 |\
sort |\
Expand Down Expand Up @@ -120,8 +121,8 @@ for chain in ${chains//,/ }; do
echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE";

OUTPUT=$(
$ASTAR_COLLATOR benchmark pallet \
--chain=$chain \
$BENCHMARK_TOOL benchmark pallet \
--runtime ./target/release/wbuild/${chain}-runtime/${chain}_runtime.compact.compressed.wasm \
--steps=50 \
--repeat=20 \
--pallet="$PALLET" \
Expand All @@ -137,16 +138,19 @@ for chain in ${chains//,/ }; do
fi
done

echo "[+] Benchmarking the machine..."
OUTPUT=$(
$ASTAR_COLLATOR benchmark machine --chain=$chain 2>&1
)
if [ $? -ne 0 ]; then
echo "[-] Failed the machine benchmark"
echo "$OUTPUT" >> "$ERR_FILE"
else
echo "$OUTPUT" >> "$output_path/$chain/$chain-machine-bench.txt"
fi
# Disabled for now - command isn't available (yet).
# With latest changes we also benchmark the HW each time the client starts.
#
# echo "[+] Benchmarking the machine..."
# OUTPUT=$(
# $BENCHMARK_TOOL benchmark machine --runtime ./target/release/wbuild/astar-runtime/${chain}_runtime.compact.compressed.wasm 2>&1
# )
# if [ $? -ne 0 ]; then
# echo "[-] Failed the machine benchmark"
# echo "$OUTPUT" >> "$ERR_FILE"
# else
# echo "$OUTPUT" >> "$output_path/$chain/$chain-machine-bench.txt"
# fi

# Check if the error file exists.
if [ -f "$ERR_FILE" ]; then
Expand Down
Loading