udp load test: store info hashes as Arc slice to save space

This commit is contained in:
Joakim Frostegård 2024-01-04 17:24:35 +01:00
parent 0eaa4475e2
commit 99791c7154
3 changed files with 7 additions and 7 deletions

View file

@ -27,7 +27,7 @@ pub struct Statistics {
#[derive(Clone)]
pub struct LoadTestState {
pub info_hashes: Arc<Vec<InfoHash>>,
pub info_hashes: Arc<[InfoHash]>,
pub statistics: Arc<Statistics>,
}

View file

@ -46,7 +46,7 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
}
let state = LoadTestState {
info_hashes: Arc::new(info_hashes),
info_hashes: Arc::from(info_hashes.into_boxed_slice()),
statistics: Arc::new(Statistics::default()),
};

View file

@ -13,7 +13,7 @@ use crate::utils::*;
pub fn process_response(
rng: &mut impl Rng,
gamma: Gamma<f64>,
info_hashes: &Arc<Vec<InfoHash>>,
info_hashes: &Arc<[InfoHash]>,
config: &Config,
torrent_peers: &mut TorrentPeerMap,
response: Response,
@ -89,7 +89,7 @@ pub fn process_response(
fn if_torrent_peer_move_and_create_random_request(
config: &Config,
rng: &mut impl Rng,
info_hashes: &Arc<Vec<InfoHash>>,
info_hashes: &Arc<[InfoHash]>,
torrent_peers: &mut TorrentPeerMap,
transaction_id: TransactionId,
) -> Option<Request> {
@ -110,7 +110,7 @@ fn if_torrent_peer_move_and_create_random_request(
fn create_random_request(
config: &Config,
rng: &mut impl Rng,
info_hashes: &Arc<Vec<InfoHash>>,
info_hashes: &Arc<[InfoHash]>,
transaction_id: TransactionId,
torrent_peer: &TorrentPeer,
) -> Request {
@ -168,7 +168,7 @@ fn create_announce_request(
}
fn create_scrape_request(
info_hashes: &Arc<Vec<InfoHash>>,
info_hashes: &Arc<[InfoHash]>,
torrent_peer: &TorrentPeer,
transaction_id: TransactionId,
) -> Request {
@ -192,7 +192,7 @@ fn create_torrent_peer(
config: &Config,
rng: &mut impl Rng,
gamma: Gamma<f64>,
info_hashes: &Arc<Vec<InfoHash>>,
info_hashes: &Arc<[InfoHash]>,
connection_id: ConnectionId,
) -> TorrentPeer {
let num_scape_hashes = rng.gen_range(1..config.requests.scrape_max_torrents);