-
Notifications
You must be signed in to change notification settings - Fork 742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[subsystem-benchmarks] Add statement-distribution benchmarks #3863
Merged
AndreiEres
merged 43 commits into
master
from
AndreiEres/statement-distr-subsystem-bench
May 27, 2024
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
e25bd4a
Init
AndreiEres 4208c5e
Merge branch 'master' into AndreiEres/statement-distr-subsystem-bench
AndreiEres 42f2a55
Add a skeleton
AndreiEres 3b4f88e
wip
AndreiEres c507c53
Merge branch 'master' into AndreiEres/statement-distr-subsystem-bench
AndreiEres 0e474ce
Add first iteration
AndreiEres 6780cf5
Merge branch 'master' into AndreiEres/statement-distr-subsystem-bench
AndreiEres 4ff06ab
update
AndreiEres c190589
update
AndreiEres 9151571
update
AndreiEres 0ec77eb
remove redundant
AndreiEres d4abb60
Generate candidates for all cores
AndreiEres 99890cd
Don't rely on full connectivity
AndreiEres 6cf9f78
Receive manifests from neighbors
AndreiEres e7fb543
Optimize neighbors messages
AndreiEres dcba6d0
Polish
AndreiEres 8ccf3cc
Update
AndreiEres 560a5d5
Reset trackers
AndreiEres daf901f
Add benchmarks
AndreiEres 4685d9f
Update test state
AndreiEres 011a7e7
Remove unused vars
AndreiEres 1512ff8
Fix manifest missing
AndreiEres cc683e3
Move validator pairs to test authorities
AndreiEres ea1fd83
Make HandleNetworkMessage async
AndreiEres e29320f
Request a candidate from own backing group
AndreiEres b8ac639
Update var names
AndreiEres 45a86ce
Use context to send messages
AndreiEres 6f225a9
Add minimum_backing_votes to config
AndreiEres 2b5944f
Remove todos
AndreiEres a78eeb7
Remove redundant vars
AndreiEres ba526b6
Remove redundant Debug
AndreiEres 50cd03a
Polish
AndreiEres 0b46d4b
Merge branch 'master' into AndreiEres/statement-distr-subsystem-bench
AndreiEres 0ffe859
Fyx GetHypotheticalMembership
AndreiEres 24f26b0
Fix clippy
AndreiEres e212386
Remove clippy rule
AndreiEres c5119d5
Update baselines
AndreiEres 74d477f
Use generic peer connected generation
AndreiEres 0405d9d
Use MockCandidateBackingState
AndreiEres 8775d70
Use AsyncBackingParams from Kusama
AndreiEres c7abc34
Extract handle_statement
AndreiEres bd285d5
Send more than 1 message
AndreiEres a80d2f1
Update baseline
AndreiEres File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, unless we are missing something here, can we concur that statement-distribution is not a subsystem with high resource(CPU + networking) demands ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it feels so, at least the signature checks seem damn fast compared to approval vote signatures :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least now we know about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is actually way less signature checks. For each candidate only the backing group would generate a statement so for polkadot you get 5 signature per candidate and with 100 candidates you check just 500 signatures in total.
In approval voting you need at least 30 votes(in practice more than that). per candidate so 30 signature per candidate and with 100 candidates you actually have to check 100 * 30 = 3000 signatures, that's around 6 times more signatures.
Yes, it was meant as a good news :D.