Skip to content

Commit 6471833

Browse files
committed
feat: remove frame_system benchmark, add frame_system_extensions benchmark
1 parent fd15f97 commit 6471833

File tree

6 files changed

+157
-69
lines changed

6 files changed

+157
-69
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copied from: https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2503/substrate/.maintain/frame-weight-template.hbs
2+
3+
// This file is part of Substrate.
4+
5+
// Copyright (C) Parity Technologies (UK) Ltd.
6+
// SPDX-License-Identifier: Apache-2.0
7+
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
20+
{{header}}
21+
//! Autogenerated weights for `{{pallet}}`
22+
//!
23+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
24+
//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: `{{cmd.repeat}}`, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}`
25+
//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}`
26+
//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}`
27+
//! WASM-EXECUTION: `{{cmd.wasm_execution}}`, CHAIN: `{{cmd.chain}}`, DB CACHE: `{{cmd.db_cache}}`
28+
29+
// Executed Command:
30+
{{#each args as |arg|}}
31+
// {{arg}}
32+
{{/each}}
33+
34+
#![cfg_attr(rustfmt, rustfmt_skip)]
35+
#![allow(unused_parens)]
36+
#![allow(unused_imports)]
37+
#![allow(missing_docs)]
38+
#![allow(dead_code)]
39+
40+
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
41+
use core::marker::PhantomData;
42+
43+
/// Weights for `{{pallet}}` using the Substrate node and recommended hardware.
44+
pub struct WeightInfo<T>(PhantomData<T>);
45+
impl<T: frame_system::Config> frame_system::ExtensionsWeightInfo for WeightInfo<T> {
46+
{{#each benchmarks as |benchmark|}}
47+
{{#each benchmark.comments as |comment|}}
48+
/// {{comment}}
49+
{{/each}}
50+
{{#each benchmark.component_ranges as |range|}}
51+
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
52+
{{/each}}
53+
fn {{benchmark.name~}}
54+
(
55+
{{~#each benchmark.components as |c| ~}}
56+
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
57+
) -> Weight {
58+
// Proof Size summary in bytes:
59+
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
60+
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
61+
// Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds.
62+
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
63+
{{#each benchmark.component_weight as |cw|}}
64+
// Standard Error: {{underscore cw.error}}
65+
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
66+
{{/each}}
67+
{{#if (ne benchmark.base_reads "0")}}
68+
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64))
69+
{{/if}}
70+
{{#each benchmark.component_reads as |cr|}}
71+
.saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into())))
72+
{{/each}}
73+
{{#if (ne benchmark.base_writes "0")}}
74+
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64))
75+
{{/if}}
76+
{{#each benchmark.component_writes as |cw|}}
77+
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
78+
{{/each}}
79+
{{#each benchmark.component_calculated_proof_size as |cp|}}
80+
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
81+
{{/each}}
82+
}
83+
{{/each}}
84+
}

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
],
1616
// Set the features to use for cargo commands
1717
"rust-analyzer.cargo.features": [
18-
"frequency-no-relay",
1918
"runtime-benchmarks",
2019
"frequency-lint-check"
2120
],

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ benchmarks-handles \
157157
benchmarks-time-release \
158158
benchmarks-passkey \
159159
benchmarks-cumulus_pallet_weight_reclaim \
160+
benchmarks-frame_system_extensions \
160161
benchmarks-pallet_balances \
161162
benchmarks-pallet_collator_selection \
162163
benchmarks-pallet_democracy \
@@ -181,6 +182,7 @@ benchmarks-handles-local \
181182
benchmarks-passkey-local \
182183
benchmarks-time-release-local \
183184
benchmarks-cumulus_pallet_weight_reclaim-local \
185+
benchmarks-frame_system_extensions-local \
184186
benchmarks-pallet_balances-local \
185187
benchmarks-pallet_collator_selection-local \
186188
benchmarks-pallet_collective-local \
Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,124 @@
1-
// Copyright (C) Parity Technologies (UK) Ltd.
2-
// This file is part of Cumulus.
1+
// Copied from: https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2503/substrate/.maintain/frame-weight-template.hbs
2+
3+
// This file is part of Substrate.
34

4-
// Cumulus is free software: you can redistribute it and/or modify
5-
// it under the terms of the GNU General Public License as published by
6-
// the Free Software Foundation, either version 3 of the License, or
7-
// (at your option) any later version.
5+
// Copyright (C) Parity Technologies (UK) Ltd.
6+
// SPDX-License-Identifier: Apache-2.0
87

9-
// Cumulus is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU General Public License for more details.
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
1319

14-
// You should have received a copy of the GNU General Public License
15-
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
1620

1721
//! Autogenerated weights for `frame_system_extensions`
1822
//!
19-
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
20-
//! DATE: 2023-12-21, STEPS: `2`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
23+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 47.0.0
24+
//! DATE: 2025-04-18, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
2125
//! WORST CASE MAP SIZE: `1000000`
22-
//! HOSTNAME: `gleipnir`, CPU: `AMD Ryzen 9 7900X 12-Core Processor`
23-
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024
26+
//! HOSTNAME: `Joes-Work-MBP.local`, CPU: `<UNKNOWN>`
27+
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
2428
2529
// Executed Command:
26-
// ./target/release/polkadot-parachain
30+
// ./scripts/../target/bench-dev/frequency
2731
// benchmark
2832
// pallet
29-
// --wasm-execution=compiled
3033
// --pallet=frame_system_extensions
31-
// --no-storage-info
32-
// --no-median-slopes
33-
// --no-min-squares
34-
// --extrinsic=*
35-
// --steps=2
36-
// --repeat=2
37-
// --json
38-
// --header=./cumulus/file_header.txt
39-
// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/
40-
// --chain=asset-hub-rococo-dev
34+
// --extrinsic
35+
// *
36+
// --heap-pages=4096
37+
// --steps=50
38+
// --repeat=20
39+
// --output=./scripts/../runtime/common/src/weights
40+
// --template=./scripts/../.maintain/frame-system-extensions-weight-template.hbs
41+
// --additional-trie-layers=3
42+
// --runtime=./scripts/../target/bench-dev/wbuild/frequency-runtime/frequency_runtime.wasm
43+
// --genesis-builder=runtime
4144

4245
#![cfg_attr(rustfmt, rustfmt_skip)]
4346
#![allow(unused_parens)]
4447
#![allow(unused_imports)]
4548
#![allow(missing_docs)]
49+
#![allow(dead_code)]
4650

47-
use frame_support::{traits::Get, weights::Weight};
51+
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
4852
use core::marker::PhantomData;
4953

50-
/// Weight functions for `frame_system_extensions`.
54+
/// Weights for `frame_system_extensions` using the Substrate node and recommended hardware.
5155
pub struct WeightInfo<T>(PhantomData<T>);
5256
impl<T: frame_system::Config> frame_system::ExtensionsWeightInfo for WeightInfo<T> {
53-
/// Storage: `System::BlockHash` (r:1 w:0)
54-
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
5557
fn check_genesis() -> Weight {
5658
// Proof Size summary in bytes:
5759
// Measured: `30`
58-
// Estimated: `3509`
59-
// Minimum execution time: 3_388_000 picoseconds.
60-
Weight::from_parts(3_577_000, 3509)
61-
.saturating_add(T::DbWeight::get().reads(1_u64))
60+
// Estimated: `0`
61+
// Minimum execution time: 2_000_000 picoseconds.
62+
Weight::from_parts(3_000_000, 0)
6263
}
63-
/// Storage: `System::BlockHash` (r:1 w:0)
64-
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
6564
fn check_mortality_mortal_transaction() -> Weight {
6665
// Proof Size summary in bytes:
6766
// Measured: `68`
68-
// Estimated: `3509`
69-
// Minimum execution time: 6_442_000 picoseconds.
70-
Weight::from_parts(6_703_000, 3509)
71-
.saturating_add(T::DbWeight::get().reads(1_u64))
67+
// Estimated: `0`
68+
// Minimum execution time: 5_000_000 picoseconds.
69+
Weight::from_parts(6_000_000, 0)
7270
}
73-
/// Storage: `System::BlockHash` (r:1 w:0)
74-
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
7571
fn check_mortality_immortal_transaction() -> Weight {
7672
// Proof Size summary in bytes:
7773
// Measured: `68`
78-
// Estimated: `3509`
79-
// Minimum execution time: 6_357_000 picoseconds.
80-
Weight::from_parts(6_605_000, 3509)
81-
.saturating_add(T::DbWeight::get().reads(1_u64))
74+
// Estimated: `0`
75+
// Minimum execution time: 5_000_000 picoseconds.
76+
Weight::from_parts(5_000_000, 0)
8277
}
8378
fn check_non_zero_sender() -> Weight {
8479
// Proof Size summary in bytes:
8580
// Measured: `0`
8681
// Estimated: `0`
87-
// Minimum execution time: 457_000 picoseconds.
88-
Weight::from_parts(570_000, 0)
82+
// Minimum execution time: 0_000 picoseconds.
83+
Weight::from_parts(1_000_000, 0)
8984
}
9085
/// Storage: `System::Account` (r:1 w:1)
9186
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
9287
fn check_nonce() -> Weight {
9388
// Proof Size summary in bytes:
9489
// Measured: `101`
95-
// Estimated: `3593`
96-
// Minimum execution time: 6_936_000 picoseconds.
97-
Weight::from_parts(7_261_000, 3593)
90+
// Estimated: `4088`
91+
// Minimum execution time: 5_000_000 picoseconds.
92+
Weight::from_parts(6_000_000, 4088)
9893
.saturating_add(T::DbWeight::get().reads(1_u64))
9994
.saturating_add(T::DbWeight::get().writes(1_u64))
10095
}
10196
fn check_spec_version() -> Weight {
10297
// Proof Size summary in bytes:
10398
// Measured: `0`
10499
// Estimated: `0`
105-
// Minimum execution time: 336_000 picoseconds.
106-
Weight::from_parts(430_000, 0)
100+
// Minimum execution time: 0_000 picoseconds.
101+
Weight::from_parts(0, 0)
107102
}
108103
fn check_tx_version() -> Weight {
109104
// Proof Size summary in bytes:
110105
// Measured: `0`
111106
// Estimated: `0`
112-
// Minimum execution time: 348_000 picoseconds.
113-
Weight::from_parts(455_000, 0)
107+
// Minimum execution time: 0_000 picoseconds.
108+
Weight::from_parts(0, 0)
114109
}
115110
fn check_weight() -> Weight {
116111
// Proof Size summary in bytes:
117112
// Measured: `0`
118113
// Estimated: `0`
119-
// Minimum execution time: 2_887_000 picoseconds.
120-
Weight::from_parts(3_006_000, 0)
114+
// Minimum execution time: 3_000_000 picoseconds.
115+
Weight::from_parts(4_000_000, 0)
121116
}
122-
/// Storage: `System::AllExtrinsicsLen` (r:1 w:1)
123-
/// Proof: `System::AllExtrinsicsLen` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
124117
fn weight_reclaim() -> Weight {
125118
// Proof Size summary in bytes:
126-
// Measured: `24`
127-
// Estimated: `1489`
128-
// Minimum execution time: 4_375_000 picoseconds.
129-
Weight::from_parts(4_747_000, 1489)
130-
.saturating_add(T::DbWeight::get().reads(1_u64))
131-
.saturating_add(T::DbWeight::get().writes(1_u64))
119+
// Measured: `0`
120+
// Estimated: `0`
121+
// Minimum execution time: 2_000_000 picoseconds.
122+
Weight::from_parts(2_000_000, 0)
132123
}
133-
}
124+
}

runtime/frequency/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,7 @@ mod benches {
13951395
define_benchmarks!(
13961396
// Substrate
13971397
[frame_system, SystemBench::<Runtime>]
1398+
[frame_system_extensions, SystemExtensionsBench::<Runtime>]
13981399
[cumulus_pallet_weight_reclaim, WeightReclaim]
13991400
[pallet_balances, Balances]
14001401
[pallet_collective, Council]
@@ -1751,6 +1752,7 @@ sp_api::impl_runtime_apis! {
17511752
use frame_benchmarking::{BenchmarkList};
17521753
use frame_support::traits::StorageInfoTrait;
17531754
use frame_system_benchmarking::Pallet as SystemBench;
1755+
use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
17541756
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
17551757

17561758
let mut list = Vec::<BenchmarkList>::new();
@@ -1769,6 +1771,8 @@ sp_api::impl_runtime_apis! {
17691771
use frame_system_benchmarking::Pallet as SystemBench;
17701772
impl frame_system_benchmarking::Config for Runtime {}
17711773

1774+
use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
1775+
17721776
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
17731777
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
17741778

scripts/run_benchmarks.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PROFILE=release
77
PROFILE_DIR=${PROFILE}
88

99
ALL_EXTERNAL_PALLETS=( \
10+
frame_system_extensions \
1011
cumulus_pallet_weight_reclaim \
1112
pallet_balances \
1213
pallet_collator_selection \
@@ -179,6 +180,13 @@ ${OVERHEAD}"
179180

180181
function run_benchmark() {
181182
echo "Running benchmarks for ${1}"
183+
184+
TEMPLATE=${5}
185+
if [[ ${1} == "frame_system_extensions" ]]
186+
then
187+
TEMPLATE=${PROJECT}/.maintain/frame-system-extensions-weight-template.hbs
188+
fi
189+
182190
set -x
183191
set -e
184192
${BENCHMARK} pallet \

0 commit comments

Comments
 (0)