Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rocksDB weights #2786

Merged
merged 13 commits into from
Aug 2, 2024
17 changes: 17 additions & 0 deletions runtime/common/src/weights/db/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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/>.

pub mod rocksdb;
117 changes: 117 additions & 0 deletions runtime/common/src/weights/db/rocksdb.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// 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/>.

//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-04-27 (Y/M/D)
//! HOSTNAME: `ip-10-0-0-176`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
//!
//! DATABASE: `RocksDb`, RUNTIME: `Moonbeam`
//! BLOCK-NUM: `BlockId::Number(5962022)`
//! SKIP-WRITE: `false`, SKIP-READ: `false`, WARMUPS: `1`
//! STATE-VERSION: `V0`, STATE-CACHE-SIZE: ``
//! WEIGHT-PATH: `/home/ubuntu/projects/moonbeam/weights-rocksdb-moonbeam.rs`
//! METRIC: `Average`, WEIGHT-MUL: `1.1`, WEIGHT-ADD: `0`

// Executed Command:
// /home/ubuntu/projects/moonbeam/target/release/moonbeam
// benchmark
// storage
// --db=rocksdb
// --state-version=0
// --mul=1.1
// --weight-path
// /home/ubuntu/projects/moonbeam/weights-rocksdb-moonbeam.rs
// --chain
// moonbeam
// --base-path
// /var/lib/rocksdb-moonbeam-data
// --keys-limit
// 10000000
// --random-seed
// 1024

/// Storage DB weights for the `Moonbeam` runtime and `RocksDb`.
pub mod constants {
use frame_support::weights::{constants, RuntimeDbWeight};
use sp_core::parameter_types;

parameter_types! {
/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
/// the runtime.
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
// Time to read one storage item.
// Calculated by multiplying the *Average* of all values with `1.1` and adding `0`.
//
// Stats nanoseconds:
// Min, Max: 2_300, 2_841_169
// Average: 37_947
// Median: 38_669
// Std-Dev: 7331.86
//
// Percentiles nanoseconds:
// 99th: 55_974
// 95th: 49_824
// 75th: 42_570
read: 41_742 * constants::WEIGHT_REF_TIME_PER_NANOS,

// Time to write one storage item.
// Calculated by multiplying the *Average* of all values with `1.1` and adding `0`.
//
// Stats nanoseconds:
// Min, Max: 18_981, 16_772_373
// Average: 73_893
// Median: 72_807
// Std-Dev: 24543.58
//
// Percentiles nanoseconds:
// 99th: 97_152
// 95th: 85_751
// 75th: 77_392
write: 81_283 * constants::WEIGHT_REF_TIME_PER_NANOS,
};
}

#[cfg(test)]
mod test_db_weights {
use super::constants::RocksDbWeight as W;
use frame_support::weights::constants;

/// Checks that all weights exist and have sane values.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn bound() {
// At least 1 µs.
assert!(
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Read weight should be at least 1 µs."
);
assert!(
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Write weight should be at least 1 µs."
);
// At most 1 ms.
assert!(
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Read weight should be at most 1 ms."
);
assert!(
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Write weight should be at most 1 ms."
);
}
}
}
1 change: 1 addition & 0 deletions runtime/common/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Moonbeam common weights.

pub mod cumulus_pallet_xcmp_queue;
pub mod db;
pub mod pallet_asset_manager;
pub mod pallet_assets;
pub mod pallet_author_inherent;
Expand Down
6 changes: 3 additions & 3 deletions runtime/moonbase/src/asset_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use super::{
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX,
};

use moonbeam_runtime_common::weights as moonbeam_weights;
use moonbeam_runtime_common::weights as moonbase_weights;
use moonkit_xcm_primitives::AccountIdAssetIdConversion;

use frame_support::{
Expand Down Expand Up @@ -98,7 +98,7 @@ impl pallet_assets::Config<ForeignAssetInstance> for Runtime {
type Freezer = ();
type Extra = ();
type AssetAccountDeposit = ConstU128<{ currency::deposit(1, 18) }>;
type WeightInfo = moonbeam_weights::pallet_assets::WeightInfo<Runtime>;
type WeightInfo = moonbase_weights::pallet_assets::WeightInfo<Runtime>;
type RemoveItemsLimit = ConstU32<{ REMOVE_ITEMS_LIMIT }>;
type AssetIdParameter = Compact<AssetId>;
type CreateOrigin = AsEnsureOriginWithArg<EnsureNever<AccountId>>;
Expand Down Expand Up @@ -187,7 +187,7 @@ impl pallet_asset_manager::Config for Runtime {
type ForeignAssetType = xcm_config::AssetType;
type AssetRegistrar = AssetRegistrar;
type ForeignAssetModifierOrigin = ForeignAssetModifierOrigin;
type WeightInfo = moonbeam_weights::pallet_asset_manager::WeightInfo<Runtime>;
type WeightInfo = moonbase_weights::pallet_asset_manager::WeightInfo<Runtime>;
}

// Instruct how to go from an H160 to an AssetID
Expand Down
6 changes: 3 additions & 3 deletions runtime/moonbase/src/governance/councils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Councils for Gov1 and Gov2

use super::*;
use moonbeam_runtime_common::weights as moonbeam_weights;
use moonbeam_runtime_common::weights as moonbase_weights;

pub type TreasuryCouncilInstance = pallet_collective::Instance3;
pub type OpenTechCommitteeInstance = pallet_collective::Instance4;
Expand All @@ -39,7 +39,7 @@ impl pallet_collective::Config<TreasuryCouncilInstance> for Runtime {
/// The maximum number of treasury council members.
type MaxMembers = ConstU32<9>;
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = moonbeam_weights::pallet_collective::WeightInfo<Runtime>;
type WeightInfo = moonbase_weights::pallet_collective::WeightInfo<Runtime>;
type SetMembersOrigin = referenda::GeneralAdminOrRoot;
type MaxProposalWeight = MaxProposalWeight;
}
Expand All @@ -56,7 +56,7 @@ impl pallet_collective::Config<OpenTechCommitteeInstance> for Runtime {
/// The maximum number of technical committee members.
type MaxMembers = ConstU32<100>;
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = moonbeam_weights::pallet_collective::WeightInfo<Runtime>;
type WeightInfo = moonbase_weights::pallet_collective::WeightInfo<Runtime>;
type SetMembersOrigin = referenda::GeneralAdminOrRoot;
type MaxProposalWeight = MaxProposalWeight;
}
8 changes: 4 additions & 4 deletions runtime/moonbase/src/governance/referenda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ use super::*;
use crate::currency::*;
use frame_support::traits::{EitherOf, MapSuccess};
use frame_system::EnsureRootWithSuccess;
use moonbeam_runtime_common::weights as moonbeam_weights;
use moonbeam_runtime_common::weights as moonbase_weights;
use sp_runtime::traits::Replace;

parameter_types! {
pub const VoteLockingPeriod: BlockNumber = 1 * DAYS;
}

impl pallet_conviction_voting::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_conviction_voting::WeightInfo<Runtime>;
type WeightInfo = moonbase_weights::pallet_conviction_voting::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type Polls = Referenda;
Expand All @@ -59,7 +59,7 @@ impl custom_origins::Config for Runtime {}
// The purpose of this pallet is to queue calls to be dispatched as by root later => the Dispatch
// origin corresponds to the Gov2 Whitelist track.
impl pallet_whitelist::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_whitelist::WeightInfo<Runtime>;
type WeightInfo = moonbase_weights::pallet_whitelist::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type WhitelistOrigin = EitherOf<
Expand All @@ -81,7 +81,7 @@ impl pallet_whitelist::Config for Runtime {
pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber);

impl pallet_referenda::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_referenda::WeightInfo<Runtime>;
type WeightInfo = moonbase_weights::pallet_referenda::WeightInfo<Runtime>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
Expand Down
Loading
Loading