mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +00:00
ws load test: add cpu pinning and log crate logging
This commit is contained in:
parent
3114f8692b
commit
b653e3e3ff
4 changed files with 31 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -272,6 +272,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"aquatic_cli_helpers",
|
"aquatic_cli_helpers",
|
||||||
|
"aquatic_common",
|
||||||
"aquatic_ws_protocol",
|
"aquatic_ws_protocol",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ name = "aquatic_ws_load_test"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
async-tungstenite = "0.15"
|
async-tungstenite = "0.15"
|
||||||
aquatic_cli_helpers = "0.1.0"
|
aquatic_cli_helpers = "0.1.0"
|
||||||
|
aquatic_common = "0.1.0"
|
||||||
aquatic_ws_protocol = "0.1.0"
|
aquatic_ws_protocol = "0.1.0"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
futures-rustls = "0.22"
|
futures-rustls = "0.22"
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,26 @@
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
use aquatic_cli_helpers::LogLevel;
|
||||||
|
use aquatic_common::cpu_pinning::CpuPinningConfig;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub server_address: SocketAddr,
|
pub server_address: SocketAddr,
|
||||||
pub num_workers: u8,
|
pub log_level: LogLevel,
|
||||||
|
pub num_workers: usize,
|
||||||
pub num_connections: usize,
|
pub num_connections: usize,
|
||||||
pub duration: usize,
|
pub duration: usize,
|
||||||
pub torrents: TorrentConfig,
|
pub torrents: TorrentConfig,
|
||||||
|
pub cpu_pinning: CpuPinningConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl aquatic_cli_helpers::Config for Config {}
|
impl aquatic_cli_helpers::Config for Config {
|
||||||
|
fn get_log_level(&self) -> Option<LogLevel> {
|
||||||
|
Some(self.log_level)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|
@ -37,10 +45,12 @@ impl Default for Config {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
server_address: "127.0.0.1:3000".parse().unwrap(),
|
server_address: "127.0.0.1:3000".parse().unwrap(),
|
||||||
|
log_level: LogLevel::Error,
|
||||||
num_workers: 1,
|
num_workers: 1,
|
||||||
num_connections: 16,
|
num_connections: 16,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
torrents: TorrentConfig::default(),
|
torrents: TorrentConfig::default(),
|
||||||
|
cpu_pinning: CpuPinningConfig::default_for_load_test(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use std::sync::{atomic::Ordering, Arc};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
use aquatic_common::cpu_pinning::{pin_current_if_configured_to, WorkerIndex};
|
||||||
use glommio::LocalExecutorBuilder;
|
use glommio::LocalExecutorBuilder;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use rand_distr::Pareto;
|
use rand_distr::Pareto;
|
||||||
|
|
@ -33,6 +34,12 @@ fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
|
|
||||||
println!("Starting client with config: {:#?}", config);
|
println!("Starting client with config: {:#?}", config);
|
||||||
|
|
||||||
|
pin_current_if_configured_to(
|
||||||
|
&config.cpu_pinning,
|
||||||
|
config.num_workers as usize,
|
||||||
|
WorkerIndex::Other,
|
||||||
|
);
|
||||||
|
|
||||||
let mut info_hashes = Vec::with_capacity(config.torrents.number_of_torrents);
|
let mut info_hashes = Vec::with_capacity(config.torrents.number_of_torrents);
|
||||||
|
|
||||||
let mut rng = SmallRng::from_entropy();
|
let mut rng = SmallRng::from_entropy();
|
||||||
|
|
@ -51,12 +58,20 @@ fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
|
|
||||||
let tls_config = create_tls_config().unwrap();
|
let tls_config = create_tls_config().unwrap();
|
||||||
|
|
||||||
for _ in 0..config.num_workers {
|
for i in 0..config.num_workers {
|
||||||
let config = config.clone();
|
let config = config.clone();
|
||||||
let tls_config = tls_config.clone();
|
let tls_config = tls_config.clone();
|
||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
|
|
||||||
LocalExecutorBuilder::default()
|
let mut builder = LocalExecutorBuilder::default();
|
||||||
|
|
||||||
|
if config.cpu_pinning.active {
|
||||||
|
builder = builder.pin_to_cpu(
|
||||||
|
WorkerIndex::SocketWorker(i).get_cpu_index(&config.cpu_pinning, config.num_workers),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder
|
||||||
.spawn(|| async move {
|
.spawn(|| async move {
|
||||||
run_socket_thread(config, tls_config, state).await.unwrap();
|
run_socket_thread(config, tls_config, state).await.unwrap();
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue