Skip to content

Commit

Permalink
add benchmark for force insert and rebenchmark route executor pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoka committed Mar 18, 2024
1 parent 483ebc2 commit 0d1fc9e
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 145 deletions.
2 changes: 1 addition & 1 deletion pallets/route-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ pub mod pallet {
/// Emits `RouteUpdated` when successful.
///
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::set_route_weight(new_route))]
#[pallet::weight(T::WeightInfo::force_insert_route_weight())]
#[transactional]
pub fn force_insert_route(
origin: OriginFor<T>,
Expand Down
215 changes: 128 additions & 87 deletions pallets/route-executor/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.


//! Autogenerated weights for `pallet_route_executor`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-12-12, STEPS: `5`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-03-18, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
Expand All @@ -27,38 +28,34 @@
// target/release/hydradx
// benchmark
// pallet
// --pallet=pallet-route-executor
// --chain=dev
// --steps=10
// --repeat=30
// --wasm-execution=compiled
// --heap-pages=4096
// --chain=dev
// --template=.maintain/pallet-weight-template.hbs
// --pallet=pallet_route-executor
// --output=re2.rs
// --extrinsic=*
// --steps=5
// --repeat=20
// --output
// ./weights-1.1.0/route_executor.rs
// --template
// .maintain/pallet-weight-template-no-back.hbs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(clippy::unnecessary_cast)]
#![allow(missing_docs)]

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

/// Weight functions needed for pallet_route_executor.
/// Weight functions needed for `pallet_route_executor`.
pub trait WeightInfo {
fn calculate_and_execute_sell_in_lbp(c: u32) -> Weight;
fn calculate_and_execute_buy_in_lbp(c: u32, b: u32) -> Weight;
fn calculate_and_execute_sell_in_lbp(c: u32, ) -> Weight;
fn calculate_and_execute_buy_in_lbp(c: u32, b: u32, ) -> Weight;
fn set_route_for_xyk() -> Weight;
fn force_insert_route() -> Weight;
}

/// Weights for pallet_route_executor using the hydraDX node and recommended hardware.
/// Weights for `pallet_route_executor` using the HydraDX node and recommended hardware.
pub struct HydraWeight<T>(PhantomData<T>);

impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
/// Storage: `LBP::PoolData` (r:1 w:0)
/// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`)
Expand All @@ -68,18 +65,22 @@ impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Locks` (r:1 w:1)
/// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`)
/// Storage: `Duster::AccountBlacklist` (r:2 w:0)
/// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::BannedAssets` (r:2 w:0)
/// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::Assets` (r:2 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`)
/// The range of component `c` is `[0, 1]`.
fn calculate_and_execute_sell_in_lbp(c: u32) -> Weight {
fn calculate_and_execute_sell_in_lbp(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `3016`
// Measured: `3436`
// Estimated: `13905`
// Minimum execution time: 316_311_000 picoseconds.
Weight::from_parts(318_353_450, 13905)
// Standard Error: 164_994
.saturating_add(Weight::from_parts(50_546_750, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(12_u64))
// Minimum execution time: 342_467_000 picoseconds.
Weight::from_parts(346_028_529, 13905)
// Standard Error: 185_098
.saturating_add(Weight::from_parts(50_586_970, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(16_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
}
/// Storage: `LBP::PoolData` (r:1 w:0)
Expand All @@ -90,55 +91,73 @@ impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Locks` (r:1 w:1)
/// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`)
/// Storage: `Duster::AccountBlacklist` (r:2 w:0)
/// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::BannedAssets` (r:2 w:0)
/// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::Assets` (r:2 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`)
/// The range of component `c` is `[1, 2]`.
/// The range of component `b` is `[0, 1]`.
fn calculate_and_execute_buy_in_lbp(c: u32, b: u32) -> Weight {
fn calculate_and_execute_buy_in_lbp(c: u32, b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1567 + b * (1418 ±0)`
// Measured: `1604 + b * (1837 ±0)`
// Estimated: `6156 + b * (7749 ±0)`
// Minimum execution time: 75_646_000 picoseconds.
Weight::from_parts(76_052_000, 6156)
// Standard Error: 1_389_058
.saturating_add(Weight::from_parts(4_096_946, 0).saturating_mul(c.into()))
// Standard Error: 3_000_708
.saturating_add(Weight::from_parts(250_139_938, 0).saturating_mul(b.into()))
// Minimum execution time: 75_256_000 picoseconds.
Weight::from_parts(76_245_000, 6156)
// Standard Error: 604_587
.saturating_add(Weight::from_parts(2_376_809, 0).saturating_mul(c.into()))
// Standard Error: 1_327_242
.saturating_add(Weight::from_parts(273_173_826, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().reads((9_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 7749).saturating_mul(b.into()))
}
/// Storage: `AssetRegistry::Assets` (r:6 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`)
/// Storage: `Router::Routes` (r:1 w:1)
/// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Accounts` (r:9 w:0)
/// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
/// Storage: `Tokens::TotalIssuance` (r:2 w:0)
/// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::Assets` (r:3 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:4 w:0)
/// Storage: `System::Account` (r:7 w:0)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Accounts` (r:15 w:0)
/// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
/// Storage: `XYK::ShareToken` (r:6 w:0)
/// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `Duster::AccountBlacklist` (r:7 w:0)
/// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::BannedAssets` (r:5 w:0)
/// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0)
/// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:3 w:0)
/// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:5 w:0)
/// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
/// Storage: `XYK::ShareToken` (r:3 w:0)
/// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `EmaOracle::Accumulator` (r:1 w:0)
/// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`)
/// Storage: `Tokens::TotalIssuance` (r:1 w:0)
/// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
fn set_route_for_xyk() -> Weight {
// Proof Size summary in bytes:
// Measured: `4201`
// Estimated: `24237`
// Minimum execution time: 1_126_027_000 picoseconds.
Weight::from_parts(1_133_155_000, 24237)
.saturating_add(T::DbWeight::get().reads(27_u64))
// Measured: `6326`
// Estimated: `39735`
// Minimum execution time: 2_275_922_000 picoseconds.
Weight::from_parts(2_284_697_000, 39735)
.saturating_add(T::DbWeight::get().reads(55_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `Router::Routes` (r:0 w:1)
/// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`)
fn force_insert_route() -> Weight {
// Proof Size summary in bytes:
// Measured: `1012`
// Estimated: `0`
// Minimum execution time: 30_072_000 picoseconds.
Weight::from_parts(30_421_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}

// For backwards compatibility and tests
// For backwards compatibility and tests.
impl WeightInfo for () {
/// Storage: `LBP::PoolData` (r:1 w:0)
/// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`)
Expand All @@ -148,18 +167,22 @@ impl WeightInfo for () {
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Locks` (r:1 w:1)
/// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`)
/// Storage: `Duster::AccountBlacklist` (r:2 w:0)
/// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::BannedAssets` (r:2 w:0)
/// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::Assets` (r:2 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`)
/// The range of component `c` is `[0, 1]`.
fn calculate_and_execute_sell_in_lbp(c: u32) -> Weight {
fn calculate_and_execute_sell_in_lbp(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `3016`
// Measured: `3436`
// Estimated: `13905`
// Minimum execution time: 316_311_000 picoseconds.
Weight::from_parts(318_353_450, 13905)
// Standard Error: 164_994
.saturating_add(Weight::from_parts(50_546_750, 0).saturating_mul(c.into()))
.saturating_add(RocksDbWeight::get().reads(12_u64))
// Minimum execution time: 342_467_000 picoseconds.
Weight::from_parts(346_028_529, 13905)
// Standard Error: 185_098
.saturating_add(Weight::from_parts(50_586_970, 0).saturating_mul(c.into()))
.saturating_add(RocksDbWeight::get().reads(16_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
/// Storage: `LBP::PoolData` (r:1 w:0)
Expand All @@ -170,50 +193,68 @@ impl WeightInfo for () {
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Locks` (r:1 w:1)
/// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`)
/// Storage: `Duster::AccountBlacklist` (r:2 w:0)
/// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::BannedAssets` (r:2 w:0)
/// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::Assets` (r:2 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`)
/// The range of component `c` is `[1, 2]`.
/// The range of component `b` is `[0, 1]`.
fn calculate_and_execute_buy_in_lbp(c: u32, b: u32) -> Weight {
fn calculate_and_execute_buy_in_lbp(c: u32, b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1567 + b * (1418 ±0)`
// Measured: `1604 + b * (1837 ±0)`
// Estimated: `6156 + b * (7749 ±0)`
// Minimum execution time: 75_646_000 picoseconds.
Weight::from_parts(76_052_000, 6156)
// Standard Error: 1_389_058
.saturating_add(Weight::from_parts(4_096_946, 0).saturating_mul(c.into()))
// Standard Error: 3_000_708
.saturating_add(Weight::from_parts(250_139_938, 0).saturating_mul(b.into()))
// Minimum execution time: 75_256_000 picoseconds.
Weight::from_parts(76_245_000, 6156)
// Standard Error: 604_587
.saturating_add(Weight::from_parts(2_376_809, 0).saturating_mul(c.into()))
// Standard Error: 1_327_242
.saturating_add(Weight::from_parts(273_173_826, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().reads((9_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 7749).saturating_mul(b.into()))
}
/// Storage: `AssetRegistry::Assets` (r:6 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`)
/// Storage: `Router::Routes` (r:1 w:1)
/// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Accounts` (r:9 w:0)
/// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
/// Storage: `Tokens::TotalIssuance` (r:2 w:0)
/// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::Assets` (r:3 w:0)
/// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:4 w:0)
/// Storage: `System::Account` (r:7 w:0)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Tokens::Accounts` (r:15 w:0)
/// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
/// Storage: `XYK::ShareToken` (r:6 w:0)
/// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `Duster::AccountBlacklist` (r:7 w:0)
/// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::BannedAssets` (r:5 w:0)
/// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0)
/// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:3 w:0)
/// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:5 w:0)
/// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
/// Storage: `XYK::ShareToken` (r:3 w:0)
/// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `EmaOracle::Accumulator` (r:1 w:0)
/// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`)
/// Storage: `Tokens::TotalIssuance` (r:1 w:0)
/// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
fn set_route_for_xyk() -> Weight {
// Proof Size summary in bytes:
// Measured: `4201`
// Estimated: `24237`
// Minimum execution time: 1_126_027_000 picoseconds.
Weight::from_parts(1_133_155_000, 24237)
.saturating_add(RocksDbWeight::get().reads(27_u64))
// Measured: `6326`
// Estimated: `39735`
// Minimum execution time: 2_275_922_000 picoseconds.
Weight::from_parts(2_284_697_000, 39735)
.saturating_add(RocksDbWeight::get().reads(55_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `Router::Routes` (r:0 w:1)
/// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`)
fn force_insert_route() -> Weight {
// Proof Size summary in bytes:
// Measured: `1012`
// Estimated: `0`
// Minimum execution time: 30_072_000 picoseconds.
Weight::from_parts(30_421_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
5 changes: 5 additions & 0 deletions runtime/hydradx/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,11 @@ impl AmmTradeWeights<Trade<AssetId>> for RouterWeightInfo {

weight
}

fn force_insert_route_weight() -> Weight {
//Since we don't have any AMM specific thing in the extrinsic, we just return the plain weight
weights::route_executor::HydraWeight::<Runtime>::force_insert_route()
}
}

parameter_types! {
Expand Down
Loading

0 comments on commit 0d1fc9e

Please sign in to comment.