udp load test: use Gamma distribution for torrent selection

This commit is contained in:
Joakim Frostegård 2022-10-26 19:45:39 +02:00
parent 15f8d30518
commit 2b9db63984
5 changed files with 22 additions and 17 deletions

View file

@ -8,7 +8,7 @@ use std::time::Duration;
use mio::{net::UdpSocket, Events, Interest, Poll, Token};
use rand::Rng;
use rand::{prelude::SmallRng, thread_rng, SeedableRng};
use rand_distr::Pareto;
use rand_distr::Gamma;
use socket2::{Domain, Protocol, Socket, Type};
use aquatic_udp_protocol::*;
@ -21,7 +21,7 @@ const MAX_PACKET_SIZE: usize = 8192;
pub fn run_worker_thread(
state: LoadTestState,
pareto: Pareto<f64>,
pareto: Gamma<f64>,
config: &Config,
addr: SocketAddr,
) {

View file

@ -2,7 +2,7 @@ use std::sync::Arc;
use rand::distributions::WeightedIndex;
use rand::prelude::*;
use rand_distr::Pareto;
use rand_distr::Gamma;
use aquatic_udp_protocol::*;
@ -12,7 +12,7 @@ use crate::utils::*;
pub fn process_response(
rng: &mut impl Rng,
pareto: Pareto<f64>,
pareto: Gamma<f64>,
info_hashes: &Arc<Vec<InfoHash>>,
config: &Config,
torrent_peers: &mut TorrentPeerMap,
@ -190,7 +190,7 @@ fn create_scrape_request(
fn create_torrent_peer(
config: &Config,
rng: &mut impl Rng,
pareto: Pareto<f64>,
pareto: Gamma<f64>,
info_hashes: &Arc<Vec<InfoHash>>,
connection_id: ConnectionId,
) -> TorrentPeer {
@ -213,6 +213,6 @@ 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: Gamma<f64>) -> usize {
pareto_usize(rng, pareto, config.requests.number_of_torrents - 1)
}