mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
udo load test: config: rename "handler" to "requests", refactor
This commit is contained in:
parent
dd573cdb30
commit
411716e333
5 changed files with 47 additions and 45 deletions
|
|
@ -18,15 +18,27 @@ pub struct Config {
|
||||||
pub workers: u8,
|
pub workers: u8,
|
||||||
/// Run duration (quit and generate report after this many seconds)
|
/// Run duration (quit and generate report after this many seconds)
|
||||||
pub duration: usize,
|
pub duration: usize,
|
||||||
/// Probability that an additional connect request will be sent for each
|
|
||||||
/// mio event
|
|
||||||
pub additional_request_probability: f32,
|
|
||||||
pub network: NetworkConfig,
|
pub network: NetworkConfig,
|
||||||
pub handler: HandlerConfig,
|
pub requests: RequestConfig,
|
||||||
#[cfg(feature = "cpu-pinning")]
|
#[cfg(feature = "cpu-pinning")]
|
||||||
pub cpu_pinning: CpuPinningConfig,
|
pub cpu_pinning: CpuPinningConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
server_address: "127.0.0.1:3000".parse().unwrap(),
|
||||||
|
log_level: LogLevel::Error,
|
||||||
|
workers: 1,
|
||||||
|
duration: 0,
|
||||||
|
network: NetworkConfig::default(),
|
||||||
|
requests: RequestConfig::default(),
|
||||||
|
#[cfg(feature = "cpu-pinning")]
|
||||||
|
cpu_pinning: CpuPinningConfig::default_for_load_test(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct NetworkConfig {
|
pub struct NetworkConfig {
|
||||||
|
|
@ -60,9 +72,21 @@ pub struct NetworkConfig {
|
||||||
pub recv_buffer: usize,
|
pub recv_buffer: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for NetworkConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
multiple_client_ipv4s: true,
|
||||||
|
first_port: 45_000,
|
||||||
|
poll_timeout: 276,
|
||||||
|
poll_event_capacity: 2_877,
|
||||||
|
recv_buffer: 6_000_000,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct HandlerConfig {
|
pub struct RequestConfig {
|
||||||
/// Number of torrents to simulate
|
/// Number of torrents to simulate
|
||||||
pub number_of_torrents: usize,
|
pub number_of_torrents: usize,
|
||||||
/// Maximum number of torrents to ask about in scrape requests
|
/// Maximum number of torrents to ask about in scrape requests
|
||||||
|
|
@ -82,37 +106,12 @@ pub struct HandlerConfig {
|
||||||
pub torrent_selection_pareto_shape: f64,
|
pub torrent_selection_pareto_shape: f64,
|
||||||
/// Probability that a generated peer is a seeder
|
/// Probability that a generated peer is a seeder
|
||||||
pub peer_seeder_probability: f64,
|
pub peer_seeder_probability: f64,
|
||||||
|
/// Probability that an additional connect request will be sent for each
|
||||||
|
/// mio event
|
||||||
|
pub additional_request_probability: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for RequestConfig {
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
server_address: "127.0.0.1:3000".parse().unwrap(),
|
|
||||||
log_level: LogLevel::Error,
|
|
||||||
workers: 1,
|
|
||||||
duration: 0,
|
|
||||||
additional_request_probability: 0.5,
|
|
||||||
network: NetworkConfig::default(),
|
|
||||||
handler: HandlerConfig::default(),
|
|
||||||
#[cfg(feature = "cpu-pinning")]
|
|
||||||
cpu_pinning: CpuPinningConfig::default_for_load_test(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for NetworkConfig {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
multiple_client_ipv4s: true,
|
|
||||||
first_port: 45_000,
|
|
||||||
poll_timeout: 276,
|
|
||||||
poll_event_capacity: 2_877,
|
|
||||||
recv_buffer: 6_000_000,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for HandlerConfig {
|
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
number_of_torrents: 10_000,
|
number_of_torrents: 10_000,
|
||||||
|
|
@ -122,6 +121,7 @@ impl Default for HandlerConfig {
|
||||||
weight_announce: 5,
|
weight_announce: 5,
|
||||||
weight_scrape: 1,
|
weight_scrape: 1,
|
||||||
torrent_selection_pareto_shape: 2.0,
|
torrent_selection_pareto_shape: 2.0,
|
||||||
|
additional_request_probability: 0.5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,9 @@ fn create_random_request(
|
||||||
torrent_peer: &TorrentPeer,
|
torrent_peer: &TorrentPeer,
|
||||||
) -> Request {
|
) -> Request {
|
||||||
let weights = vec![
|
let weights = vec![
|
||||||
config.handler.weight_announce as u32,
|
config.requests.weight_announce as u32,
|
||||||
config.handler.weight_connect as u32,
|
config.requests.weight_connect as u32,
|
||||||
config.handler.weight_scrape as u32,
|
config.requests.weight_scrape as u32,
|
||||||
];
|
];
|
||||||
|
|
||||||
let items = vec![
|
let items = vec![
|
||||||
|
|
@ -142,7 +142,7 @@ fn create_announce_request(
|
||||||
transaction_id: TransactionId,
|
transaction_id: TransactionId,
|
||||||
) -> Request {
|
) -> Request {
|
||||||
let (event, bytes_left) = {
|
let (event, bytes_left) = {
|
||||||
if rng.gen_bool(config.handler.peer_seeder_probability) {
|
if rng.gen_bool(config.requests.peer_seeder_probability) {
|
||||||
(AnnounceEvent::Completed, NumberOfBytes(0))
|
(AnnounceEvent::Completed, NumberOfBytes(0))
|
||||||
} else {
|
} else {
|
||||||
(AnnounceEvent::Started, NumberOfBytes(50))
|
(AnnounceEvent::Started, NumberOfBytes(50))
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ impl aquatic_cli_helpers::Config for Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(config: Config) -> ::anyhow::Result<()> {
|
fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
if config.handler.weight_announce + config.handler.weight_connect + config.handler.weight_scrape
|
if config.requests.weight_announce
|
||||||
|
+ config.requests.weight_connect
|
||||||
|
+ config.requests.weight_scrape
|
||||||
== 0
|
== 0
|
||||||
{
|
{
|
||||||
panic!("Error: at least one weight must be larger than zero.");
|
panic!("Error: at least one weight must be larger than zero.");
|
||||||
|
|
@ -45,9 +47,9 @@ fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
|
|
||||||
println!("Starting client with config: {:#?}", config);
|
println!("Starting client with config: {:#?}", config);
|
||||||
|
|
||||||
let mut info_hashes = Vec::with_capacity(config.handler.number_of_torrents);
|
let mut info_hashes = Vec::with_capacity(config.requests.number_of_torrents);
|
||||||
|
|
||||||
for _ in 0..config.handler.number_of_torrents {
|
for _ in 0..config.requests.number_of_torrents {
|
||||||
info_hashes.push(generate_info_hash());
|
info_hashes.push(generate_info_hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +58,7 @@ fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
statistics: Arc::new(Statistics::default()),
|
statistics: Arc::new(Statistics::default()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pareto = Pareto::new(1.0, config.handler.torrent_selection_pareto_shape).unwrap();
|
let pareto = Pareto::new(1.0, config.requests.torrent_selection_pareto_shape).unwrap();
|
||||||
|
|
||||||
// Start workers
|
// Start workers
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ pub fn run_worker_thread(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rng.gen::<f32>() <= config.additional_request_probability {
|
if rng.gen::<f32>() <= config.requests.additional_request_probability {
|
||||||
let additional_request =
|
let additional_request =
|
||||||
create_connect_request(generate_transaction_id(&mut rng));
|
create_connect_request(generate_transaction_id(&mut rng));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ pub fn create_torrent_peer(
|
||||||
info_hashes: &Arc<Vec<InfoHash>>,
|
info_hashes: &Arc<Vec<InfoHash>>,
|
||||||
connection_id: ConnectionId,
|
connection_id: ConnectionId,
|
||||||
) -> TorrentPeer {
|
) -> TorrentPeer {
|
||||||
let num_scape_hashes = rng.gen_range(1..config.handler.scrape_max_torrents);
|
let num_scape_hashes = rng.gen_range(1..config.requests.scrape_max_torrents);
|
||||||
|
|
||||||
let mut scrape_hash_indeces = Vec::new();
|
let mut scrape_hash_indeces = Vec::new();
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ pub fn create_torrent_peer(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_info_hash_index(config: &Config, rng: &mut impl Rng, pareto: Pareto<f64>) -> usize {
|
fn select_info_hash_index(config: &Config, rng: &mut impl Rng, pareto: Pareto<f64>) -> usize {
|
||||||
pareto_usize(rng, pareto, config.handler.number_of_torrents - 1)
|
pareto_usize(rng, pareto, config.requests.number_of_torrents - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pareto_usize(rng: &mut impl Rng, pareto: Pareto<f64>, max: usize) -> usize {
|
pub fn pareto_usize(rng: &mut impl Rng, pareto: Pareto<f64>, max: usize) -> usize {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue