mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +00:00
Add subsystem benchmarks for availability-distribution and biftield-distribution (availability write) (#2970)
Introduce a new test objective : `DataAvailabilityWrite`. The new benchmark measures the network and cpu usage of `availability-distribution`, `biftield-distribution` and `availability-store` subsystems from the perspective of a validator node during the process when candidates are made available. Additionally I refactored the networking emulation to support bandwidth acounting and limits of incoming and outgoing requests. Screenshot of succesful run <img width="1293" alt="Screenshot 2024-01-17 at 19 17 44" src="https://github.com/paritytech/polkadot-sdk/assets/54316454/fde11280-e25b-4dc3-9dc9-d4b9752f9b7a"> --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -16,20 +16,23 @@
|
||||
|
||||
//! A tool for running subsystem benchmark tests designed for development and
|
||||
//! CI regression testing.
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use colored::Colorize;
|
||||
|
||||
use color_eyre::eyre;
|
||||
use pyroscope::PyroscopeAgent;
|
||||
use pyroscope_pprofrs::{pprof_backend, PprofConfig};
|
||||
|
||||
use colored::Colorize;
|
||||
use std::{path::Path, time::Duration};
|
||||
use std::path::Path;
|
||||
|
||||
pub(crate) mod availability;
|
||||
pub(crate) mod cli;
|
||||
pub(crate) mod core;
|
||||
mod valgrind;
|
||||
|
||||
const LOG_TARGET: &str = "subsystem-bench";
|
||||
|
||||
use availability::{prepare_test, NetworkEmulation, TestState};
|
||||
use cli::TestObjective;
|
||||
|
||||
@@ -61,24 +64,24 @@ struct BenchCli {
|
||||
pub standard_configuration: cli::StandardTestOptions,
|
||||
|
||||
#[clap(short, long)]
|
||||
/// The bandwidth of simulated remote peers in KiB
|
||||
/// The bandwidth of emulated remote peers in KiB
|
||||
pub peer_bandwidth: Option<usize>,
|
||||
|
||||
#[clap(short, long)]
|
||||
/// The bandwidth of our simulated node in KiB
|
||||
/// The bandwidth of our node in KiB
|
||||
pub bandwidth: Option<usize>,
|
||||
|
||||
#[clap(long, value_parser=le_100)]
|
||||
/// Simulated conection error ratio [0-100].
|
||||
pub peer_error: Option<usize>,
|
||||
/// Emulated peer connection ratio [0-100].
|
||||
pub connectivity: Option<usize>,
|
||||
|
||||
#[clap(long, value_parser=le_5000)]
|
||||
/// Minimum remote peer latency in milliseconds [0-5000].
|
||||
pub peer_min_latency: Option<u64>,
|
||||
/// Mean remote peer latency in milliseconds [0-5000].
|
||||
pub peer_mean_latency: Option<usize>,
|
||||
|
||||
#[clap(long, value_parser=le_5000)]
|
||||
/// Maximum remote peer latency in milliseconds [0-5000].
|
||||
pub peer_max_latency: Option<u64>,
|
||||
/// Remote peer latency standard deviation
|
||||
pub peer_latency_std_dev: Option<f64>,
|
||||
|
||||
#[clap(long, default_value_t = false)]
|
||||
/// Enable CPU Profiling with Pyroscope
|
||||
@@ -101,6 +104,37 @@ struct BenchCli {
|
||||
}
|
||||
|
||||
impl BenchCli {
|
||||
fn create_test_configuration(&self) -> TestConfiguration {
|
||||
let configuration = &self.standard_configuration;
|
||||
|
||||
match self.network {
|
||||
NetworkEmulation::Healthy => TestConfiguration::healthy_network(
|
||||
self.objective.clone(),
|
||||
configuration.num_blocks,
|
||||
configuration.n_validators,
|
||||
configuration.n_cores,
|
||||
configuration.min_pov_size,
|
||||
configuration.max_pov_size,
|
||||
),
|
||||
NetworkEmulation::Degraded => TestConfiguration::degraded_network(
|
||||
self.objective.clone(),
|
||||
configuration.num_blocks,
|
||||
configuration.n_validators,
|
||||
configuration.n_cores,
|
||||
configuration.min_pov_size,
|
||||
configuration.max_pov_size,
|
||||
),
|
||||
NetworkEmulation::Ideal => TestConfiguration::ideal_network(
|
||||
self.objective.clone(),
|
||||
configuration.num_blocks,
|
||||
configuration.n_validators,
|
||||
configuration.n_cores,
|
||||
configuration.min_pov_size,
|
||||
configuration.max_pov_size,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn launch(self) -> eyre::Result<()> {
|
||||
let is_valgrind_running = valgrind::is_valgrind_running();
|
||||
if !is_valgrind_running && self.cache_misses {
|
||||
@@ -117,7 +151,6 @@ impl BenchCli {
|
||||
None
|
||||
};
|
||||
|
||||
let configuration = self.standard_configuration;
|
||||
let mut test_config = match self.objective {
|
||||
TestObjective::TestSequence(options) => {
|
||||
let test_sequence =
|
||||
@@ -130,56 +163,48 @@ impl BenchCli {
|
||||
format!("Sequence contains {} step(s)", num_steps).bright_purple()
|
||||
);
|
||||
for (index, test_config) in test_sequence.into_iter().enumerate() {
|
||||
gum::info!("{}", format!("Step {}/{}", index + 1, num_steps).bright_purple(),);
|
||||
gum::info!(target: LOG_TARGET, "{}", format!("Step {}/{}", index + 1, num_steps).bright_purple(),);
|
||||
display_configuration(&test_config);
|
||||
|
||||
let mut state = TestState::new(&test_config);
|
||||
let (mut env, _protocol_config) = prepare_test(test_config, &mut state);
|
||||
env.runtime()
|
||||
.block_on(availability::benchmark_availability_read(&mut env, state));
|
||||
match test_config.objective {
|
||||
TestObjective::DataAvailabilityRead(ref _opts) => {
|
||||
let mut state = TestState::new(&test_config);
|
||||
let (mut env, _protocol_config) = prepare_test(test_config, &mut state);
|
||||
env.runtime().block_on(availability::benchmark_availability_read(
|
||||
&mut env, state,
|
||||
));
|
||||
},
|
||||
TestObjective::DataAvailabilityWrite => {
|
||||
let mut state = TestState::new(&test_config);
|
||||
let (mut env, _protocol_config) = prepare_test(test_config, &mut state);
|
||||
env.runtime().block_on(availability::benchmark_availability_write(
|
||||
&mut env, state,
|
||||
));
|
||||
},
|
||||
_ => gum::error!("Invalid test objective in sequence"),
|
||||
}
|
||||
}
|
||||
return Ok(())
|
||||
},
|
||||
TestObjective::DataAvailabilityRead(ref _options) => match self.network {
|
||||
NetworkEmulation::Healthy => TestConfiguration::healthy_network(
|
||||
self.objective,
|
||||
configuration.num_blocks,
|
||||
configuration.n_validators,
|
||||
configuration.n_cores,
|
||||
configuration.min_pov_size,
|
||||
configuration.max_pov_size,
|
||||
),
|
||||
NetworkEmulation::Degraded => TestConfiguration::degraded_network(
|
||||
self.objective,
|
||||
configuration.num_blocks,
|
||||
configuration.n_validators,
|
||||
configuration.n_cores,
|
||||
configuration.min_pov_size,
|
||||
configuration.max_pov_size,
|
||||
),
|
||||
NetworkEmulation::Ideal => TestConfiguration::ideal_network(
|
||||
self.objective,
|
||||
configuration.num_blocks,
|
||||
configuration.n_validators,
|
||||
configuration.n_cores,
|
||||
configuration.min_pov_size,
|
||||
configuration.max_pov_size,
|
||||
),
|
||||
},
|
||||
TestObjective::DataAvailabilityRead(ref _options) => self.create_test_configuration(),
|
||||
TestObjective::DataAvailabilityWrite => self.create_test_configuration(),
|
||||
};
|
||||
|
||||
let mut latency_config = test_config.latency.clone().unwrap_or_default();
|
||||
|
||||
if let Some(latency) = self.peer_min_latency {
|
||||
latency_config.min_latency = Duration::from_millis(latency);
|
||||
if let Some(latency) = self.peer_mean_latency {
|
||||
latency_config.mean_latency_ms = latency;
|
||||
}
|
||||
|
||||
if let Some(latency) = self.peer_max_latency {
|
||||
latency_config.max_latency = Duration::from_millis(latency);
|
||||
if let Some(std_dev) = self.peer_latency_std_dev {
|
||||
latency_config.std_dev = std_dev;
|
||||
}
|
||||
|
||||
if let Some(error) = self.peer_error {
|
||||
test_config.error = error;
|
||||
// Write back the updated latency.
|
||||
test_config.latency = Some(latency_config);
|
||||
|
||||
if let Some(connectivity) = self.connectivity {
|
||||
test_config.connectivity = connectivity;
|
||||
}
|
||||
|
||||
if let Some(bandwidth) = self.peer_bandwidth {
|
||||
@@ -197,8 +222,17 @@ impl BenchCli {
|
||||
let mut state = TestState::new(&test_config);
|
||||
let (mut env, _protocol_config) = prepare_test(test_config, &mut state);
|
||||
|
||||
env.runtime()
|
||||
.block_on(availability::benchmark_availability_read(&mut env, state));
|
||||
match self.objective {
|
||||
TestObjective::DataAvailabilityRead(_options) => {
|
||||
env.runtime()
|
||||
.block_on(availability::benchmark_availability_read(&mut env, state));
|
||||
},
|
||||
TestObjective::DataAvailabilityWrite => {
|
||||
env.runtime()
|
||||
.block_on(availability::benchmark_availability_write(&mut env, state));
|
||||
},
|
||||
TestObjective::TestSequence(_options) => {},
|
||||
}
|
||||
|
||||
if let Some(agent_running) = agent_running {
|
||||
let agent_ready = agent_running.stop()?;
|
||||
@@ -216,6 +250,7 @@ fn main() -> eyre::Result<()> {
|
||||
// Avoid `Terminating due to subsystem exit subsystem` warnings
|
||||
.filter(Some("polkadot_overseer"), log::LevelFilter::Error)
|
||||
.filter(None, log::LevelFilter::Info)
|
||||
.format_timestamp_millis()
|
||||
// .filter(None, log::LevelFilter::Trace)
|
||||
.try_init()
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user