forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[subsystem-benchmarks] Add statement-distribution benchmarks (parityt…
…ech#3863) Fixes paritytech#3748 Adds a subsystem benchmark for statements-distribution subsystem. Results in CI (reference hw): ``` $ cargo bench -p polkadot-statement-distribution --bench statement-distribution-regression-bench --features subsystem-benchmarks [Sent to peers] standart_deviation 0.07% [Received from peers] standart_deviation 0.00% [statement-distribution] standart_deviation 0.97% [test-environment] standart_deviation 1.03% Network usage, KiB total per block Received from peers 1088.0000 108.8000 Sent to peers 1238.1800 123.8180 CPU usage, seconds total per block statement-distribution 0.3897 0.0390 test-environment 0.4715 0.0472 ```
- Loading branch information
1 parent
7a630f9
commit e9e0861
Showing
22 changed files
with
1,480 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...ot/node/network/statement-distribution/benches/statement-distribution-regression-bench.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! statement-distribution regression tests | ||
//! | ||
//! Statement distribution benchmark based on Kusama parameters and scale. | ||
|
||
use polkadot_subsystem_bench::{ | ||
configuration::TestConfiguration, | ||
statement::{benchmark_statement_distribution, prepare_test, TestState}, | ||
usage::BenchmarkUsage, | ||
utils::save_to_file, | ||
}; | ||
use std::io::Write; | ||
|
||
const BENCH_COUNT: usize = 50; | ||
|
||
fn main() -> Result<(), String> { | ||
let mut messages = vec![]; | ||
let mut config = TestConfiguration::default(); | ||
config.n_cores = 100; | ||
config.n_validators = 500; | ||
config.num_blocks = 10; | ||
config.connectivity = 100; | ||
config.generate_pov_sizes(); | ||
let state = TestState::new(&config); | ||
|
||
println!("Benchmarking..."); | ||
let usages: Vec<BenchmarkUsage> = (0..BENCH_COUNT) | ||
.map(|n| { | ||
print!("\r[{}{}]", "#".repeat(n), "_".repeat(BENCH_COUNT - n)); | ||
std::io::stdout().flush().unwrap(); | ||
let (mut env, _cfgs) = prepare_test(&state, false); | ||
env.runtime().block_on(benchmark_statement_distribution( | ||
"statement-distribution", | ||
&mut env, | ||
&state, | ||
)) | ||
}) | ||
.collect(); | ||
println!("\rDone!{}", " ".repeat(BENCH_COUNT)); | ||
|
||
let average_usage = BenchmarkUsage::average(&usages); | ||
save_to_file( | ||
"charts/statement-distribution-regression-bench.json", | ||
average_usage.to_chart_json().map_err(|e| e.to_string())?, | ||
) | ||
.map_err(|e| e.to_string())?; | ||
println!("{}", average_usage); | ||
|
||
// We expect no variance for received and sent | ||
// but use 0.001 because we operate with floats | ||
messages.extend(average_usage.check_network_usage(&[ | ||
("Received from peers", 106.4000, 0.001), | ||
("Sent to peers", 127.9100, 0.001), | ||
])); | ||
messages.extend(average_usage.check_cpu_usage(&[("statement-distribution", 0.0390, 0.1)])); | ||
|
||
if messages.is_empty() { | ||
Ok(()) | ||
} else { | ||
eprintln!("{}", messages.join("\n")); | ||
Err("Regressions found".to_string()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
polkadot/node/subsystem-bench/examples/statement_distribution.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
TestConfiguration: | ||
- objective: StatementDistribution | ||
num_blocks: 10 | ||
n_cores: 100 | ||
n_validators: 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.