Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
New weights using i7 machine (#5848)
Browse files Browse the repository at this point in the history
* i7 weights

* fix full block test

* fix merge

* fix priority
  • Loading branch information
shawntabrizi authored May 1, 2020
1 parent 58edbf4 commit c386dea
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 43 deletions.
4 changes: 2 additions & 2 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ parameter_types! {
/// This probably should not be changed unless you have specific
/// disk i/o conditions for the node.
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 60_000_000, // ~0.06 ms = ~60 µs
write: 200_000_000, // ~0.2 ms = 200 µs
read: 25_000_000, // ~25 µs
write: 100_000_000, // ~100 µs
};
}

Expand Down
13 changes: 8 additions & 5 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ fn full_native_block_import_works() {
phase: Phase::ApplyExtrinsic(0),
// timestamp set call with weight 9_000_000 + 2 read + 1 write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 9_000_000 + 2 * 60_000_000 + 1 * 200_000_000, class: DispatchClass::Mandatory, ..Default::default() }
DispatchInfo { weight: 9_000_000 + 2 * 25_000_000 + 1 * 100_000_000, class: DispatchClass::Mandatory, ..Default::default() }
)),
topics: vec![],
},
Expand All @@ -359,8 +359,9 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
// Balance Transfer 80_000_000 + 1 Read + 1 Write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 460_000_000, ..Default::default() }
DispatchInfo { weight: 80_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
)),
topics: vec![],
},
Expand Down Expand Up @@ -393,7 +394,7 @@ fn full_native_block_import_works() {
phase: Phase::ApplyExtrinsic(0),
// timestamp set call with weight 9_000_000 + 2 read + 1 write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 9_000_000 + 2 * 60_000_000 + 1 * 200_000_000, class: DispatchClass::Mandatory, ..Default::default() }
DispatchInfo { weight: 9_000_000 + 2 * 25_000_000 + 1 * 100_000_000, class: DispatchClass::Mandatory, ..Default::default() }
)),
topics: vec![],
},
Expand All @@ -415,8 +416,9 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
// Balance Transfer 80_000_000 + 1 Read + 1 Write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 460_000_000, ..Default::default() }
DispatchInfo { weight: 80_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
)),
topics: vec![],
},
Expand All @@ -438,8 +440,9 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
// Balance Transfer 80_000_000 + 1 Read + 1 Write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 460_000_000, ..Default::default() }
DispatchInfo { weight: 80_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
)),
topics: vec![],
},
Expand Down
2 changes: 1 addition & 1 deletion bin/node/executor/tests/submit_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn submitted_transaction_should_be_valid() {
let res = Executive::validate_transaction(source, extrinsic);

assert_eq!(res.unwrap(), ValidTransaction {
priority: 1_411_390_000_000,
priority: 1_410_625_000_000,
requires: vec![],
provides: vec![(address, 0).encode()],
longevity: 128,
Expand Down
4 changes: 2 additions & 2 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ parameter_types! {
pub const Version: RuntimeVersion = VERSION;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 60_000_000, // ~0.06 ms = ~60 µs
write: 200_000_000, // ~0.2 ms = 200 µs
read: 25_000_000, // ~25 µs
write: 100_000_000, // ~100 µs
};
}

Expand Down
21 changes: 16 additions & 5 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,12 @@ decl_module! {
/// - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced`.
/// - `transfer_keep_alive` works the same way as `transfer`, but has an additional
/// check that the transfer will not kill the origin account.
///
/// ---------------------------------
/// - Base Weight: 80 µs, worst case scenario (account created, account removed)
/// - 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) + 200_000_000]
#[weight = T::DbWeight::get().reads_writes(1, 1) + 80_000_000]
pub fn transfer(
origin,
dest: <T::Lookup as StaticLookup>::Source,
Expand All @@ -456,8 +459,11 @@ decl_module! {
/// # <weight>
/// - Independent of the arguments.
/// - Contains a limited number of reads and writes.
/// ---------------------
/// - Base Weight: 32.6 µs
/// - DB Weight: 1 Read, 1 Write to `who`
/// # </weight>
#[weight = T::DbWeight::get().reads_writes(1, 1) + 100_000_000]
#[weight = T::DbWeight::get().reads_writes(1, 1) + 35_000_000]
fn set_balance(
origin,
who: <T::Lookup as StaticLookup>::Source,
Expand Down Expand Up @@ -499,7 +505,7 @@ 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) + 200_000_000]
#[weight = T::DbWeight::get().reads_writes(2, 2) + 80_000_000]
pub fn force_transfer(
origin,
source: <T::Lookup as StaticLookup>::Source,
Expand All @@ -518,7 +524,12 @@ decl_module! {
/// 99% of the time you want [`transfer`] instead.
///
/// [`transfer`]: struct.Module.html#method.transfer
#[weight = T::DbWeight::get().reads_writes(1, 1) + 150_000_000]
/// # <weight>
/// - Cheaper than transfer because account cannot be killed.
/// - Base Weight: 57.36 µs
/// - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
/// #</weight>
#[weight = T::DbWeight::get().reads_writes(1, 1) + 60_000_000]
pub fn transfer_keep_alive(
origin,
dest: <T::Lookup as StaticLookup>::Source,
Expand Down
38 changes: 19 additions & 19 deletions frame/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,17 @@ mod weight_of {
use super::*;

/// - Base Weight:
/// - Create: 137.5 + 0.274 * S µs
/// - Approve: 103.8 + .266 * S µs
/// - Complete: 116.2 + .754 * S µs
/// - Create: 59.2 + 0.096 * S µs
/// - Approve: 42.27 + .116 * S µs
/// - Complete: 50.91 + .232 * S µs
/// - DB Weight:
/// - Reads: Multisig Storage, [Caller Account]
/// - Writes: Multisig Storage, [Caller Account]
/// - Plus Call Weight
pub fn as_multi<T: Trait>(other_sig_len: usize, call_weight: Weight) -> Weight {
call_weight
.saturating_add(150_000_000)
.saturating_add((other_sig_len as Weight).saturating_mul(750_000))
.saturating_add(60_000_000)
.saturating_add((other_sig_len as Weight).saturating_mul(250_000))
.saturating_add(T::DbWeight::get().reads_writes(1, 1))
}
}
Expand All @@ -236,7 +236,7 @@ decl_module! {
/// - `calls`: The calls to be dispatched from the same origin.
///
/// # <weight>
/// - Base weight: 63.78 µs
/// - Base weight: 15.64 + .987 * c µs
/// - Plus the sum of the weights of the `calls`.
/// - Plus one additional event. (repeat read/write)
/// # </weight>
Expand All @@ -250,7 +250,7 @@ decl_module! {
|args: (&Vec<<T as Trait>::Call>,)| {
args.0.iter()
.map(|call| call.get_dispatch_info().weight)
.fold(65_000_000, |a: Weight, n| a.saturating_add(n))
.fold(15_000_000, |a: Weight, n| a.saturating_add(n).saturating_add(1_000_000))
},
|args: (&Vec<<T as Trait>::Call>,)| {
let all_operational = args.0.iter()
Expand Down Expand Up @@ -280,12 +280,12 @@ decl_module! {
/// The dispatch origin for this call must be _Signed_.
///
/// # <weight>
/// - Base weight: 5.1 µs
/// - Base weight: 2.863 µs
/// - Plus the weight of the `call`
/// # </weight>
#[weight = FunctionOf(
|args: (&u16, &Box<<T as Trait>::Call>)| {
args.1.get_dispatch_info().weight.saturating_add(5_000_000)
args.1.get_dispatch_info().weight.saturating_add(3_000_000)
},
|args: (&u16, &Box<<T as Trait>::Call>)| args.1.get_dispatch_info().class,
Pays::Yes,
Expand Down Expand Up @@ -339,9 +339,9 @@ decl_module! {
/// `MultisigDepositBase + threshold * MultisigDepositFactor`.
/// -------------------------------
/// - Base Weight:
/// - Create: 137.5 + 0.274 * S µs
/// - Approve: 103.8 + .266 * S µs
/// - Complete: 116.2 + .754 * S µs
/// - Create: 59.2 + 0.096 * S µs
/// - Approve: 42.27 + .116 * S µs
/// - Complete: 50.91 + .232 * S µs
/// - DB Weight:
/// - Reads: Multisig Storage, [Caller Account]
/// - Writes: Multisig Storage, [Caller Account]
Expand Down Expand Up @@ -471,17 +471,17 @@ decl_module! {
/// `MultisigDepositBase + threshold * MultisigDepositFactor`.
/// ----------------------------------
/// - Base Weight:
/// - Create: 139.1 + 0.202 * S
/// - Approve: 96.6 + 0.328 * S
/// - Create: 56.3 + 0.107 * S
/// - Approve: 39.25 + 0.121 * S
/// - DB Weight:
/// - Read: Multisig Storage, [Caller Account]
/// - Write: Multisig Storage, [Caller Account]
/// # </weight>
#[weight = FunctionOf(
|args: (&u16, &Vec<T::AccountId>, &Option<Timepoint<T::BlockNumber>>, &[u8; 32])| {
T::DbWeight::get().reads_writes(1, 1)
.saturating_add(140_000_000)
.saturating_add((args.1.len() as Weight).saturating_mul(350_000))
.saturating_add(60_000_000)
.saturating_add((args.1.len() as Weight).saturating_mul(120_000))
},
DispatchClass::Normal,
Pays::Yes,
Expand Down Expand Up @@ -554,16 +554,16 @@ decl_module! {
/// - I/O: 1 read `O(S)`, one remove.
/// - Storage: removes one item.
/// ----------------------------------
/// - Base Weight: 126.6 + 0.126 * S
/// - Base Weight: 46.71 + 0.09 * S
/// - DB Weight:
/// - Read: Multisig Storage, [Caller Account]
/// - Write: Multisig Storage, [Caller Account]
/// # </weight>
#[weight = FunctionOf(
|args: (&u16, &Vec<T::AccountId>, &Timepoint<T::BlockNumber>, &[u8; 32])| {
T::DbWeight::get().reads_writes(1, 1)
.saturating_add(130_000_000)
.saturating_add((args.1.len() as Weight).saturating_mul(130_000))
.saturating_add(50_000_000)
.saturating_add((args.1.len() as Weight).saturating_mul(100_000))
},
DispatchClass::Normal,
Pays::Yes,
Expand Down
22 changes: 13 additions & 9 deletions frame/vesting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ decl_module! {
/// - DbWeight: 2 Reads, 2 Writes
/// - Reads: Vesting Storage, Balances Locks, [Sender Account]
/// - Writes: Vesting Storage, Balances Locks, [Sender Account]
/// - Benchmark: 147.5 µs (min square analysis)
/// - Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// - Benchmark:
/// - Unlocked: 56.1 + .098 * l µs (min square analysis)
/// - Locked: 54.37 + .254 * l µs (min square analysis)
/// - Using 60 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// # </weight>
#[weight = 150_000_000 + T::DbWeight::get().reads_writes(2, 2)]
#[weight = 60_000_000 + T::DbWeight::get().reads_writes(2, 2)]
fn vest(origin) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::update_lock(who)
Expand All @@ -216,10 +218,12 @@ decl_module! {
/// - DbWeight: 3 Reads, 3 Writes
/// - Reads: Vesting Storage, Balances Locks, Target Account
/// - Writes: Vesting Storage, Balances Locks, Target Account
/// - Benchmark: 150.4 µs (min square analysis)
/// - Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// - Benchmark:
/// - Unlocked: 58.09 + .104 * l µs (min square analysis)
/// - Locked: 55.35 + .255 * l µs (min square analysis)
/// - Using 60 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// # </weight>
#[weight = 150_000_000 + T::DbWeight::get().reads_writes(3, 3)]
#[weight = 60_000_000 + T::DbWeight::get().reads_writes(3, 3)]
fn vest_other(origin, target: <T::Lookup as StaticLookup>::Source) -> DispatchResult {
ensure_signed(origin)?;
Self::update_lock(T::Lookup::lookup(target)?)
Expand All @@ -240,10 +244,10 @@ decl_module! {
/// - DbWeight: 3 Reads, 3 Writes
/// - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account]
/// - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
/// - Benchmark: 263 µs (min square analysis)
/// - Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// - Benchmark: 111.4 + .345 * l µs (min square analysis)
/// - Using 115 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// # </weight>
#[weight = 300_000_000 + T::DbWeight::get().reads_writes(3, 3)]
#[weight = 115_000_000 + T::DbWeight::get().reads_writes(3, 3)]
pub fn vested_transfer(
origin,
target: <T::Lookup as StaticLookup>::Source,
Expand Down

0 comments on commit c386dea

Please sign in to comment.