Skip to content

Commit

Permalink
Bench upstream pallets (#292)
Browse files Browse the repository at this point in the history
* Fix balances benchmark

* Add bridge related bench

* Benchmark with steps 50 repeat 20

* Update weights for bridge pallets

* Pangolin bench pallets

* Bench s2 r1 for all runtimes

* Update weights for all runtime
  • Loading branch information
Guantong authored Feb 22, 2023
1 parent f24def2 commit 6132743
Show file tree
Hide file tree
Showing 164 changed files with 12,122 additions and 420 deletions.
21 changes: 20 additions & 1 deletion runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,30 @@ frame_support::construct_runtime! {

#[cfg(feature = "runtime-benchmarks")]
frame_benchmarking::define_benchmarks! {
// Substrate
[cumulus_pallet_xcmp_queue, XcmpQueue]
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Assets]
[pallet_balances, Balances]
[pallet_collective, Council]
[pallet_collective, TechnicalCommittee]
[pallet_democracy, Democracy]
[pallet_elections_phragmen, PhragmenElection]
[pallet_identity, Identity]
[pallet_membership, TechnicalMembership]
[pallet_multisig, Multisig]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
[pallet_scheduler, Scheduler]
[pallet_tips, Tips]
[pallet_treasury, Treasury]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_session, SessionBench::<Runtime>]
[pallet_timestamp, Timestamp]
[cumulus_pallet_xcmp_queue, XcmpQueue]
// Bridge
[pallet_bridge_grandpa, BridgePolkadotGrandpa]
[pallet_fee_market, DarwiniaFeeMarket]
}

impl_self_contained_call!();
Expand Down
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ impl pallet_assets::Config for Runtime {
type RemoveItemsLimit = ConstU32<1000>;
type RuntimeEvent = RuntimeEvent;
type StringLimit = ConstU32<50>;
type WeightInfo = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Self>;
}
12 changes: 11 additions & 1 deletion runtime/crab/src/pallets/balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@
// darwinia
use crate::*;

// https://github.com/paritytech/substrate/blob/polkadot-v0.9.37/frame/balances/src/benchmarking.rs#L39
#[cfg(feature = "runtime-benchmarks")]
frame_support::parameter_types! {
pub const ExistentialDeposit:Balance = 1;
}
#[cfg(not(feature = "runtime-benchmarks"))]
frame_support::parameter_types! {
pub const ExistentialDeposit:Balance = 0;
}

impl pallet_balances::Config for Runtime {
type AccountStore = System;
type Balance = Balance;
type DustRemoval = ();
type ExistentialDeposit = ConstU128<0>;
type ExistentialDeposit = ExistentialDeposit;
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
Expand Down
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/bridge_grandpa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ impl pallet_bridge_grandpa::Config<WithPolkadotGrandpa> for Runtime {
type MaxBridgedAuthorities = ConstU32<100_000>;
type MaxBridgedHeaderSize = ConstU32<65536>;
type MaxRequests = ConstU32<50>;
type WeightInfo = ();
type WeightInfo = weights::pallet_bridge_grandpa::WeightInfo<Self>;
}
4 changes: 2 additions & 2 deletions runtime/crab/src/pallets/collective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type WeightInfo = ();
type WeightInfo = weights::pallet_collective_council::WeightInfo<Self>;
}
impl pallet_collective::Config<TechnicalCollective> for Runtime {
type DefaultVote = pallet_collective::PrimeDefaultVote;
Expand All @@ -46,5 +46,5 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type WeightInfo = ();
type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/democracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ impl pallet_democracy::Config for Runtime {
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
type VoteLockingPeriod = ConstU32<ENACTMENT_PERIOD>;
type VotingPeriod = ConstU32<{ 28 * DAYS }>;
type WeightInfo = ();
type WeightInfo = weights::pallet_democracy::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/elections_phragmen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ impl pallet_elections_phragmen::Config for Runtime {
type VotingBondBase = ConstU128<{ darwinia_deposit(1, 64) }>;
// Additional data per vote is 32 bytes (account id).
type VotingBondFactor = ConstU128<{ darwinia_deposit(0, 32) }>;
type WeightInfo = ();
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/fee_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ impl pallet_fee_market::Config<WithDarwiniaFeeMarket> for Runtime {
type Slasher = FeeMarketSlasher;
type Slot = ConstU32<600>;
type TreasuryPalletId = TreasuryPalletId;
type WeightInfo = ();
type WeightInfo = weights::pallet_fee_market::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ impl pallet_identity::Config for Runtime {
type Slashed = Treasury;
// 53 bytes on-chain.
type SubAccountDeposit = ConstU128<{ darwinia_deposit(1, 53) }>;
type WeightInfo = ();
type WeightInfo = weights::pallet_identity::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/membership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
type ResetOrigin = RootOrMoreThanHalf<CouncilCollective>;
type RuntimeEvent = RuntimeEvent;
type SwapOrigin = RootOrMoreThanHalf<CouncilCollective>;
type WeightInfo = ();
type WeightInfo = weights::pallet_membership::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ impl pallet_multisig::Config for Runtime {
type MaxSignatories = ConstU32<100>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type WeightInfo = weights::pallet_multisig::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ impl pallet_preimage::Config for Runtime {
type Currency = Balances;
type ManagerOrigin = frame_system::EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type WeightInfo = weights::pallet_preimage::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ impl pallet_proxy::Config for Runtime {
type ProxyType = ProxyType;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type WeightInfo = weights::pallet_proxy::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type ScheduleOrigin = Root;
type WeightInfo = ();
type WeightInfo = weights::pallet_scheduler::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/tips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ impl pallet_tips::Config for Runtime {
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = ConstU128<{ 100 * UNIT }>;
type Tippers = PhragmenElection;
type WeightInfo = ();
type WeightInfo = weights::pallet_tips::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ impl pallet_treasury::Config for Runtime {
type SpendFunds = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
type SpendPeriod = ConstU32<{ 24 * DAYS }>;
type WeightInfo = ();
type WeightInfo = weights::pallet_treasury::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ impl pallet_utility::Config for Runtime {
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type WeightInfo = weights::pallet_utility::WeightInfo<Self>;
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl pallet_vesting::Config for Runtime {
type MinVestedTransfer = ConstU128<UNIT>;
type RuntimeEvent = RuntimeEvent;
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
type WeightInfo = ();
type WeightInfo = weights::pallet_vesting::WeightInfo<Self>;

// `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the
// highest number of schedules that encodes less than 2^10.
Expand Down
32 changes: 19 additions & 13 deletions runtime/crab/src/weights/cumulus_pallet_xcmp_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
//! Autogenerated weights for `cumulus_pallet_xcmp_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-11-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `inv.cafe`, CPU: `AMD Ryzen 9 5950X 16-Core Processor`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024
//! DATE: 2023-02-22, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `Debian`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("crab-local"), DB CACHE: 1024
// Executed Command:
// target/release/darwinia
// ./target/release/darwinia
// benchmark
// pallet
// --header
Expand All @@ -33,14 +33,18 @@
// wasm
// --heap-pages
// 4096
// --steps
// 2
// --repeat
// 1
// --chain
// local
// crab-local
// --output
// runtime/src/weights
// runtime/crab/src/weights/
// --extrinsic
// *
// --pallet
// cumulus-pallet-xcmp-queue
// *

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -54,14 +58,16 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> cumulus_pallet_xcmp_queue::WeightInfo for WeightInfo<T> {
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_u32() -> Weight {
Weight::from_ref_time(13_340_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
// Minimum execution time: 26_238 nanoseconds.
Weight::from_ref_time(26_238_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_weight() -> Weight {
Weight::from_ref_time(12_610_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
// Minimum execution time: 23_922 nanoseconds.
Weight::from_ref_time(23_922_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
52 changes: 31 additions & 21 deletions runtime/crab/src/weights/frame_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
//! Autogenerated weights for `frame_system`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-11-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `inv.cafe`, CPU: `AMD Ryzen 9 5950X 16-Core Processor`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024
//! DATE: 2023-02-22, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `Debian`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("crab-local"), DB CACHE: 1024
// Executed Command:
// target/release/darwinia
// ./target/release/darwinia
// benchmark
// pallet
// --header
Expand All @@ -33,14 +33,18 @@
// wasm
// --heap-pages
// 4096
// --steps
// 2
// --repeat
// 1
// --chain
// local
// crab-local
// --output
// runtime/src/weights
// runtime/crab/src/weights/
// --extrinsic
// *
// --pallet
// frame-system
// *

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -54,35 +58,41 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_system::WeightInfo for WeightInfo<T> {
/// The range of component `b` is `[0, 3932160]`.
fn remark(_b: u32, ) -> Weight {
Weight::from_ref_time(1_074_555_000 as u64)
// Minimum execution time: 16_591 nanoseconds.
Weight::from_ref_time(886_493_000)
}
/// The range of component `b` is `[0, 3932160]`.
fn remark_with_event(_b: u32, ) -> Weight {
Weight::from_ref_time(4_724_488_000 as u64)
// Minimum execution time: 32_289 nanoseconds.
Weight::from_ref_time(4_680_492_000)
}
// Storage: System Digest (r:1 w:1)
// Storage: unknown [0x3a686561707061676573] (r:0 w:1)
fn set_heap_pages() -> Weight {
Weight::from_ref_time(14_110_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
// Minimum execution time: 30_011 nanoseconds.
Weight::from_ref_time(30_011_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: Skipped Metadata (r:0 w:0)
/// The range of component `i` is `[1, 1000]`.
/// The range of component `i` is `[0, 1000]`.
fn set_storage(_i: u32, ) -> Weight {
Weight::from_ref_time(655_299_000 as u64)
.saturating_add(T::DbWeight::get().writes(1000 as u64))
// Minimum execution time: 95_093 nanoseconds.
Weight::from_ref_time(572_291_000)
.saturating_add(T::DbWeight::get().writes(1000))
}
// Storage: Skipped Metadata (r:0 w:0)
/// The range of component `i` is `[1, 1000]`.
/// The range of component `i` is `[0, 1000]`.
fn kill_storage(_i: u32, ) -> Weight {
Weight::from_ref_time(555_697_000 as u64)
.saturating_add(T::DbWeight::get().writes(1000 as u64))
// Minimum execution time: 18_319 nanoseconds.
Weight::from_ref_time(407_086_000)
.saturating_add(T::DbWeight::get().writes(1000))
}
// Storage: Skipped Metadata (r:0 w:0)
/// The range of component `p` is `[1, 1000]`.
/// The range of component `p` is `[0, 1000]`.
fn kill_prefix(_p: u32, ) -> Weight {
Weight::from_ref_time(1_089_395_000 as u64)
.saturating_add(T::DbWeight::get().writes(1000 as u64))
// Minimum execution time: 31_200 nanoseconds.
Weight::from_ref_time(772_322_000)
.saturating_add(T::DbWeight::get().writes(1000))
}
}
17 changes: 17 additions & 0 deletions runtime/crab/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ pub use rocksdb_weights::constants::RocksDbWeight;

pub mod cumulus_pallet_xcmp_queue;
pub mod frame_system;
pub mod pallet_assets;
pub mod pallet_balances;
pub mod pallet_bridge_grandpa;
pub mod pallet_collective_council;
pub mod pallet_collective_technical_committee;
pub mod pallet_democracy;
pub mod pallet_elections_phragmen;
pub mod pallet_fee_market;
pub mod pallet_identity;
pub mod pallet_membership;
pub mod pallet_multisig;
pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_scheduler;
pub mod pallet_session;
pub mod pallet_timestamp;
pub mod pallet_tips;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
Loading

0 comments on commit 6132743

Please sign in to comment.