Skip to content

Commit

Permalink
Add missing benchmarks (#2909)
Browse files Browse the repository at this point in the history
* Add benchmarks for pallet-message-queue

* Add benchmarks for cumulus_pallet_parachain_system

* update MessageQueueHeapSize

* Use proper (2^n) value in MessageQueueHeapSize
  • Loading branch information
RomarQ authored Aug 22, 2024
1 parent 7806562 commit f0cbe6f
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 11 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion file_header.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2022 PureStake Inc.
// Copyright 2024 Moonbeam foundation
// This file is part of Moonbeam.

// Moonbeam is free software: you can redistribute it and/or modify
Expand Down
9 changes: 8 additions & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ xcm-primitives = { workspace = true }
# Substrate
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
pallet-message-queue = { workspace = true }
frame-benchmarking = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
Expand Down Expand Up @@ -105,6 +106,7 @@ std = [
"pallet-xcm-transactor/std",
"pallet-moonbeam-lazy-migrations/std",
"pallet-identity/std",
"pallet-message-queue/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-consensus-slots/std",
Expand All @@ -120,6 +122,7 @@ std = [
runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"pallet-asset-manager/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
Expand Down Expand Up @@ -151,4 +154,8 @@ runtime-benchmarks = [
"pallet-moonbeam-lazy-migrations/runtime-benchmarks",
"moonbeam-xcm-benchmarks/runtime-benchmarks",
]
try-runtime = ["cumulus-pallet-parachain-system/try-runtime", "frame-support/try-runtime", "pallet-migrations/try-runtime"]
try-runtime = [
"cumulus-pallet-parachain-system/try-runtime",
"frame-support/try-runtime",
"pallet-migrations/try-runtime",
]
72 changes: 72 additions & 0 deletions runtime/common/src/weights/cumulus_pallet_parachain_system.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright 2024 Moonbeam foundation
// This file is part of Moonbeam.

// Moonbeam is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Moonbeam is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

//! Autogenerated weights for `cumulus_pallet_parachain_system`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-08-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `MacBook-Pro-de-romarq.local`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: Compiled, CHAIN: Some("moonbase-dev"), DB CACHE: 1024
// Executed Command:
// ./target/release/moonbeam
// benchmark
// pallet
// --chain=moonbase-dev
// --steps=50
// --repeat=20
// --pallet=cumulus_pallet_parachain_system
// --extrinsic=*
// --wasm-execution=compiled
// --header=./file_header.txt
// --template=./benchmarking/frame-weight-template.hbs
// --output=./runtime/common/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weights for `cumulus_pallet_parachain_system`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> cumulus_pallet_parachain_system::WeightInfo for WeightInfo<T> {
/// Storage: `ParachainSystem::LastDmqMqcHead` (r:1 w:1)
/// Proof: `ParachainSystem::LastDmqMqcHead` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
/// Storage: `ParachainSystem::ProcessedDownwardMessages` (r:0 w:1)
/// Proof: `ParachainSystem::ProcessedDownwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::Pages` (r:0 w:1000)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(107993), added: 110468, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 1000]`.
fn enqueue_inbound_downward_messages(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `82`
// Estimated: `3517`
// Minimum execution time: 2_000_000 picoseconds.
Weight::from_parts(2_000_000, 3517)
// Standard Error: 914_274
.saturating_add(Weight::from_parts(213_425_397, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
}
}
2 changes: 2 additions & 0 deletions runtime/common/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Moonbeam common weights.
pub mod cumulus_pallet_parachain_system;
pub mod cumulus_pallet_xcmp_queue;
pub mod db;
pub mod pallet_asset_manager;
Expand All @@ -29,6 +30,7 @@ pub mod pallet_conviction_voting;
pub mod pallet_crowdloan_rewards;
pub mod pallet_evm;
pub mod pallet_identity;
pub mod pallet_message_queue;
pub mod pallet_moonbeam_foreign_assets;
pub mod pallet_moonbeam_lazy_migrations;
pub mod pallet_moonbeam_orbiters;
Expand Down
184 changes: 184 additions & 0 deletions runtime/common/src/weights/pallet_message_queue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// Copyright 2024 Moonbeam foundation
// This file is part of Moonbeam.

// Moonbeam is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Moonbeam is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

//! Autogenerated weights for `pallet_message_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-08-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `MacBook-Pro-de-romarq.local`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: Compiled, CHAIN: Some("moonbase-dev"), DB CACHE: 1024
// Executed Command:
// ./target/release/moonbeam
// benchmark
// pallet
// --chain=moonbase-dev
// --steps=50
// --repeat=20
// --pallet=pallet_message_queue
// --extrinsic=*
// --wasm-execution=compiled
// --header=./file_header.txt
// --template=./benchmarking/frame-weight-template.hbs
// --output=./runtime/common/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weights for `pallet_message_queue`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_message_queue::WeightInfo for WeightInfo<T> {
/// Storage: `MessageQueue::ServiceHead` (r:1 w:0)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::BookStateFor` (r:2 w:2)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
fn ready_ring_knit() -> Weight {
// Proof Size summary in bytes:
// Measured: `223`
// Estimated: `6044`
// Minimum execution time: 10_000_000 picoseconds.
Weight::from_parts(11_000_000, 6044)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// Storage: `MessageQueue::BookStateFor` (r:2 w:2)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
fn ready_ring_unknit() -> Weight {
// Proof Size summary in bytes:
// Measured: `218`
// Estimated: `6044`
// Minimum execution time: 9_000_000 picoseconds.
Weight::from_parts(10_000_000, 6044)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `EmergencyParaXcm::Mode` (r:1 w:0)
/// Proof: `EmergencyParaXcm::Mode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MaintenanceMode::MaintenanceMode` (r:1 w:0)
/// Proof: `MaintenanceMode::MaintenanceMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn service_queue_base() -> Weight {
// Proof Size summary in bytes:
// Measured: `190`
// Estimated: `3517`
// Minimum execution time: 7_000_000 picoseconds.
Weight::from_parts(7_000_000, 3517)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
fn service_page_base_completion() -> Weight {
// Proof Size summary in bytes:
// Measured: `72`
// Estimated: `137658`
// Minimum execution time: 5_000_000 picoseconds.
Weight::from_parts(6_000_000, 137658)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
fn service_page_base_no_completion() -> Weight {
// Proof Size summary in bytes:
// Measured: `72`
// Estimated: `137658`
// Minimum execution time: 5_000_000 picoseconds.
Weight::from_parts(6_000_000, 137658)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MessageQueue::BookStateFor` (r:0 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:0 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
fn service_page_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 155_000_000 picoseconds.
Weight::from_parts(156_000_000, 0)
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::BookStateFor` (r:1 w:0)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
fn bump_service_head() -> Weight {
// Proof Size summary in bytes:
// Measured: `171`
// Estimated: `3517`
// Minimum execution time: 5_000_000 picoseconds.
Weight::from_parts(6_000_000, 3517)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
fn reap_page() -> Weight {
// Proof Size summary in bytes:
// Measured: `134274`
// Estimated: `137658`
// Minimum execution time: 48_000_000 picoseconds.
Weight::from_parts(53_000_000, 137658)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `EmergencyParaXcm::Mode` (r:1 w:0)
/// Proof: `EmergencyParaXcm::Mode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MaintenanceMode::MaintenanceMode` (r:1 w:0)
/// Proof: `MaintenanceMode::MaintenanceMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
fn execute_overweight_page_removed() -> Weight {
// Proof Size summary in bytes:
// Measured: `134458`
// Estimated: `137658`
// Minimum execution time: 69_000_000 picoseconds.
Weight::from_parts(75_000_000, 137658)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `EmergencyParaXcm::Mode` (r:1 w:0)
/// Proof: `EmergencyParaXcm::Mode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MaintenanceMode::MaintenanceMode` (r:1 w:0)
/// Proof: `MaintenanceMode::MaintenanceMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
fn execute_overweight_page_updated() -> Weight {
// Proof Size summary in bytes:
// Measured: `134458`
// Estimated: `137658`
// Minimum execution time: 82_000_000 picoseconds.
Weight::from_parts(88_000_000, 137658)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
}
4 changes: 3 additions & 1 deletion runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type CheckAssociatedRelayNumber = EmergencyParaXcm;
type ConsensusHook = ConsensusHookWrapperForRelayTimestamp<Runtime, ConsensusHook>;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight<Runtime>;
type WeightInfo = moonbase_weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
}

impl parachain_info::Config for Runtime {}
Expand Down Expand Up @@ -1501,7 +1501,9 @@ mod benches {
[pallet_author_mapping, AuthorMapping]
[pallet_proxy, Proxy]
[pallet_identity, Identity]
[cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_message_queue, MessageQueue]
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
[pallet_asset_manager, AssetManager]
[pallet_xcm_transactor, XcmTransactor]
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbase/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ parameter_types! {
/// A good value depends on the expected message sizes, their weights, the weight that is
/// available for processing them and the maximal needed message size. The maximal message
/// size is slightly lower than this as defined by [`MaxMessageLenOf`].
pub const MessageQueueHeapSize: u32 = 128 * 1048;
pub const MessageQueueHeapSize: u32 = 103 * 1024;
}

impl pallet_message_queue::Config for Runtime {
Expand All @@ -455,7 +455,7 @@ impl pallet_message_queue::Config for Runtime {
type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
// NarrowOriginToSibling calls XcmpQueue's is_paused if Origin is sibling. Allows all other origins
type QueuePausedQuery = EmergencyParaXcm;
type WeightInfo = pallet_message_queue::weights::SubstrateWeight<Runtime>;
type WeightInfo = moonbase_weights::pallet_message_queue::WeightInfo<Runtime>;
type IdleMaxServiceWeight = MessageQueueServiceWeight;
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHookWrapperForRelayTimestamp<Runtime, ConsensusHook>;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight<Runtime>;
type WeightInfo = moonbeam_weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
}

pub struct EthereumXcmEnsureProxy;
Expand Down Expand Up @@ -1489,7 +1489,9 @@ mod benches {
[pallet_author_mapping, AuthorMapping]
[pallet_proxy, Proxy]
[pallet_identity, Identity]
[cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_message_queue, MessageQueue]
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
[pallet_asset_manager, AssetManager]
[pallet_xcm_transactor, XcmTransactor]
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbeam/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ parameter_types! {
/// A good value depends on the expected message sizes, their weights, the weight that is
/// available for processing them and the maximal needed message size. The maximal message
/// size is slightly lower than this as defined by [`MaxMessageLenOf`].
pub const MessageQueueHeapSize: u32 = 128 * 1048;
pub const MessageQueueHeapSize: u32 = 103 * 1024;
}

impl pallet_message_queue::Config for Runtime {
Expand All @@ -443,7 +443,7 @@ impl pallet_message_queue::Config for Runtime {
type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
// NarrowOriginToSibling calls XcmpQueue's is_paused if Origin is sibling. Allows all other origins
type QueuePausedQuery = (MaintenanceMode, NarrowOriginToSibling<XcmpQueue>);
type WeightInfo = pallet_message_queue::weights::SubstrateWeight<Runtime>;
type WeightInfo = moonbeam_weights::pallet_message_queue::WeightInfo<Runtime>;
type IdleMaxServiceWeight = MessageQueueServiceWeight;
}

Expand Down
Loading

0 comments on commit f0cbe6f

Please sign in to comment.