Skip to content
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] Fix availability-write regression tests #3698

Merged
merged 42 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f90ec6a
Adjust av write regression tests
AndreiEres Mar 14, 2024
be14c1f
Add the test
AndreiEres Mar 14, 2024
18d8401
Fix clippy
AndreiEres Mar 14, 2024
f085105
Update
AndreiEres Mar 14, 2024
7bc1f66
Update
AndreiEres Mar 14, 2024
b631f33
Merge branch 'master' into AndreiEres/av-write-regression
AndreiEres Mar 14, 2024
c83802d
Update options
AndreiEres Mar 14, 2024
e85a9d6
Update
AndreiEres Mar 14, 2024
fca1298
Update
AndreiEres Mar 14, 2024
b70518e
Update
AndreiEres Mar 14, 2024
79c90cc
Update
AndreiEres Mar 15, 2024
380742b
Update
AndreiEres Mar 15, 2024
e024367
Add debug
AndreiEres Mar 15, 2024
b3e1b3e
Fix imports
AndreiEres Mar 15, 2024
320b3ef
Fix imports
AndreiEres Mar 15, 2024
057e748
Merge branch 'master' into AndreiEres/av-write-regression
AndreiEres Mar 15, 2024
ed920a1
Update values
AndreiEres Mar 15, 2024
733ea22
Increase precission
AndreiEres Mar 15, 2024
26c826c
Merge branch 'master' into AndreiEres/av-write-regression
AndreiEres Mar 19, 2024
7d596f8
Move all generation out of regression tests (#3746)
AndreiEres Mar 20, 2024
c1d831a
Add fields to state
AndreiEres Mar 20, 2024
b108fc2
Update
AndreiEres Mar 20, 2024
4ca7d3a
Update
AndreiEres Mar 20, 2024
b958883
Update
AndreiEres Mar 20, 2024
afea297
Update
AndreiEres Mar 21, 2024
8cf35fe
Move to benches
AndreiEres Mar 21, 2024
8c9723e
Fix clippy errors
AndreiEres Mar 21, 2024
2131382
Update
AndreiEres Mar 21, 2024
5dbd5c5
Merge branch 'master' into AndreiEres/av-write-regression
AndreiEres Mar 21, 2024
f23ff46
Update
AndreiEres Mar 21, 2024
0c9c44a
Fix cli
AndreiEres Mar 21, 2024
7837b43
Fix clippy
AndreiEres Mar 21, 2024
6fba293
Fix clippy
AndreiEres Mar 21, 2024
5056256
Fix clippy
AndreiEres Mar 21, 2024
30caa96
Update values
AndreiEres Mar 21, 2024
a7d7fb8
Merge branch 'master' into AndreiEres/av-write-regression
AndreiEres Mar 22, 2024
6ad7700
Update test state
AndreiEres Mar 22, 2024
8c2a645
Update values
AndreiEres Mar 22, 2024
a17a8cd
Remove redundant clone
AndreiEres Mar 22, 2024
685fc33
Address PR review
AndreiEres Mar 22, 2024
514f6cb
Revert accidental change
AndreiEres Mar 22, 2024
4dae323
Revert accidental change
AndreiEres Mar 25, 2024
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
1 change: 1 addition & 0 deletions .gitlab/pipeline/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ subsystem-regression-tests:
- .run-immediately
script:
- cargo bench --profile=testnet -p polkadot-availability-recovery --bench availability-recovery-regression-bench --features subsystem-benchmarks
- cargo bench --profile=testnet -p polkadot-availability-distribution --bench availability-distribution-regression-bench --features subsystem-benchmarks
tags:
- benchmark
allow_failure: true
4 changes: 2 additions & 2 deletions polkadot/node/network/availability-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" }
polkadot-subsystem-bench = { path = "../../subsystem-bench" }


[[test]]
[[bench]]
name = "availability-distribution-regression-bench"
path = "tests/availability-distribution-regression-bench.rs"
path = "benches/availability-distribution-regression-bench.rs"
harness = false
required-features = ["subsystem-benchmarks"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,54 @@
//! - availability-store

use polkadot_subsystem_bench::{
availability::{benchmark_availability_write, prepare_test, TestDataAvailability, TestState},
availability::{benchmark_availability_write, prepare_test, TestState},
configuration::TestConfiguration,
utils::{warm_up_and_benchmark, WarmUpOptions},
usage::BenchmarkUsage,
};
use std::io::Write;

const BENCH_COUNT: usize = 50;

fn main() -> Result<(), String> {
let mut messages = vec![];
let mut config = TestConfiguration::default();
// A single node effort roughly n_cores * needed_approvals / n_validators = 60 * 30 / 300
config.n_cores = 6;
// A single node effort roughly
config.n_cores = 10;
config.n_validators = 500;
config.num_blocks = 3;
config.generate_pov_sizes();
let state = TestState::new(&config);

let usage = warm_up_and_benchmark(
WarmUpOptions::new(&[
"availability-distribution",
"bitfield-distribution",
"availability-store",
]),
|| {
let mut state = TestState::new(&config);
let (mut env, _protocol_config) =
prepare_test(config.clone(), &mut state, TestDataAvailability::Write, false);
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,
polkadot_subsystem_bench::availability::TestDataAvailability::Write,
false,
);
env.runtime().block_on(benchmark_availability_write(
"data_availability_write",
&mut env,
state,
&state,
))
},
)?;
println!("{}", usage);
})
.collect();
println!("\rDone!{}", " ".repeat(BENCH_COUNT));
let average_usage = BenchmarkUsage::average(&usages);
println!("{}", average_usage);

messages.extend(usage.check_network_usage(&[
("Received from peers", 443.333, 0.05),
("Sent to peers", 21818.555, 0.05),
messages.extend(average_usage.check_network_usage(&[
("Received from peers", 433.3, 0.01),
("Sent to peers", 18480.0, 0.01),
]));
messages.extend(usage.check_cpu_usage(&[
("availability-distribution", 0.011, 0.05),
("bitfield-distribution", 0.029, 0.05),
("availability-store", 0.232, 0.05),

messages.extend(average_usage.check_cpu_usage(&[
("availability-distribution", 0.012, 0.05),
("availability-store", 0.153, 0.05),
("bitfield-distribution", 0.026, 0.05),
]));

if messages.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! availability-write regression tests
//! availability-read regression tests
//!
//! Availability write benchmark based on Kusama parameters and scale.
//! Availability read benchmark based on Kusama parameters and scale.
//!
//! Subsystems involved:
//! - availability-recovery
Expand All @@ -27,8 +27,11 @@ use polkadot_subsystem_bench::{
TestDataAvailability, TestState,
},
configuration::TestConfiguration,
utils::{warm_up_and_benchmark, WarmUpOptions},
usage::BenchmarkUsage,
};
use std::io::Write;

const BENCH_COUNT: usize = 50;

fn main() -> Result<(), String> {
let mut messages = vec![];
Expand All @@ -38,27 +41,31 @@ fn main() -> Result<(), String> {
config.num_blocks = 3;
config.generate_pov_sizes();

let usage = warm_up_and_benchmark(WarmUpOptions::new(&["availability-recovery"]), || {
let mut state = TestState::new(&config);
let (mut env, _protocol_config) = prepare_test(
config.clone(),
&mut state,
TestDataAvailability::Read(options.clone()),
false,
);
env.runtime().block_on(benchmark_availability_read(
"data_availability_read",
&mut env,
state,
))
})?;
println!("{}", usage);
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, TestDataAvailability::Read(options.clone()), false);
env.runtime().block_on(benchmark_availability_read(
"data_availability_read",
&mut env,
&state,
))
})
.collect();
println!("\rDone!{}", " ".repeat(BENCH_COUNT));
let average_usage = BenchmarkUsage::average(&usages);
println!("{}", average_usage);

messages.extend(usage.check_network_usage(&[
messages.extend(average_usage.check_network_usage(&[
("Received from peers", 307200.000, 0.05),
("Sent to peers", 1.667, 0.05),
]));
messages.extend(usage.check_cpu_usage(&[("availability-recovery", 11.500, 0.05)]));
messages.extend(average_usage.check_cpu_usage(&[("availability-recovery", 11.500, 0.05)]));

if messages.is_empty() {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/subsystem-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bitvec = "1.0.1"
kvdb-memorydb = "0.13.0"

parity-scale-codec = { version = "3.6.1", features = ["derive", "std"] }
tokio = "1.24.2"
tokio = { version = "1.24.2", features = ["rt-multi-thread", "parking_lot"] }
clap-num = "1.0.2"
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
sp-keyring = { path = "../../../substrate/primitives/keyring" }
Expand Down
14 changes: 6 additions & 8 deletions polkadot/node/subsystem-bench/src/cli/subsystem-bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,31 +136,29 @@ impl BenchCli {

let usage = match objective {
TestObjective::DataAvailabilityRead(opts) => {
let mut state = availability::TestState::new(&test_config);
let state = availability::TestState::new(&test_config);
let (mut env, _protocol_config) = availability::prepare_test(
test_config,
&mut state,
&state,
availability::TestDataAvailability::Read(opts),
true,
);
env.runtime().block_on(availability::benchmark_availability_read(
&benchmark_name,
&mut env,
state,
&state,
))
},
TestObjective::DataAvailabilityWrite => {
let mut state = availability::TestState::new(&test_config);
let state = availability::TestState::new(&test_config);
let (mut env, _protocol_config) = availability::prepare_test(
test_config,
&mut state,
&state,
availability::TestDataAvailability::Write,
true,
);
env.runtime().block_on(availability::benchmark_availability_write(
&benchmark_name,
&mut env,
state,
&state,
))
},
TestObjective::ApprovalVoting(ref options) => {
Expand Down
Loading
Loading