Skip to content
Commit 1b27ae95 authored by Shawn Tabrizi's avatar Shawn Tabrizi Committed by GitHub
Browse files

Add Proof Size to Weight Output (#11637)



* 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: default avatarOliver Tale-Yazdi <[email protected]>

* Fix test features

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Whitelist :extrinsic_index

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Use whitelist when recording proof

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Add logs

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Add PoV testing pallet

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Deploy PoV testing pallet

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Storage benches reside in the PoV pallet

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* 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: default avatarOliver Tale-Yazdi <[email protected]>

* Put PoV into the weight templates

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* fmt

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Extra alanysis choise for PoV

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Add+Fix tests

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Make benches faster

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Cleanup

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Use same template comments

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* ".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: default avatarOliver Tale-Yazdi <[email protected]>

* Take measured value size into account

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* clippy

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* ".git/.scripts/bench-bot.sh" pallet dev pallet_scheduler

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* proof_size: None

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* ugly, but works

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* wup

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* WIP

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Add pov_mode attribute to the benchmarks! macro

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Use pov_mode attribute in PoV benchmarking

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Update tests

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Scheduler, Whitelist: Add pov_mode attr

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Update PoV weights

* Add CLI arg: default-pov-mode

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Fix tests

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* fmt

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* fix

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* 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: default avatarOliver Tale-Yazdi <[email protected]>

* Clippy

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Add extra benchmarks

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* ".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: default avatarOliver Tale-Yazdi <[email protected]>

* Clippy

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Clippy 🤦



Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Add reference benchmarks

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Fix doc comments

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Undo logging

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Add 'Ignored' pov_mode

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* 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: default avatarOliver Tale-Yazdi <[email protected]>

* Validate pov_mode syntax

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Ignore PoV for all contract benchmarks

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Test

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* test

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Bump macro recursion limit

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* fmt

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Update contract weights

They dont have a PoV component anymore.

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* fix test ffs

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* pov_mode is unsupported in V2 syntax

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Fix pallet ui tests

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* update pallet ui

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Fix pallet ui tests

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

* Update weights

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>

Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
Co-authored-by: default avatarParity Bot <[email protected]>
Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
Co-authored-by: command-bot <>
Co-authored-by: default avatarYour Name <[email protected]>
parent 41f819eb
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment