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

WeightInfo for System, Timestamp, and Utility #6868

Merged
15 commits merged into from
Aug 17, 2020
Next Next commit
initial updates to system
  • Loading branch information
shawntabrizi committed Aug 5, 2020
commit 8672f1bda20a2a65bf9a9c0fd4489271282c6abc
64 changes: 64 additions & 0 deletions bin/node/runtime/src/weights/frame_system.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// 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 {
(1385000 as Weight)
}
// WARNING! Some components were not used: ["i"]
fn set_heap_pages() -> Weight {
(2098000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["b"]
fn set_code_without_checks() -> Weight {
(21572000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["d"]
fn set_changes_trie_config() -> Weight {
(10546000 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((654000 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 {
(4210000 as Weight)
.saturating_add((490000 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 {
(11452000 as Weight)
.saturating_add((831000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
}
// WARNING! Some components were not used: ["n"]
fn suicide() -> Weight {
(30017000 as Weight)
}
}
18 changes: 6 additions & 12 deletions frame/system/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,24 @@ benchmarks! {
_ { }

remark {
// # of Bytes
let b in 0 .. 16_384;
let remark_message = vec![1; b as usize];
let remark_message = vec![1; 16_384 as usize];
let caller = account("caller", 0, SEED);
}: _(RawOrigin::Signed(caller), remark_message)

set_heap_pages {
// Heap page size
let i in 0 .. u32::max_value();
}: _(RawOrigin::Root, i.into())
}: _(RawOrigin::Root, Default::default())

// `set_code` was not benchmarked because it is pretty hard to come up with a real
// Wasm runtime to test the upgrade with. But this is okay because we will make
// `set_code` take a full block anyway.

set_code_without_checks {
// Version number
let b in 0 .. 16_384;
let code = vec![1; b as usize];
// Assume Wasm ~4MB
let code = vec![1; 4_000_000 as usize];
}: _(RawOrigin::Root, code)
verify {
let current_code = storage::unhashed::get_raw(well_known_keys::CODE).ok_or("Code not stored.")?;
assert_eq!(current_code.len(), b as usize);
assert_eq!(current_code.len(), 4_000_000 as usize);
}

set_changes_trie_config {
Expand Down Expand Up @@ -141,10 +136,9 @@ benchmarks! {
}

suicide {
let n in 1 .. 1000;
let caller: T::AccountId = account("caller", 0, SEED);
let account_info = AccountInfo::<T::Index, T::AccountData> {
nonce: n.into(),
nonce: 1337,
refcount: 0,
data: T::AccountData::default()
};
Expand Down
64 changes: 64 additions & 0 deletions frame/system/src/default_weights.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// 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 {
(1385000 as Weight)
}
// WARNING! Some components were not used: ["i"]
fn set_heap_pages() -> Weight {
(2098000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["b"]
fn set_code_without_checks() -> Weight {
(21572000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["d"]
fn set_changes_trie_config() -> Weight {
(10546000 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((654000 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 {
(4210000 as Weight)
.saturating_add((490000 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 {
(11452000 as Weight)
.saturating_add((831000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
}
// WARNING! Some components were not used: ["n"]
fn suicide() -> Weight {
(30017000 as Weight)
}
}
22 changes: 6 additions & 16 deletions frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -159,25 +160,14 @@ 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_code_without_checks() -> 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 {
Expand Down
7 changes: 7 additions & 0 deletions utils/frame/benchmarking-cli/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ pub fn write_results(batches: &[BenchmarkBatch]) -> Result<(), std::io::Error> {
VERSION,
)?;

// allow statements
write!(
file,
"#![allow(unused_parens)]\n\n",
VERSION,
)?;

// general imports
write!(
file,
Expand Down