mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
http load test: add config fields num connections, creation interval
Also update defaults
This commit is contained in:
parent
7d4b1ab610
commit
aa0094164a
2 changed files with 9 additions and 8 deletions
|
|
@ -8,6 +8,7 @@ use serde::{Serialize, Deserialize};
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub server_address: SocketAddr,
|
pub server_address: SocketAddr,
|
||||||
pub num_workers: u8,
|
pub num_workers: u8,
|
||||||
|
pub num_connections: usize,
|
||||||
pub duration: usize,
|
pub duration: usize,
|
||||||
pub network: NetworkConfig,
|
pub network: NetworkConfig,
|
||||||
pub torrents: TorrentConfig,
|
pub torrents: TorrentConfig,
|
||||||
|
|
@ -17,6 +18,7 @@ pub struct Config {
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct NetworkConfig {
|
pub struct NetworkConfig {
|
||||||
|
pub connection_creation_interval: usize,
|
||||||
pub poll_timeout_microseconds: u64,
|
pub poll_timeout_microseconds: u64,
|
||||||
pub poll_event_capacity: usize,
|
pub poll_event_capacity: usize,
|
||||||
}
|
}
|
||||||
|
|
@ -46,6 +48,7 @@ impl Default for Config {
|
||||||
Self {
|
Self {
|
||||||
server_address: "127.0.0.1:3000".parse().unwrap(),
|
server_address: "127.0.0.1:3000".parse().unwrap(),
|
||||||
num_workers: 1,
|
num_workers: 1,
|
||||||
|
num_connections: 128,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
network: NetworkConfig::default(),
|
network: NetworkConfig::default(),
|
||||||
torrents: TorrentConfig::default(),
|
torrents: TorrentConfig::default(),
|
||||||
|
|
@ -56,8 +59,9 @@ impl Default for Config {
|
||||||
impl Default for NetworkConfig {
|
impl Default for NetworkConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
poll_timeout_microseconds: 1000,
|
connection_creation_interval: 40,
|
||||||
poll_event_capacity: 4096,
|
poll_timeout_microseconds: 47,
|
||||||
|
poll_event_capacity: 1024,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,18 +175,15 @@ impl Connection {
|
||||||
pub type ConnectionMap = Slab<Connection>;
|
pub type ConnectionMap = Slab<Connection>;
|
||||||
|
|
||||||
|
|
||||||
const NUM_CONNECTIONS: usize = 128;
|
|
||||||
const CREATE_CONN_INTERVAL: usize = 2 ^ 18;
|
|
||||||
|
|
||||||
|
|
||||||
pub fn run_socket_thread(
|
pub fn run_socket_thread(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
state: LoadTestState,
|
state: LoadTestState,
|
||||||
num_initial_requests: usize,
|
num_initial_requests: usize,
|
||||||
) {
|
) {
|
||||||
let timeout = Duration::from_micros(config.network.poll_timeout_microseconds);
|
let timeout = Duration::from_micros(config.network.poll_timeout_microseconds);
|
||||||
|
let create_conn_interval = 2 ^ config.network.connection_creation_interval;
|
||||||
|
|
||||||
let mut connections: ConnectionMap = Slab::with_capacity(NUM_CONNECTIONS);
|
let mut connections: ConnectionMap = Slab::with_capacity(config.num_connections);
|
||||||
let mut poll = Poll::new().expect("create poll");
|
let mut poll = Poll::new().expect("create poll");
|
||||||
let mut events = Events::with_capacity(config.network.poll_event_capacity);
|
let mut events = Events::with_capacity(config.network.poll_event_capacity);
|
||||||
let mut rng = SmallRng::from_entropy();
|
let mut rng = SmallRng::from_entropy();
|
||||||
|
|
@ -244,7 +241,7 @@ pub fn run_socket_thread(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slowly create new connections
|
// Slowly create new connections
|
||||||
if token_counter < NUM_CONNECTIONS && iter_counter % CREATE_CONN_INTERVAL == 0 {
|
if token_counter < config.num_connections && iter_counter % create_conn_interval == 0 {
|
||||||
Connection::create_and_register(
|
Connection::create_and_register(
|
||||||
config,
|
config,
|
||||||
&mut connections,
|
&mut connections,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue