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

Add Proof Size to Weight Output #11637

Merged
merged 114 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
02d79f4
initial impl
shawntabrizi Jun 10, 2022
0c8651c
add template test
shawntabrizi Jun 10, 2022
6571394
linear fit proof size
shawntabrizi Jun 10, 2022
9d22002
always record proof when tracking storage
shawntabrizi Jun 10, 2022
b05dca2
calculate worst case pov
shawntabrizi Jun 11, 2022
04e8d61
remove duplicate worst case
shawntabrizi Jun 11, 2022
1ab7c34
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 11, 2022
1d6d2e7
cargo run --quiet --profile=production --features=runtime-benchmarks…
Jun 11, 2022
5d52c9c
more comment output
shawntabrizi Jun 11, 2022
34c4467
Merge branch 'shawntabrizi-pov-in-cli' of https://github.com/parityte…
shawntabrizi Jun 11, 2022
97acc2d
add cli for worst case map size
shawntabrizi Jun 11, 2022
651f347
update name
shawntabrizi Jun 11, 2022
9d0bdf9
clap does not support underscores
shawntabrizi Jun 11, 2022
7c542d8
rename
shawntabrizi Jun 11, 2022
625593e
expose worst case map values
shawntabrizi Jun 12, 2022
dfc55b4
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 12, 2022
49c8132
improve some comments
shawntabrizi Jun 12, 2022
baeddb3
cargo run --quiet --profile=production --features=runtime-benchmarks…
Jun 12, 2022
9d11567
Merge branch 'shawntabrizi-pov-in-cli' of https://github.com/parityte…
shawntabrizi Jun 12, 2022
232cb97
Merge branch 'master' into shawntabrizi-pov-in-cli
shawntabrizi Jun 12, 2022
7a9a3d8
update template
shawntabrizi Jun 12, 2022
6a0cf76
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 13, 2022
c8cd738
cargo run --quiet --profile=production --features=runtime-benchmarks…
Jun 13, 2022
7c55e48
Merge branch 'master' into shawntabrizi-pov-in-cli
shawntabrizi Jul 10, 2022
e5e549f
Merge branch 'master' into shawntabrizi-pov-in-cli
shawntabrizi Aug 9, 2022
8b272c4
fix fmt
shawntabrizi Aug 9, 2022
f2baa71
more fmt
shawntabrizi Aug 9, 2022
3b44d68
more fmt
shawntabrizi Aug 10, 2022
26daf32
Merge branch 'master' into shawntabrizi-pov-in-cli
shawntabrizi Sep 7, 2022
b6f849b
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
ggwpez Oct 14, 2022
b5fedc4
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
ggwpez Dec 2, 2022
a5ddf1f
Dont panic when there is no proof
ggwpez Dec 17, 2022
c0a4bc5
Fix test features
ggwpez Dec 17, 2022
3108f6a
Whitelist :extrinsic_index
ggwpez Dec 17, 2022
8eb47ec
Use whitelist when recording proof
ggwpez Dec 17, 2022
309c0cb
Add logs
ggwpez Dec 17, 2022
9926aef
Add PoV testing pallet
ggwpez Dec 17, 2022
96a4b0d
Deploy PoV testing pallet
ggwpez Dec 17, 2022
c48bcc9
Storage benches reside in the PoV pallet
ggwpez Dec 17, 2022
824785d
Linear regress PoV per component
ggwpez Dec 17, 2022
27a335b
Put PoV into the weight templates
ggwpez Dec 17, 2022
21d89aa
fmt
ggwpez Dec 17, 2022
9e7a9f9
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
ggwpez Dec 17, 2022
ba83ba6
Extra alanysis choise for PoV
ggwpez Dec 17, 2022
879cf5b
Add+Fix tests
ggwpez Dec 17, 2022
2b19fa1
Make benches faster
ggwpez Dec 17, 2022
b1f89b8
Cleanup
ggwpez Dec 17, 2022
c19e84a
Use same template comments
ggwpez Dec 19, 2022
66a2d9b
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
ggwpez Dec 19, 2022
9da76e0
".git/.scripts/bench-bot.sh" pallet dev pallet_balances
Dec 19, 2022
cca1f74
".git/.scripts/bench-bot.sh" pallet dev pallet_democracy
Dec 19, 2022
170c358
Update referenda mock BlockWeights
ggwpez Dec 19, 2022
afb4a88
Take measured value size into account
ggwpez Dec 20, 2022
774b383
clippy
ggwpez Dec 20, 2022
43b2cdb
Merge branch 'master' of https://github.com/paritytech/substrate into…
Dec 20, 2022
cd5b536
".git/.scripts/bench-bot.sh" pallet dev pallet_scheduler
Dec 20, 2022
8ddaa2f
WIP
ggwpez Dec 21, 2022
fe5caf9
proof_size: None
ggwpez Dec 21, 2022
c34b538
WIP
ggwpez Dec 22, 2022
d69e0c4
WIP
ggwpez Dec 22, 2022
dc1410f
WIP
ggwpez Dec 22, 2022
906c60e
ugly, but works
ggwpez Dec 22, 2022
1e02140
WIP
ggwpez Dec 22, 2022
5595b55
WIP
ggwpez Dec 22, 2022
3a39968
WIP
ggwpez Dec 22, 2022
74dde1e
wup
ggwpez Dec 22, 2022
61b749e
WIP
ggwpez Dec 22, 2022
2e96402
WIP
ggwpez Dec 22, 2022
3991122
WIP
ggwpez Dec 22, 2022
4c84f87
WIP
ggwpez Dec 22, 2022
3bc2ec5
Add pov_mode attribute to the benchmarks! macro
ggwpez Jan 4, 2023
f2b8c8e
Use pov_mode attribute in PoV benchmarking
ggwpez Jan 4, 2023
b000667
Update tests
ggwpez Jan 4, 2023
8e631b3
Scheduler, Whitelist: Add pov_mode attr
ggwpez Jan 4, 2023
2f3ac23
Update PoV weights
Jan 4, 2023
5acb33a
Add CLI arg: default-pov-mode
ggwpez Jan 4, 2023
e2006ed
Fix tests
ggwpez Jan 4, 2023
21b1c64
fmt
ggwpez Jan 4, 2023
442394a
Merge remote-tracking branch 'server/oty-proof-size-attribute' into s…
ggwpez Jan 4, 2023
0a4829d
fix
ggwpez Jan 4, 2023
697eef7
Revert "Update PoV weights"
ggwpez Jan 4, 2023
95bfa49
Revert "WIP"
ggwpez Jan 4, 2023
467477e
Revert first approach
ggwpez Jan 4, 2023
debbc07
Clippy
ggwpez Jan 4, 2023
213e340
Add extra benchmarks
ggwpez Jan 4, 2023
9fe83c5
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jan 4, 2023
a82f20a
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_alliance
Jan 4, 2023
46fa61a
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_whitelist
Jan 4, 2023
81e6723
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_scheduler
Jan 4, 2023
9ac907d
fmt
ggwpez Jan 4, 2023
637641b
Clippy
ggwpez Jan 4, 2023
9bd0c3d
Clippy 🤦
ggwpez Jan 4, 2023
1b87727
Add reference benchmarks
ggwpez Jan 5, 2023
29b8eed
Fix doc comments
ggwpez Jan 5, 2023
c52210f
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
Jan 6, 2023
3dd9a4c
Undo logging
ggwpez Jan 7, 2023
44dce06
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
ggwpez Jan 7, 2023
6bc569b
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
ggwpez Jan 20, 2023
a4bd72c
Add 'Ignored' pov_mode
ggwpez Jan 20, 2023
52f460b
Allow multiple attributes per benchmark
ggwpez Jan 23, 2023
4ea47d9
Validate pov_mode syntax
ggwpez Jan 23, 2023
8878ab0
Ignore PoV for all contract benchmarks
ggwpez Jan 23, 2023
5af9771
Test
ggwpez Jan 23, 2023
b5438b2
test
ggwpez Jan 23, 2023
545f26f
Bump macro recursion limit
ggwpez Jan 23, 2023
fc33556
fmt
ggwpez Jan 23, 2023
b77fb33
Update contract weights
ggwpez Jan 23, 2023
d988e35
Merge remote-tracking branch 'origin/master' into shawntabrizi-pov-in…
ggwpez Jan 23, 2023
20633ea
fix test ffs
ggwpez Jan 23, 2023
4a6a3e7
pov_mode is unsupported in V2 syntax
ggwpez Jan 23, 2023
f45c2f8
Fix pallet ui tests
ggwpez Jan 23, 2023
74f84d6
update pallet ui
ggwpez Jan 24, 2023
2674325
Fix pallet ui tests
ggwpez Jan 24, 2023
047cf4f
Update weights
ggwpez Jan 25, 2023
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
35 changes: 28 additions & 7 deletions .maintain/frame-weight-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//! Autogenerated weights for {{pallet}}
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}`
//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: `{{cmd.repeat}}`, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}`
//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}`
//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}`
//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}}

Expand Down Expand Up @@ -38,7 +39,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
{{/if}}
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
// {{comment}}
/// {{comment}}
{{/each}}
{{#each benchmark.component_ranges as |range|}}
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
Expand All @@ -48,24 +49,34 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
// Proof Size summary in bytes:
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds.
{{#if (ne benchmark.base_calculated_proof_size "0")}}
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
{{else}}
Weight::from_ref_time({{underscore benchmark.base_weight}})
{{/if}}
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into()))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}))
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into())))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}))
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
{{/each}}
{{#each benchmark.component_calculated_proof_size as |cp|}}
.saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into()))
{{/each}}
}
{{/each}}
}
Expand All @@ -74,7 +85,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
impl WeightInfo for () {
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
// {{comment}}
/// {{comment}}
{{/each}}
{{#each benchmark.component_ranges as |range|}}
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
Expand All @@ -84,24 +95,34 @@ impl WeightInfo for () {
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
// Proof Size summary in bytes:
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds.
{{#if (ne benchmark.base_calculated_proof_size "0")}}
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
{{else}}
Weight::from_ref_time({{underscore benchmark.base_weight}})
{{/if}}
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into()))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}}))
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}}_u64))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(RocksDbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into())))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}}))
.saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}}_u64))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
{{/each}}
{{#each benchmark.component_calculated_proof_size as |cp|}}
.saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into()))
{{/each}}
}
{{/each}}
}
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ members = [
"frame/beefy-mmr",
"frame/beefy-mmr/primitives",
"frame/benchmarking",
"frame/benchmarking/pov",
"frame/bounties",
"frame/child-bounties",
"frame/collective",
Expand Down
8 changes: 6 additions & 2 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ sp-io = { version = "7.0.0", default-features = false, path = "../../../primitiv

# frame dependencies
frame-executive = { version = "4.0.0-dev", default-features = false, path = "../../../frame/executive" }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking", optional = true }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking" }
frame-benchmarking-pallet-pov = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking/pov" }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system" }
frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
Expand Down Expand Up @@ -178,7 +179,8 @@ std = [
"sp-session/std",
"pallet-sudo/std",
"frame-support/std",
"frame-benchmarking?/std",
"frame-benchmarking/std",
"frame-benchmarking-pallet-pov/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-election-provider-multi-phase/std",
Expand Down Expand Up @@ -208,6 +210,7 @@ std = [
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-benchmarking-pallet-pov/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
Expand Down Expand Up @@ -262,6 +265,7 @@ runtime-benchmarks = [
]
try-runtime = [
"frame-try-runtime/try-runtime",
"frame-benchmarking-pallet-pov/try-runtime",
"frame-executive/try-runtime",
"frame-system/try-runtime",
"frame-support/try-runtime",
Expand Down
6 changes: 6 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,10 @@ impl pallet_alliance::Config for Runtime {
type RetirementPeriod = RetirementPeriod;
}

impl frame_benchmarking_pallet_pov::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
}

construct_runtime!(
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -1757,6 +1761,7 @@ construct_runtime!(
RankedCollective: pallet_ranked_collective,
FastUnstake: pallet_fast_unstake,
MessageQueue: pallet_message_queue,
Pov: frame_benchmarking_pallet_pov,
}
);

Expand Down Expand Up @@ -1829,6 +1834,7 @@ extern crate frame_benchmarking;
mod benches {
define_benchmarks!(
[frame_benchmarking, BaselineBench::<Runtime>]
[frame_benchmarking_pallet_pov, Pov]
[pallet_alliance, Alliance]
[pallet_assets, Assets]
[pallet_babe, Babe]
Expand Down
4 changes: 4 additions & 0 deletions client/db/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,14 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
let proof_recorder_root = self.proof_recorder_root.get();
if proof_recorder_root == Default::default() || proof_size == 1 {
// empty trie
log::debug!(target: "benchmark", "Some proof size: {}", &proof_size);
proof_size
} else {
if let Some(size) = proof.encoded_compact_size::<HashFor<B>>(proof_recorder_root) {
size as u32
} else if proof_recorder_root == self.root.get() {
log::debug!(target: "benchmark", "No changes - no proof");
0
} else {
panic!(
"proof rec root {:?}, root {:?}, genesis {:?}, rec_len {:?}",
Expand Down
2 changes: 1 addition & 1 deletion client/db/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn version_file_path(path: &Path) -> PathBuf {
file_path
}

#[cfg(test)]
#[cfg(all(test, feature = "rocksdb"))]
mod tests {
use super::*;
use crate::{tests::Block, DatabaseSource};
Expand Down
7 changes: 5 additions & 2 deletions client/db/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,12 @@ mod tests {
use super::*;
use codec::Input;
use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper};
use std::path::PathBuf;
type Block = RawBlock<ExtrinsicWrapper<u32>>;

#[cfg(any(feature = "rocksdb", test))]
#[cfg(feature = "rocksdb")]
#[test]
fn database_type_subdir_migration() {
use std::path::PathBuf;
type Block = RawBlock<ExtrinsicWrapper<u64>>;

fn check_dir_for_db_type(
Expand Down Expand Up @@ -685,6 +685,7 @@ mod tests {
assert_eq!(joined.remaining_len().unwrap(), Some(0));
}

#[cfg(feature = "rocksdb")]
#[test]
fn test_open_database_auto_new() {
let db_dir = tempfile::TempDir::new().unwrap();
Expand Down Expand Up @@ -730,6 +731,7 @@ mod tests {
}
}

#[cfg(feature = "rocksdb")]
#[test]
fn test_open_database_rocksdb_new() {
let db_dir = tempfile::TempDir::new().unwrap();
Expand Down Expand Up @@ -780,6 +782,7 @@ mod tests {
}
}

#[cfg(feature = "rocksdb")]
#[test]
fn test_open_database_paritydb_new() {
let db_dir = tempfile::TempDir::new().unwrap();
Expand Down
Loading