Skip to content

Commit

Permalink
Make weights depend on n
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Dec 31, 2024
1 parent 80f4b80 commit 574fcc1
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 305 deletions.
2 changes: 1 addition & 1 deletion pallets/author-noting/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ benchmarks! {

let mut infos = vec![];
for i in 0..x {
let para_id = (1000 + x).into();
let para_id = (1000 + i).into();
let block_number = 1;
let author: T::AccountId = account("account id", 0u32, 0u32);
T::AuthorNotingHook::prepare_worst_case_for_bench(&author, block_number, para_id);
Expand Down
112 changes: 49 additions & 63 deletions pallets/author-noting/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
//! Autogenerated weights for pallet_author_noting
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 43.0.0
//! DATE: 2024-12-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-12-31, STEPS: `16`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `pop-os`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P`
//! HOSTNAME: `tomasz-XPS-15-9520`, CPU: `12th Gen Intel(R) Core(TM) i7-12700H`
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
Expand All @@ -35,14 +35,14 @@
// *
// --chain=dev
// --steps
// 50
// 16
// --repeat
// 20
// --template=./benchmarking/frame-weight-pallet-template.hbs
// 1
// --template=benchmarking/frame-weight-pallet-template.hbs
// --json-file
// raw.json
// --output
// tmp/dancebox_weights/pallet_author_noting.rs
// tmp/pallet_author_noting.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -56,7 +56,7 @@ pub trait WeightInfo {
fn set_latest_author_data(x: u32, ) -> Weight;
fn set_author() -> Weight;
fn kill_author_data() -> Weight;
fn on_container_authors_noted() -> Weight;
fn on_container_authors_noted(x: u32, ) -> Weight;
}

/// Weights for pallet_author_noting using the Substrate node and recommended hardware.
Expand All @@ -76,39 +76,29 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `AuthorNoting::LatestAuthor` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
/// Storage: `InflationRewards::ChainsToReward` (r:1 w:1)
/// Proof: `InflationRewards::ChainsToReward` (`max_values`: Some(1), `max_size`: Some(418), added: 913, mode: `MaxEncodedLen`)
/// Storage: `ServicesPayment::BlockProductionCredits` (r:100 w:0)
/// Proof: `ServicesPayment::BlockProductionCredits` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:103 w:102)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Invulnerables::Invulnerables` (r:1 w:0)
/// Proof: `Invulnerables::Invulnerables` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
/// Storage: `PooledStaking::Pools` (r:2 w:0)
/// Proof: `PooledStaking::Pools` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`)
/// Storage: `XcmCoreBuyer::PendingBlocks` (r:0 w:100)
/// Proof: `XcmCoreBuyer::PendingBlocks` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 100]`.
fn set_latest_author_data(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1015 + x * (208 ±0)`
// Estimated: `8799 + x * (2603 ±0)`
// Minimum execution time: 122_225_000 picoseconds.
Weight::from_parts(123_639_000, 8799)
// Standard Error: 128_105
.saturating_add(Weight::from_parts(36_913_982, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(12_u64))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().writes(4_u64))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into())))
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(x.into()))
// Measured: `493 + x * (73 ±0)`
// Estimated: `1978 + x * (2539 ±0)`
// Minimum execution time: 48_373_000 picoseconds.
Weight::from_parts(48_373_000, 1978)
// Standard Error: 633_051
.saturating_add(Weight::from_parts(15_379_156, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into())))
.saturating_add(Weight::from_parts(0, 2539).saturating_mul(x.into()))
}
/// Storage: `AuthorNoting::LatestAuthor` (r:0 w:1)
/// Proof: `AuthorNoting::LatestAuthor` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
fn set_author() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_776_000 picoseconds.
Weight::from_parts(6_057_000, 0)
// Minimum execution time: 9_241_000 picoseconds.
Weight::from_parts(9_241_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `AuthorNoting::LatestAuthor` (r:0 w:1)
Expand All @@ -117,8 +107,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_542_000 picoseconds.
Weight::from_parts(5_844_000, 0)
// Minimum execution time: 11_313_000 picoseconds.
Weight::from_parts(11_313_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `InflationRewards::ChainsToReward` (r:1 w:1)
Expand All @@ -133,12 +123,15 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `ServicesPayment::BlockProductionCredits` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`)
/// Storage: `XcmCoreBuyer::PendingBlocks` (r:0 w:1)
/// Proof: `XcmCoreBuyer::PendingBlocks` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
fn on_container_authors_noted() -> Weight {
/// The range of component `x` is `[1, 50]`.
fn on_container_authors_noted(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `881`
// Estimated: `11402`
// Minimum execution time: 92_792_000 picoseconds.
Weight::from_parts(99_983_000, 11402)
// Minimum execution time: 92_161_000 picoseconds.
Weight::from_parts(76_221_073, 11402)
// Standard Error: 239_851
.saturating_add(Weight::from_parts(10_452_583, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(9_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
Expand All @@ -160,39 +153,29 @@ impl WeightInfo for () {
/// Proof: `AuthorNoting::LatestAuthor` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
/// Storage: `InflationRewards::ChainsToReward` (r:1 w:1)
/// Proof: `InflationRewards::ChainsToReward` (`max_values`: Some(1), `max_size`: Some(418), added: 913, mode: `MaxEncodedLen`)
/// Storage: `ServicesPayment::BlockProductionCredits` (r:100 w:0)
/// Proof: `ServicesPayment::BlockProductionCredits` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:103 w:102)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Invulnerables::Invulnerables` (r:1 w:0)
/// Proof: `Invulnerables::Invulnerables` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`)
/// Storage: `PooledStaking::Pools` (r:2 w:0)
/// Proof: `PooledStaking::Pools` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`)
/// Storage: `XcmCoreBuyer::PendingBlocks` (r:0 w:100)
/// Proof: `XcmCoreBuyer::PendingBlocks` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 100]`.
fn set_latest_author_data(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1015 + x * (208 ±0)`
// Estimated: `8799 + x * (2603 ±0)`
// Minimum execution time: 122_225_000 picoseconds.
Weight::from_parts(123_639_000, 8799)
// Standard Error: 128_105
.saturating_add(Weight::from_parts(36_913_982, 0).saturating_mul(x.into()))
.saturating_add(RocksDbWeight::get().reads(12_u64))
.saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into())))
.saturating_add(RocksDbWeight::get().writes(4_u64))
.saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(x.into())))
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(x.into()))
// Measured: `493 + x * (73 ±0)`
// Estimated: `1978 + x * (2539 ±0)`
// Minimum execution time: 48_373_000 picoseconds.
Weight::from_parts(48_373_000, 1978)
// Standard Error: 633_051
.saturating_add(Weight::from_parts(15_379_156, 0).saturating_mul(x.into()))
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(x.into())))
.saturating_add(Weight::from_parts(0, 2539).saturating_mul(x.into()))
}
/// Storage: `AuthorNoting::LatestAuthor` (r:0 w:1)
/// Proof: `AuthorNoting::LatestAuthor` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
fn set_author() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_776_000 picoseconds.
Weight::from_parts(6_057_000, 0)
// Minimum execution time: 9_241_000 picoseconds.
Weight::from_parts(9_241_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `AuthorNoting::LatestAuthor` (r:0 w:1)
Expand All @@ -201,8 +184,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_542_000 picoseconds.
Weight::from_parts(5_844_000, 0)
// Minimum execution time: 11_313_000 picoseconds.
Weight::from_parts(11_313_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `InflationRewards::ChainsToReward` (r:1 w:1)
Expand All @@ -217,12 +200,15 @@ impl WeightInfo for () {
/// Proof: `ServicesPayment::BlockProductionCredits` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`)
/// Storage: `XcmCoreBuyer::PendingBlocks` (r:0 w:1)
/// Proof: `XcmCoreBuyer::PendingBlocks` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
fn on_container_authors_noted() -> Weight {
/// The range of component `x` is `[1, 50]`.
fn on_container_authors_noted(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `881`
// Estimated: `11402`
// Minimum execution time: 92_792_000 picoseconds.
Weight::from_parts(99_983_000, 11402)
// Minimum execution time: 92_161_000 picoseconds.
Weight::from_parts(76_221_073, 11402)
// Standard Error: 239_851
.saturating_add(Weight::from_parts(10_452_583, 0).saturating_mul(x.into()))
.saturating_add(RocksDbWeight::get().reads(9_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
Expand Down
7 changes: 3 additions & 4 deletions pallets/services-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ impl<T: Config> AuthorNotingHook<T::AccountId> for Pallet<T> {
// This hook is called when pallet_author_noting sees that the block number of a container chain has increased.
// Currently we always charge 1 credit, even if a container chain produced more that 1 block in between tanssi
// blocks.
fn on_container_authors_noted(info: &[AuthorNotingInfo<T::AccountId>]) -> Weight {
for info in info {
fn on_container_authors_noted(infos: &[AuthorNotingInfo<T::AccountId>]) -> Weight {
for info in infos {
let para_id = info.para_id;
if Pallet::<T>::burn_block_production_free_credit_for_para(&para_id).is_err() {
let (amount_to_charge, _weight) =
Expand All @@ -568,8 +568,7 @@ impl<T: Config> AuthorNotingHook<T::AccountId> for Pallet<T> {
}
}

// TODO: weight should depend on info.len()
T::WeightInfo::on_container_authors_noted()
T::WeightInfo::on_container_authors_noted(infos.len() as u32)
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
Loading

0 comments on commit 574fcc1

Please sign in to comment.