bencher: change to account for new aquatic_udp implementation

This commit is contained in:
Joakim Frostegård 2024-02-10 18:51:13 +01:00
parent 358c8951c0
commit 2c7bcf71ad
4 changed files with 33 additions and 36 deletions

View file

@ -58,6 +58,12 @@ impl UdpCommand {
indexmap::indexmap! {
1 => SetConfig {
implementations: indexmap! {
UdpTracker::Aquatic => vec![
AquaticUdpRunner::with_mio(1, Priority::High),
],
UdpTracker::AquaticIoUring => vec![
AquaticUdpRunner::with_io_uring(1, Priority::High),
],
UdpTracker::OpenTracker => vec![
OpenTrackerUdpRunner::new(0, Priority::Medium), // Handle requests within event loop
OpenTrackerUdpRunner::new(1, Priority::High),
@ -74,12 +80,10 @@ impl UdpCommand {
2 => SetConfig {
implementations: indexmap! {
UdpTracker::Aquatic => vec![
AquaticUdpRunner::with_mio(1, 1, Priority::Medium),
AquaticUdpRunner::with_mio(2, 1, Priority::High),
AquaticUdpRunner::with_mio(2, Priority::High),
],
UdpTracker::AquaticIoUring => vec![
AquaticUdpRunner::with_io_uring(1, 1, Priority::Medium),
AquaticUdpRunner::with_io_uring(2, 1, Priority::High),
AquaticUdpRunner::with_io_uring(2, Priority::High),
],
UdpTracker::OpenTracker => vec![
OpenTrackerUdpRunner::new(2, Priority::High),
@ -97,12 +101,10 @@ impl UdpCommand {
4 => SetConfig {
implementations: indexmap! {
UdpTracker::Aquatic => vec![
AquaticUdpRunner::with_mio(3, 1, Priority::High),
AquaticUdpRunner::with_mio(4, 1, Priority::Medium),
AquaticUdpRunner::with_mio(4, Priority::High),
],
UdpTracker::AquaticIoUring => vec![
AquaticUdpRunner::with_io_uring(3, 1, Priority::High),
AquaticUdpRunner::with_io_uring(4, 1, Priority::Medium),
AquaticUdpRunner::with_io_uring(4, Priority::High),
],
UdpTracker::OpenTracker => vec![
OpenTrackerUdpRunner::new(4, Priority::High),
@ -119,10 +121,10 @@ impl UdpCommand {
6 => SetConfig {
implementations: indexmap! {
UdpTracker::Aquatic => vec![
AquaticUdpRunner::with_mio(5, 1, Priority::High),
AquaticUdpRunner::with_mio(6, Priority::High),
],
UdpTracker::AquaticIoUring => vec![
AquaticUdpRunner::with_io_uring(5, 1, Priority::High),
AquaticUdpRunner::with_io_uring(6, Priority::High),
],
UdpTracker::OpenTracker => vec![
OpenTrackerUdpRunner::new(6, Priority::High),
@ -139,10 +141,10 @@ impl UdpCommand {
8 => SetConfig {
implementations: indexmap! {
UdpTracker::Aquatic => vec![
AquaticUdpRunner::with_mio(7, 1, Priority::High),
AquaticUdpRunner::with_mio(8, Priority::High),
],
UdpTracker::AquaticIoUring => vec![
AquaticUdpRunner::with_io_uring(7, 1, Priority::High),
AquaticUdpRunner::with_io_uring(8, Priority::High),
],
UdpTracker::OpenTracker => vec![
OpenTrackerUdpRunner::new(8, Priority::High),
@ -159,12 +161,10 @@ impl UdpCommand {
12 => SetConfig {
implementations: indexmap! {
UdpTracker::Aquatic => vec![
AquaticUdpRunner::with_mio(10, 2, Priority::High),
AquaticUdpRunner::with_mio(9, 3, Priority::Medium),
AquaticUdpRunner::with_mio(12, Priority::High),
],
UdpTracker::AquaticIoUring => vec![
AquaticUdpRunner::with_io_uring(10, 2, Priority::High),
AquaticUdpRunner::with_io_uring(9, 3, Priority::Medium),
AquaticUdpRunner::with_io_uring(12, Priority::High),
],
UdpTracker::OpenTracker => vec![
OpenTrackerUdpRunner::new(12, Priority::High),
@ -181,10 +181,10 @@ impl UdpCommand {
16 => SetConfig {
implementations: indexmap! {
UdpTracker::Aquatic => vec![
AquaticUdpRunner::with_mio(13, 3, Priority::High),
AquaticUdpRunner::with_mio(16, Priority::High),
],
UdpTracker::AquaticIoUring => vec![
AquaticUdpRunner::with_io_uring(13, 3, Priority::High),
AquaticUdpRunner::with_io_uring(16, Priority::High),
],
UdpTracker::OpenTracker => vec![
OpenTrackerUdpRunner::new(16, Priority::High),
@ -211,7 +211,6 @@ impl UdpCommand {
#[derive(Debug, Clone)]
struct AquaticUdpRunner {
socket_workers: usize,
swarm_workers: usize,
use_io_uring: bool,
priority: Priority,
}
@ -219,24 +218,20 @@ struct AquaticUdpRunner {
impl AquaticUdpRunner {
fn with_mio(
socket_workers: usize,
swarm_workers: usize,
priority: Priority,
) -> Rc<dyn ProcessRunner<Command = UdpCommand>> {
Rc::new(Self {
socket_workers,
swarm_workers,
use_io_uring: false,
priority,
})
}
fn with_io_uring(
socket_workers: usize,
swarm_workers: usize,
priority: Priority,
) -> Rc<dyn ProcessRunner<Command = UdpCommand>> {
Rc::new(Self {
socket_workers,
swarm_workers,
use_io_uring: true,
priority,
})
@ -256,7 +251,6 @@ impl ProcessRunner for AquaticUdpRunner {
let mut c = aquatic_udp::config::Config::default();
c.socket_workers = self.socket_workers;
c.swarm_workers = self.swarm_workers;
c.network.address = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 3000));
c.network.use_io_uring = self.use_io_uring;
c.protocol.max_response_peers = 30;
@ -283,7 +277,6 @@ impl ProcessRunner for AquaticUdpRunner {
fn keys(&self) -> IndexMap<String, String> {
indexmap! {
"socket workers".to_string() => self.socket_workers.to_string(),
"swarm workers".to_string() => self.swarm_workers.to_string(),
}
}
}

View file

@ -94,11 +94,11 @@ pub struct State {
pub server_start_instant: ServerStartInstant,
}
impl State {
pub fn new(config: &Config) -> Self {
impl Default for State {
fn default() -> Self {
Self {
access_list: Arc::new(AccessListArcSwap::default()),
torrent_maps: TorrentMaps::new(config),
torrent_maps: TorrentMaps::default(),
server_start_instant: ServerStartInstant::new(),
}
}

View file

@ -25,7 +25,7 @@ pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn run(config: Config) -> ::anyhow::Result<()> {
let mut signals = Signals::new([SIGUSR1])?;
let state = State::new(&config);
let state = State::default();
let statistics = Statistics::new(&config);
let connection_validator = ConnectionValidator::new(&config)?;
let priv_dropper = PrivilegeDropper::new(config.privileges.clone(), config.socket_workers);

View file

@ -16,6 +16,7 @@ use aquatic_common::{CanonicalSocketAddr, IndexMap};
use aquatic_udp_protocol::*;
use arrayvec::ArrayVec;
use crossbeam_channel::Sender;
use hashbrown::HashMap;
use hdrhistogram::Histogram;
use parking_lot::RwLockUpgradableReadGuard;
use rand::prelude::SmallRng;
@ -29,24 +30,24 @@ const SMALL_PEER_MAP_CAPACITY: usize = 2;
use aquatic_udp_protocol::InfoHash;
use parking_lot::RwLock;
type TorrentMapShard<T> = IndexMap<InfoHash, Arc<TorrentData<T>>>;
#[derive(Clone)]
pub struct TorrentMaps {
ipv4: TorrentMapShards<Ipv4AddrBytes>,
ipv6: TorrentMapShards<Ipv6AddrBytes>,
}
impl TorrentMaps {
pub fn new(config: &Config) -> Self {
let num_shards = 16usize;
impl Default for TorrentMaps {
fn default() -> Self {
const NUM_SHARDS: usize = 16;
Self {
ipv4: TorrentMapShards::new(num_shards),
ipv6: TorrentMapShards::new(num_shards),
ipv4: TorrentMapShards::new(NUM_SHARDS),
ipv6: TorrentMapShards::new(NUM_SHARDS),
}
}
}
impl TorrentMaps {
pub fn announce(
&self,
config: &Config,
@ -294,6 +295,9 @@ impl<I: Ip> TorrentMapShards<I> {
}
}
/// Use HashMap instead of IndexMap for better lookup performance
type TorrentMapShard<T> = HashMap<InfoHash, Arc<TorrentData<T>>>;
pub struct TorrentData<T: Ip> {
peer_map: RwLock<PeerMap<T>>,
pending_removal: AtomicBool,