-
Éloïs authored
* add base block weights * db weights licence * remove unused import * fix base weights computation * force skip some warnings in weights module * force skip fmt on weights module * add storage benchmarks
Éloïs authored* add base block weights * db weights licence * remove unused import * fix base weights computation * force skip some warnings in weights module * force skip fmt on weights module * add storage benchmarks
weights-benchmarking.md 2.78 KiB
Weights benchmarking
What is the reference machine?
For now (09/2022), it's a Raspberry Pi 4 Model B - 4GB
with an SSD connected via USB3.
To cross-compile the benchmarks binary for armv7:
./scripts/cross-build-arm.sh --features runtime-benchmarks
The cross compiled binary is generated here: target/armv7-unknown-linux-gnueabihf/release/duniter
How to benchmarks weights of a Call/Hook/Pallet
- Create the benchmarking tests, see commit 31057e37 for a complete real example.
- Run the benchmark test on your local machine:
cargo test -p <pallet> --features runtime-benchmarks
- If the benchmark tests compiles and pass, compile the binary with benchmarks on your local
machine:
cargo build --release --features runtime-benchmarks
- Run the benchmarks on your local machine (to test if it work with a real runtime). The command
is:
duniter benchmark pallet --chain=CURRENCY-dev --steps=50 --repeat=20 --pallet=pallet_universal_dividend --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=.
- If it worked, use the generated file content to create or update the
WeightInfo
trait and the()
dummy implementation. Then use theWeightInfo
tarit in the real code of the pallet. See 79e0fd4b for a complete real example. - Redo steps
3.
and4.
on the reference machine. - Put the generated file on
runtime/common/src/weights
and use it in the runtimes configuration. See cee7c3b2 for a complete real example.
Note 1: You must replace CURRENCY
by the currency type, or for ĞDev use directly --chain=dev
.
Note 2: If the reference machine does not support wasmtime, you should replace --wasm-execution=compiled
by --wasm-execution=interpreted-i-know-what-i-do
.
Generate base block benchmarking
- Build binary for reference machine and copy it on reference machine.
- Run base block benchmarks command:
./duniter benchmark overhead --chain=gdev --execution=wasm --wasm-execution=interpreted-i-know-what-i-do --weight-path=. --warmup=10 --repeat=100
- Copy the generated file
block_weights.rs
in the codebase in folderruntime/common/src/weights/
. - Commit changes and open an MR.
Generate storage benchmarking
- Build binary for reference machine and copy it on reference machine.
- Copy a DB on reference machine (on ssd), example:
scp -r -P 37015 tmp/t1 pi@192.168.1.188:/mnt/ssd1/duniter-v2s/
- Run storage benchmarks command, example:
./duniter benchmark storage -d=/mnt/ssd1/duniter-v2s/t1 --chain=gdev --mul=2 --weight-path=. --state-version=1
- Copy the generated file
paritydb_weights.rs
in the codebase in folderruntime/common/src/weights/
. - Commit changes and open an MR.