Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7468464
initial mockup
shawntabrizi Jun 17, 2020
947d68c
add and wipe
shawntabrizi Jun 17, 2020
9c77f50
track writes
shawntabrizi Jun 17, 2020
2f198b9
start to add to pipeline
shawntabrizi Jun 18, 2020
12395ae
return all reads/writes
shawntabrizi Jun 18, 2020
69f137d
Log reads and writes from bench db
shawntabrizi Jun 18, 2020
60f22c3
causes panic
shawntabrizi Jun 18, 2020
e08ffef
Allow multiple commits
arkpar Jun 18, 2020
86ecbeb
commit before ending benchmark
shawntabrizi Jun 18, 2020
f7305a2
Merge branch 'master' into shawntabrizi-bench-db-tracking
shawntabrizi Jun 18, 2020
004bea1
doesn't work???
shawntabrizi Jun 18, 2020
1b25a8b
fix
shawntabrizi Jun 18, 2020
c995215
Update lib.rs
shawntabrizi Jun 18, 2020
2eef7fa
switch to struct for `BenchmarkResults`
shawntabrizi Jun 18, 2020
473f492
add to output
shawntabrizi Jun 18, 2020
0ae5300
fix test
shawntabrizi Jun 18, 2020
fd99bda
line width
shawntabrizi Jun 18, 2020
79cd015
@kianenigma review
shawntabrizi Jun 18, 2020
9464475
Add Whitelist to DB Tracking in Benchmarks Pipeline (#6405)
shawntabrizi Jun 20, 2020
956cda1
Add regression analysis to DB Tracking (#6475)
shawntabrizi Jun 22, 2020
962a3f5
initial idea
shawntabrizi Jun 23, 2020
c3e9639
use all benchmarks
shawntabrizi Jun 23, 2020
87dfc19
broken
shawntabrizi Jun 23, 2020
6f82848
working without trait
shawntabrizi Jun 23, 2020
78ca73e
Make work for multiple pallets
shawntabrizi Jun 23, 2020
decc972
Merge branch 'master' into shawntabrizi-output-benchmarks
shawntabrizi Jun 27, 2020
b38d82e
Fix merge issues
shawntabrizi Jun 27, 2020
ccff2e1
writer appends to file
shawntabrizi Jun 28, 2020
02f69ff
implement () for balances weight trait
shawntabrizi Jul 2, 2020
e51814a
Merge branch 'master' into shawntabrizi-output-benchmarks
shawntabrizi Jul 2, 2020
aa17f5c
update name of trait
shawntabrizi Jul 2, 2020
c83c7fb
Weights to WeightInfo
shawntabrizi Jul 2, 2020
b29eef1
auto trait writer
shawntabrizi Jul 2, 2020
b2b7205
Start adding weight info
shawntabrizi Jul 2, 2020
4eda4bc
More weightinfo
shawntabrizi Jul 2, 2020
9dfa60d
finish weight info
shawntabrizi Jul 2, 2020
464c2f2
more fixes
shawntabrizi Jul 3, 2020
2c5e0ff
inital update of node runtime
shawntabrizi Jul 3, 2020
9aa9267
Initial benchmarks
shawntabrizi Jul 3, 2020
415fb0d
Add staking weights
shawntabrizi Jul 3, 2020
cff48e2
Heap pages are configurable
shawntabrizi Jul 3, 2020
b359b5a
fix the rest of the compilation
shawntabrizi Jul 3, 2020
7e11dd6
Update vesting weights
shawntabrizi Jul 3, 2020
bdc6742
Update weight formulas for Vesting
shawntabrizi Jul 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/node-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl system::Trait for Test {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
impl Trait for Test {
type Event = ();
Expand Down
4 changes: 4 additions & 0 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ impl system::Trait for Runtime {
type OnKilledAccount = ();
/// The data to be stored in an account.
type AccountData = balances::AccountData<Balance>;
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = ();
}

impl aura::Trait for Runtime {
Expand Down Expand Up @@ -221,6 +223,7 @@ impl timestamp::Trait for Runtime {
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}

parameter_types! {
Expand All @@ -235,6 +238,7 @@ impl balances::Trait for Runtime {
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}

parameter_types! {
Expand Down
1,434 changes: 1,434 additions & 0 deletions bin/node/runtime/src/benchmarks.rs

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ use impls::{CurrencyToVoteHandler, Author};
pub mod constants;
use constants::{time::*, currency::*};

pub mod benchmarks;

// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
Expand Down Expand Up @@ -171,11 +173,13 @@ impl frame_system::Trait for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}

impl pallet_utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type WeightInfo = benchmarks::WeightForUtility;
}

parameter_types! {
Expand All @@ -193,6 +197,7 @@ impl pallet_multisig::Trait for Runtime {
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = benchmarks::WeightForMultisig;
}

parameter_types! {
Expand Down Expand Up @@ -246,6 +251,7 @@ impl pallet_proxy::Trait for Runtime {
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type WeightInfo = benchmarks::WeightForProxy;
}

parameter_types! {
Expand All @@ -259,6 +265,7 @@ impl pallet_scheduler::Trait for Runtime {
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type WeightInfo = benchmarks::WeightForScheduler;
}

parameter_types! {
Expand All @@ -281,6 +288,7 @@ impl pallet_indices::Trait for Runtime {
type Currency = Balances;
type Deposit = IndexDeposit;
type Event = Event;
type WeightInfo = benchmarks::WeightForIndices;
}

parameter_types! {
Expand All @@ -293,6 +301,7 @@ impl pallet_balances::Trait for Runtime {
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Module<Runtime>;
type WeightInfo = benchmarks::WeightForBalances;
}

parameter_types! {
Expand All @@ -319,6 +328,7 @@ impl pallet_timestamp::Trait for Runtime {
type Moment = Moment;
type OnTimestampSet = Babe;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = benchmarks::WeightForTimestamp;
}

parameter_types! {
Expand Down Expand Up @@ -355,6 +365,7 @@ impl pallet_session::Trait for Runtime {
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
type WeightInfo = benchmarks::WeightForSession;
}

impl pallet_session::historical::Trait for Runtime {
Expand Down Expand Up @@ -411,6 +422,7 @@ impl pallet_staking::Trait for Runtime {
type MinSolutionScoreBump = MinSolutionScoreBump;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type UnsignedPriority = StakingUnsignedPriority;
type WeightInfo = benchmarks::WeightForStaking;
}

parameter_types! {
Expand Down Expand Up @@ -459,6 +471,7 @@ impl pallet_democracy::Trait for Runtime {
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type WeightInfo = benchmarks::WeightForDemocracy;
}

parameter_types! {
Expand All @@ -473,6 +486,7 @@ impl pallet_collective::Trait<CouncilCollective> for Runtime {
type Event = Event;
type MotionDuration = CouncilMotionDuration;
type MaxProposals = CouncilMaxProposals;
type WeightInfo = benchmarks::WeightForCollective;
}

parameter_types! {
Expand Down Expand Up @@ -504,6 +518,7 @@ impl pallet_elections_phragmen::Trait for Runtime {
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration;
type WeightInfo = benchmarks::WeightForElections;
}

parameter_types! {
Expand All @@ -518,6 +533,7 @@ impl pallet_collective::Trait<TechnicalCollective> for Runtime {
type Event = Event;
type MotionDuration = TechnicalMotionDuration;
type MaxProposals = TechnicalMaxProposals;
type WeightInfo = benchmarks::WeightForCollective;
}

type EnsureRootOrHalfCouncil = EnsureOneOf<
Expand Down Expand Up @@ -572,6 +588,7 @@ impl pallet_treasury::Trait for Runtime {
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type WeightInfo = benchmarks::WeightForTreasury;
}

parameter_types! {
Expand Down Expand Up @@ -673,6 +690,7 @@ impl pallet_im_online::Trait for Runtime {
type SessionDuration = SessionDuration;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ImOnlineUnsignedPriority;
type WeightInfo = benchmarks::WeightForImOnline;
}

parameter_types! {
Expand All @@ -684,6 +702,7 @@ impl pallet_offences::Trait for Runtime {
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type WeightSoftLimit = OffencesWeightSoftLimit;
type WeightInfo = benchmarks::WeightForOffences;
}

impl pallet_authority_discovery::Trait for Runtime {}
Expand Down Expand Up @@ -742,6 +761,7 @@ impl pallet_identity::Trait for Runtime {
type Slashed = Treasury;
type ForceOrigin = EnsureRootOrHalfCouncil;
type RegistrarOrigin = EnsureRootOrHalfCouncil;
type WeightInfo = benchmarks::WeightForIdentity;
}

parameter_types! {
Expand Down Expand Up @@ -791,13 +811,16 @@ impl pallet_society::Trait for Runtime {

parameter_types! {
pub const MinVestedTransfer: Balance = 100 * DOLLARS;
pub const LocksUpperBound: u32 = 50;
}

impl pallet_vesting::Trait for Runtime {
type Event = Event;
type Currency = Balances;
type BlockNumberToBalance = ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = benchmarks::WeightForVesting;
type LocksUpperBound = LocksUpperBound;
}

construct_runtime!(
Expand Down
1 change: 1 addition & 0 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ mod tests {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
impl Trait for Test {
type Event = ();
Expand Down
2 changes: 2 additions & 0 deletions frame/atomic-swap/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl frame_system::Trait for Test {
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
Expand All @@ -64,6 +65,7 @@ impl pallet_balances::Trait for Test {
type Event = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const ProofLimit: u32 = 1024;
Expand Down
2 changes: 2 additions & 0 deletions frame/aura/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ impl frame_system::Trait for Test {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}

impl pallet_timestamp::Trait for Test {
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}

impl Trait for Test {
Expand Down
2 changes: 2 additions & 0 deletions frame/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ mod tests {
type ValidatorIdOf = ConvertInto;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type WeightInfo = ();
}

impl pallet_session::historical::Trait for Test {
Expand Down Expand Up @@ -167,6 +168,7 @@ mod tests {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}

impl_outer_origin! {
Expand Down
1 change: 1 addition & 0 deletions frame/authorship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ mod tests {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}

parameter_types! {
Expand Down
3 changes: 3 additions & 0 deletions frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl frame_system::Trait for Test {
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}

impl_opaque_keys! {
Expand All @@ -99,12 +100,14 @@ impl pallet_session::Trait for Test {
type Keys = MockSessionKeys;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
type NextSessionRotation = Babe;
type WeightInfo = ();
}

impl pallet_timestamp::Trait for Test {
type Moment = u64;
type OnTimestampSet = Babe;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}

impl Trait for Test {
Expand Down
33 changes: 29 additions & 4 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ use sp_std::prelude::*;
use sp_std::{cmp, result, mem, fmt::Debug, ops::BitOr, convert::Infallible};
use codec::{Codec, Encode, Decode};
use frame_support::{
weights::Weight,
StorageValue, Parameter, decl_event, decl_storage, decl_module, decl_error, ensure,
traits::{
Currency, OnKilledAccount, OnUnbalanced, TryDrop, StoredMap,
Expand Down Expand Up @@ -188,6 +189,24 @@ pub trait Subtrait<I: Instance = DefaultInstance>: frame_system::Trait {

/// The means of storing the balances of an account.
type AccountStore: StoredMap<Self::AccountId, AccountData<Self::Balance>>;

type WeightInfo: WeightInfo;
}

pub trait WeightInfo {
fn transfer(u: u32, e: u32, ) -> Weight;
fn transfer_best_case(u: u32, e: u32, ) -> Weight;
fn transfer_keep_alive(u: u32, e: u32, ) -> Weight;
fn set_balance(u: u32, e: u32, ) -> Weight;
fn set_balance_killing(u: u32, e: u32, ) -> Weight;
}

impl WeightInfo for () {
fn transfer(_u: u32, _e: u32, ) -> Weight { 1_000_000_000 }
fn transfer_best_case(_u: u32, _e: u32, ) -> Weight { 1_000_000_000 }
fn transfer_keep_alive(_u: u32, _e: u32, ) -> Weight { 1_000_000_000 }
fn set_balance(_u: u32, _e: u32, ) -> Weight { 1_000_000_000 }
fn set_balance_killing(_u: u32, _e: u32, ) -> Weight { 1_000_000_000 }
}

pub trait Trait<I: Instance = DefaultInstance>: frame_system::Trait {
Expand All @@ -206,12 +225,15 @@ pub trait Trait<I: Instance = DefaultInstance>: frame_system::Trait {

/// The means of storing the balances of an account.
type AccountStore: StoredMap<Self::AccountId, AccountData<Self::Balance>>;

type WeightInfo: WeightInfo;
}

impl<T: Trait<I>, I: Instance> Subtrait<I> for T {
type Balance = T::Balance;
type ExistentialDeposit = T::ExistentialDeposit;
type AccountStore = T::AccountStore;
type WeightInfo = <T as Trait<I>>::WeightInfo;
}

decl_event!(
Expand Down Expand Up @@ -437,7 +459,7 @@ decl_module! {
/// - DB Weight: 1 Read and 1 Write to destination account
/// - Origin account is already in memory, so no DB operations for them.
/// # </weight>
#[weight = T::DbWeight::get().reads_writes(1, 1) + 70_000_000]
#[weight = T::WeightInfo::transfer(0,0)]
pub fn transfer(
origin,
dest: <T::Lookup as StaticLookup>::Source,
Expand Down Expand Up @@ -466,7 +488,7 @@ decl_module! {
/// - Killing: 35.11 µs
/// - DB Weight: 1 Read, 1 Write to `who`
/// # </weight>
#[weight = T::DbWeight::get().reads_writes(1, 1) + 35_000_000]
#[weight = T::WeightInfo::set_balance(0, 0)]
fn set_balance(
origin,
who: <T::Lookup as StaticLookup>::Source,
Expand Down Expand Up @@ -508,7 +530,8 @@ decl_module! {
/// - Same as transfer, but additional read and write because the source account is
/// not assumed to be in the overlay.
/// # </weight>
#[weight = T::DbWeight::get().reads_writes(2, 2) + 70_000_000]
// TODO: ADD NEW BENCHMARK
#[weight = T::WeightInfo::transfer(0,0)]
pub fn force_transfer(
origin,
source: <T::Lookup as StaticLookup>::Source,
Expand All @@ -532,7 +555,7 @@ decl_module! {
/// - Base Weight: 51.4 µs
/// - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
/// #</weight>
#[weight = T::DbWeight::get().reads_writes(1, 1) + 50_000_000]
#[weight = T::WeightInfo::transfer_keep_alive(0,0)]
pub fn transfer_keep_alive(
origin,
dest: <T::Lookup as StaticLookup>::Source,
Expand Down Expand Up @@ -872,13 +895,15 @@ impl<T: Subtrait<I>, I: Instance> frame_system::Trait for ElevatedTrait<T, I> {
type OnNewAccount = T::OnNewAccount;
type OnKilledAccount = T::OnKilledAccount;
type AccountData = T::AccountData;
type SystemWeightInfo = T::SystemWeightInfo;
}
impl<T: Subtrait<I>, I: Instance> Trait<I> for ElevatedTrait<T, I> {
type Balance = T::Balance;
type Event = ();
type DustRemoval = ();
type ExistentialDeposit = T::ExistentialDeposit;
type AccountStore = T::AccountStore;
type WeightInfo = <T as Subtrait<I>>::WeightInfo;
}

impl<T: Trait<I>, I: Instance> Currency<T::AccountId> for Module<T, I> where
Expand Down
Loading