Driver, Input: Performance & Benchmarks (#27)
* Driver Benchmarks Benchmarks driver use cases for single packet send, multiple packet send, float vs opus, and the cost of head-of-queue track removal. Mix costs for large packet counts are also included. This is a prelude to the optimisations discussed in #21. * Typo in benchmark * Place Opus packet directly into packet buffer Cleans up some other logic surrounding this, too. Gets a 16.9% perf improvement on opus packet passthrough (sub 5us here). * Better track removal In theory this should be faster, but it aint. Keeping in case reducing struct sizes down the line magically makes this faster. * Reduce size of Input, TrackHandle Metadata is now boxed away. Similarly, TrackHandles are neatly Arc'd to reduce their size to pointer length (and mitigate the impact of copies if we add in more fields).
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use crate::{
|
||||
driver::{connection::error::Error, Config},
|
||||
events::EventData,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use crate::{
|
||||
events::{CoreContext, EventData, EventStore},
|
||||
tracks::{LoopState, PlayMode, TrackHandle, TrackState},
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
pub(crate) enum EventMessage {
|
||||
pub enum EventMessage {
|
||||
// Event related.
|
||||
// Track events should fire off the back of state changes.
|
||||
AddGlobalEvent(EventData),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use super::{Interconnect, UdpRxMessage, UdpTxMessage, WsMessage};
|
||||
|
||||
use crate::{
|
||||
@@ -8,7 +10,7 @@ use crate::{
|
||||
use flume::Sender;
|
||||
use xsalsa20poly1305::XSalsa20Poly1305 as Cipher;
|
||||
|
||||
pub(crate) struct MixerConnection {
|
||||
pub struct MixerConnection {
|
||||
pub cipher: Cipher,
|
||||
pub crypto_state: CryptoState,
|
||||
pub udp_rx: Sender<UdpRxMessage>,
|
||||
@@ -22,7 +24,7 @@ impl Drop for MixerConnection {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum MixerMessage {
|
||||
pub enum MixerMessage {
|
||||
AddTrack(Track),
|
||||
SetTrack(Option<Track>),
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
mod core;
|
||||
mod events;
|
||||
mod mixer;
|
||||
@@ -5,13 +7,13 @@ mod udp_rx;
|
||||
mod udp_tx;
|
||||
mod ws;
|
||||
|
||||
pub(crate) use self::{core::*, events::*, mixer::*, udp_rx::*, udp_tx::*, ws::*};
|
||||
pub use self::{core::*, events::*, mixer::*, udp_rx::*, udp_tx::*, ws::*};
|
||||
|
||||
use flume::Sender;
|
||||
use tracing::info;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct Interconnect {
|
||||
pub struct Interconnect {
|
||||
pub core: Sender<CoreMessage>,
|
||||
pub events: Sender<EventMessage>,
|
||||
pub mixer: Sender<MixerMessage>,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use super::Interconnect;
|
||||
use crate::driver::Config;
|
||||
|
||||
pub(crate) enum UdpRxMessage {
|
||||
pub enum UdpRxMessage {
|
||||
SetConfig(Config),
|
||||
ReplaceInterconnect(Interconnect),
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
pub enum UdpTxMessage {
|
||||
Packet(Vec<u8>), // TODO: do something cheaper.
|
||||
Poison,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use super::Interconnect;
|
||||
use crate::ws::WsStream;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum WsMessage {
|
||||
pub enum WsMessage {
|
||||
Ws(Box<WsStream>),
|
||||
ReplaceInterconnect(Interconnect),
|
||||
SetKeepalive(f64),
|
||||
|
||||
Reference in New Issue
Block a user