-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Improve usability of add
+list_benchmark!
#10592
Improve usability of add
+list_benchmark!
#10592
Conversation
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This looks good in general, but I would prefer a backwards compatible PR, rather than forcing everyone into this way of things. That probably means just keeping the existing macro as is, and changing the name of the new macro you created to something like |
It is backwards-compatible 😄 but the naming is a bit sneaky. Also what do you think about the boilerplate code, should I put it inside the macro or not? This specifically: #[macro_use]
extern crate frame_benchmarking;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
} |
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This reverts commit 82ea52f.
@@ -1385,6 +1385,51 @@ mod mmr { | |||
pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing; | |||
} | |||
|
|||
#[cfg(feature = "runtime-benchmarks")] | |||
#[macro_use] | |||
extern crate frame_benchmarking; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this syntax (extern crate
) was not needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do this, but then we would have to import the "hidden" cb_add_benchmarks
and cb_list_benchmarks
macros, which is more confusing I think since the user does not directly need them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just have a few small questions.
More a fan of having it inside the |
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Yes I tried this. The This MR is only a temporary solution until we have automatic bench-case extraction from the pallet metadata, so I think it is ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, still LGTM!
bot merge |
@ggwpez please do the same in Polkadot and Cumulus? |
* Improve usability of add_benchmark and list_benchmark. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * node-template: use new define_benchmarks syntax Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * make CI happy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * remove old imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fix TryBuild tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "fix TryBuild tests" This reverts commit 82ea52f. * review: remove blank lines Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
## fixes KILTProtocol/ticket#2289 and KILTProtocol/ticket#2296 * Upgrades from Polkadot v0.9.29 to v0.9.32 * Adds missing feature implementations for all tomls (checked via `subalfred check features` in all crates) * Actually necessary for application of paritytech/substrate#10592 (see runtime changes in [dd81eac](dd81eac)) * Migrates Democracy, Preimage and Scheduler pallets to use bounded Calls, see below ## Summary of changes (Polkadot v0.9.30-0.9.32) * Weights v2 are not fully there yet, but the struct now includes the [second field for storage size](paritytech/substrate#12277) (tracking issue: https://github.com/paritytech/substrate/issues/12176) ### Breaking Changes * Breaking: Outer enums (paritytech/substrate#11981) * `Origin` --> `RuntimeOrigin` * `Call` --> `RuntimeCall` * `Event` --> `RuntimeEvent` * ~Convention seems to be to keep `Event`, `Call`, `Origin` for inner pallet usage, e.g. `Did::Origin`~ Update: We use `Runtime` prefix internally as well ### Noteworthy PRs * paritytech/substrate#12109 * paritytech/substrate#12328 * paritytech/cumulus#1585 * Following the effort of decoupling collators and full relay nodes, this PR adds the possibility of pointing the collator to an “external” (non in-process) relay node. This is still considered experimental, and the **relay node is suggested to run on the same machine than the collator for the moment**. * To specify the relay full node rpc: `polkadot-parachain --alice --collator --relay-chain-rpc-url <rpc-websocket-url>` * paritytech/substrate#12486 * Before this change only the interpreted WASM executor was included in per default compilations. Making the compiled executor opt-in, now, compiled WASM executor is set by default and an opt-out instead. This could lead to **big performance difference** between using these two, as more recent versions of the interpreter see a regression in performance. ### Scheduler, Preimage, Democracy Migration * paritytech/substrate#11649 * Referenda, Democracy, Scheduler and Preimage pallets are all now bounded in storage access footprint * Removed the concept of a "hard deadline" or weight-override priority and no longer guarantees that at least one scheduled item will be executed per block (since these are both dangerous to parachains which have a strict need of weight limits). This means you must ensure that scheduled items are below the MaximumWeight or they will not be executed. * Interesting comment: paritytech/substrate#11649 (comment) > There is migration code which moves existing proposals and referenda over to the new format. However IT DOES NOT MIGRATE EVERYTHING: > > * Preimages are **NOT** migrated. Any registered preimages in Democracy at the time of migration are dropped. Their balance is **NOT UNRESERVED**. > * The re-dispatcher used in the old Democracy implementation is removed. Any proposals scheduled for dispatch by Democracy **WILL NOT EXECUTE**. > > This means you SHOULD ensure that: > > * **the preimage for the runtime upgrade is placed as an imminent preimage, not with a deposit;** > * **no other preimages are in place at the time of upgrade;** > * **there are no other proposals scheduled for dispatch by Democracy at the time of upgrade.** > > The Democracy pallet will be marked as deprecated immediately once Referenda is considered production-ready. **ALL TEAMS ARE RECOMMENDED TO SWITCH SWAY FROM DEMOCRACY PALLET TO REFERENDA/CONVICTION-VOTING PALLETS ASAP** #### Result of `try-runtime` against Spiritnet on Friday Nov 18, 2022: ``` 2022-11-18 09:27:23.917 INFO main runtime::preimage::migration::v1: Migrating 0 images 2022-11-18 09:27:23.917 INFO main runtime::scheduler::migration: Trying to migrate 0 agendas... 2022-11-18 09:27:23.917 INFO main runtime::scheduler::migration: Migrated 0 agendas. 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: 0 public proposals will be migrated. 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: 25 referenda will be migrated. 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #7 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #20 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #13 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #5 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #8 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #1 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #19 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #9 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #16 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #14 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #21 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #15 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #24 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #22 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #2 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #10 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #0 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #6 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #11 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #3 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #17 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #18 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #23 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #4 2022-11-18 09:27:23.917 INFO main runtime::democracy::migration::v1: migrating referendum #25 2022-11-18 09:27:23.918 INFO main runtime::democracy::migration::v1: 0 public proposals migrated, 25 referenda migrated ``` ## Checklist: - [x] I have verified that the code works - [x] No panics! (checked arithmetic ops, no indexing `array[3]` use `get(3)`, ...) - [x] I have verified that the code is easy to understand - [ ] If not, I have left a well-balanced amount of inline comments - [x] I have [left the code in a better state](https://deviq.com/principles/boy-scout-rule) - [x] I have documented the changes (where applicable)
* Improve usability of add_benchmark and list_benchmark. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * node-template: use new define_benchmarks syntax Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * make CI happy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * remove old imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fix TryBuild tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "fix TryBuild tests" This reverts commit 82ea52f. * review: remove blank lines Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Problem
The usage of the
add_benchmark
andlist_benchmark
macros is error prone since they require code duplication.Related paritytech/polkadot-sdk#397
Current Syntax
Possible Solution
This MR contains a non-destructive way of extending the syntax to eliminate the repetition.
Added:
define_benchmarks!
: takes a list of bench configs that was formerly passed toadd_
+list_benchmark!
list_benchmarks!
: lists all benchmarks defined indefine_benchmarks!
add_benchmarks!
: adds all benchmarks defined indefine_benchmarks!
New Syntax
@ reviewers
D-*
label is currently missing.define_benchmarks
macro call, which could be moved into it but I am not sure if this is good style.[path, location] …
is the best syntax.cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --pallet='*' --extrinsic='*' --list
and the same for thenode-template
.