Skip to content

Commit

Permalink
subsystem-bench: run cli benchmarks only using config files (#3239)
Browse files Browse the repository at this point in the history
This PR removes the configuration of subsystem benchmarks via CLI
arguments. After this, we only keep configurations only in yaml files.
It removes unnecessary code duplication
  • Loading branch information
AndreiEres authored Feb 8, 2024
1 parent 84d89e3 commit 07f8592
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ use crate::{
GeneratedState, BUFFER_FOR_GENERATION_MILLIS, LOG_TARGET, SLOT_DURATION_MILLIS,
},
core::{
configuration::{TestAuthorities, TestConfiguration, TestObjective},
configuration::{TestAuthorities, TestConfiguration},
mock::session_info_for_peers,
NODE_UNDER_TEST,
},
TestObjective,
};
use polkadot_node_network_protocol::v3 as protocol_v3;
use polkadot_primitives::Hash;
Expand Down
3 changes: 2 additions & 1 deletion polkadot/node/subsystem-bench/src/approval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::{
mock_chain_selection::MockChainSelection,
},
core::{
configuration::{TestAuthorities, TestConfiguration},
configuration::TestAuthorities,
environment::{
BenchmarkUsage, TestEnvironment, TestEnvironmentDependencies, MAX_TIME_OF_FLIGHT,
},
Expand All @@ -43,6 +43,7 @@ use crate::{
},
NODE_UNDER_TEST,
},
TestConfiguration,
};
use colored::Colorize;
use futures::channel::oneshot;
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/subsystem-bench/src/availability/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use super::core::{configuration::TestConfiguration, mock::dummy_builder, network

const LOG_TARGET: &str = "subsystem-bench::availability";

use super::{cli::TestObjective, core::mock::AlwaysSupportsParachains};
use super::{core::mock::AlwaysSupportsParachains, TestObjective};
use polkadot_node_subsystem_test_helpers::{
derive_erasure_chunks_with_proofs_and_root, mock::new_block_import_info,
};
Expand Down
82 changes: 0 additions & 82 deletions polkadot/node/subsystem-bench/src/cli.rs

This file was deleted.

91 changes: 1 addition & 90 deletions polkadot/node/subsystem-bench/src/core/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use sc_network::PeerId;
use sp_consensus_babe::AuthorityId;
use std::{collections::HashMap, path::Path};

pub use crate::cli::TestObjective;
use crate::TestObjective;
use polkadot_primitives::{AssignmentId, AuthorityDiscoveryId, ValidatorId};
use rand::thread_rng;
use rand_distr::{Distribution, Normal, Uniform};
Expand Down Expand Up @@ -240,95 +240,6 @@ impl TestConfiguration {
peer_id_to_authority,
}
}

/// An unconstrained standard configuration matching Polkadot/Kusama
pub fn ideal_network(
objective: TestObjective,
num_blocks: usize,
n_validators: usize,
n_cores: usize,
min_pov_size: usize,
max_pov_size: usize,
) -> TestConfiguration {
Self {
objective,
n_cores,
n_validators,
max_validators_per_core: 5,
pov_sizes: generate_pov_sizes(n_cores, min_pov_size, max_pov_size),
bandwidth: 50 * 1024 * 1024,
peer_bandwidth: 50 * 1024 * 1024,
// No latency
latency: None,
num_blocks,
min_pov_size,
max_pov_size,
connectivity: 100,
needed_approvals: default_needed_approvals(),
n_delay_tranches: default_n_delay_tranches(),
no_show_slots: default_no_show_slots(),
relay_vrf_modulo_samples: default_relay_vrf_modulo_samples(),
zeroth_delay_tranche_width: default_zeroth_delay_tranche_width(),
}
}

pub fn healthy_network(
objective: TestObjective,
num_blocks: usize,
n_validators: usize,
n_cores: usize,
min_pov_size: usize,
max_pov_size: usize,
) -> TestConfiguration {
Self {
objective,
n_cores,
n_validators,
max_validators_per_core: 5,
pov_sizes: generate_pov_sizes(n_cores, min_pov_size, max_pov_size),
bandwidth: 50 * 1024 * 1024,
peer_bandwidth: 50 * 1024 * 1024,
latency: Some(PeerLatency { mean_latency_ms: 50, std_dev: 12.5 }),
num_blocks,
min_pov_size,
max_pov_size,
connectivity: 95,
needed_approvals: default_needed_approvals(),
n_delay_tranches: default_n_delay_tranches(),
no_show_slots: default_no_show_slots(),
relay_vrf_modulo_samples: default_relay_vrf_modulo_samples(),
zeroth_delay_tranche_width: default_zeroth_delay_tranche_width(),
}
}

pub fn degraded_network(
objective: TestObjective,
num_blocks: usize,
n_validators: usize,
n_cores: usize,
min_pov_size: usize,
max_pov_size: usize,
) -> TestConfiguration {
Self {
objective,
n_cores,
n_validators,
max_validators_per_core: 5,
pov_sizes: generate_pov_sizes(n_cores, min_pov_size, max_pov_size),
bandwidth: 50 * 1024 * 1024,
peer_bandwidth: 50 * 1024 * 1024,
latency: Some(PeerLatency { mean_latency_ms: 150, std_dev: 40.0 }),
num_blocks,
min_pov_size,
max_pov_size,
connectivity: 67,
needed_approvals: default_needed_approvals(),
n_delay_tranches: default_n_delay_tranches(),
no_show_slots: default_no_show_slots(),
relay_vrf_modulo_samples: default_relay_vrf_modulo_samples(),
zeroth_delay_tranche_width: default_zeroth_delay_tranche_width(),
}
}
}

/// Sample latency (in milliseconds) from a normal distribution with parameters
Expand Down
Loading

0 comments on commit 07f8592

Please sign in to comment.