WeightInfo for System, Timestamp, and Utility (#6868)

* initial updates to system

* fix compile

* Update writer.rs

* update weights

* finish system weights

* timestamp weights

* utility weight

* Fix overflow in weight calculations

* add back weight notes

* Update for whitelisted benchmarks

* add trait bounds

* Revert "add trait bounds"

This reverts commit 12b08b7189aa3969f96fa19b211a370860fdb240.

* Update weights for unaccounted for read
This commit is contained in:
Shawn Tabrizi
2020-08-17 22:59:23 +02:00
committed by GitHub
parent 93c73b6509
commit 74a583d147
14 changed files with 316 additions and 68 deletions
@@ -0,0 +1,57 @@
// This file is part of Substrate.
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
#![allow(unused_parens)]
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
impl crate::WeightInfo for () {
// WARNING! Some components were not used: ["b"]
fn remark() -> Weight {
(1305000 as Weight)
}
fn set_heap_pages() -> Weight {
(2023000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["d"]
fn set_changes_trie_config() -> Weight {
(10026000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn set_storage(i: u32, ) -> Weight {
(0 as Weight)
.saturating_add((656000 as Weight).saturating_mul(i as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_storage(i: u32, ) -> Weight {
(4327000 as Weight)
.saturating_add((478000 as Weight).saturating_mul(i as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_prefix(p: u32, ) -> Weight {
(8349000 as Weight)
.saturating_add((838000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
}
fn suicide() -> Weight {
(29247000 as Weight)
}
}
+12 -26
View File
@@ -139,6 +139,7 @@ mod extensions;
mod weights;
#[cfg(test)]
mod tests;
mod default_weights;
pub use extensions::{
check_mortality::CheckMortality, check_genesis::CheckGenesis, check_nonce::CheckNonce,
@@ -159,25 +160,13 @@ pub fn extrinsics_data_root<H: Hash>(xts: Vec<Vec<u8>>) -> H::Output {
}
pub trait WeightInfo {
fn remark(b: u32, ) -> Weight;
fn set_heap_pages(i: u32, ) -> Weight;
fn set_code_without_checks(b: u32, ) -> Weight;
fn set_changes_trie_config(d: u32, ) -> Weight;
fn remark() -> Weight;
fn set_heap_pages() -> Weight;
fn set_changes_trie_config() -> Weight;
fn set_storage(i: u32, ) -> Weight;
fn kill_storage(i: u32, ) -> Weight;
fn kill_prefix(p: u32, ) -> Weight;
fn suicide(n: u32, ) -> Weight;
}
impl WeightInfo for () {
fn remark(_b: u32, ) -> Weight { 1_000_000_000 }
fn set_heap_pages(_i: u32, ) -> Weight { 1_000_000_000 }
fn set_code_without_checks(_b: u32, ) -> Weight { 1_000_000_000 }
fn set_changes_trie_config(_d: u32, ) -> Weight { 1_000_000_000 }
fn set_storage(_i: u32, ) -> Weight { 1_000_000_000 }
fn kill_storage(_i: u32, ) -> Weight { 1_000_000_000 }
fn kill_prefix(_p: u32, ) -> Weight { 1_000_000_000 }
fn suicide(_n: u32, ) -> Weight { 1_000_000_000 }
fn suicide() -> Weight;
}
pub trait Trait: 'static + Eq + Clone {
@@ -564,7 +553,7 @@ decl_module! {
/// - Base Weight: 0.665 µs, independent of remark length.
/// - No DB operations.
/// # </weight>
#[weight = 700_000]
#[weight = T::SystemWeightInfo::remark()]
fn remark(origin, _remark: Vec<u8>) {
ensure_signed(origin)?;
}
@@ -577,7 +566,7 @@ decl_module! {
/// - Base Weight: 1.405 µs
/// - 1 write to HEAP_PAGES
/// # </weight>
#[weight = (T::DbWeight::get().writes(1) + 1_500_000, DispatchClass::Operational)]
#[weight = (T::SystemWeightInfo::set_heap_pages(), DispatchClass::Operational)]
fn set_heap_pages(origin, pages: u64) {
ensure_root(origin)?;
storage::unhashed::put_raw(well_known_keys::HEAP_PAGES, &pages.encode());
@@ -627,7 +616,7 @@ decl_module! {
/// - DB Weight:
/// - Writes: Changes Trie, System Digest
/// # </weight>
#[weight = (T::DbWeight::get().writes(2) + 10_000_000, DispatchClass::Operational)]
#[weight = (T::SystemWeightInfo::set_changes_trie_config(), DispatchClass::Operational)]
pub fn set_changes_trie_config(origin, changes_trie_config: Option<ChangesTrieConfiguration>) {
ensure_root(origin)?;
match changes_trie_config.clone() {
@@ -653,8 +642,7 @@ decl_module! {
/// - Writes: Number of items
/// # </weight>
#[weight = (
T::DbWeight::get().writes(items.len() as Weight)
.saturating_add((items.len() as Weight).saturating_mul(600_000)),
T::SystemWeightInfo::set_storage(items.len() as u32),
DispatchClass::Operational,
)]
fn set_storage(origin, items: Vec<KeyValue>) {
@@ -673,8 +661,7 @@ decl_module! {
/// - Writes: Number of items
/// # </weight>
#[weight = (
T::DbWeight::get().writes(keys.len() as Weight)
.saturating_add((keys.len() as Weight).saturating_mul(400_000)),
T::SystemWeightInfo::kill_storage(keys.len() as u32),
DispatchClass::Operational,
)]
fn kill_storage(origin, keys: Vec<Key>) {
@@ -696,8 +683,7 @@ decl_module! {
/// - Writes: Number of subkeys + 1
/// # </weight>
#[weight = (
T::DbWeight::get().writes(Weight::from(*_subkeys) + 1)
.saturating_add((Weight::from(*_subkeys) + 1).saturating_mul(850_000)),
T::SystemWeightInfo::kill_prefix(_subkeys.saturating_add(1)),
DispatchClass::Operational,
)]
fn kill_prefix(origin, prefix: Key, _subkeys: u32) {
@@ -715,7 +701,7 @@ decl_module! {
/// Base Weight: 8.626 µs
/// No DB Read or Write operations because caller is already in overlay
/// # </weight>
#[weight = (10_000_000, DispatchClass::Operational)]
#[weight = (T::SystemWeightInfo::suicide(), DispatchClass::Operational)]
pub fn suicide(origin) {
let who = ensure_signed(origin)?;
let account = Account::<T>::get(&who);