Struct remoc::chmux::Cfg

source ·
pub struct Cfg {
    pub connection_timeout: Option<Duration>,
    pub max_ports: u32,
    pub ports_exhausted: PortsExhausted,
    pub max_data_size: usize,
    pub max_received_ports: usize,
    pub chunk_size: u32,
    pub receive_buffer: u32,
    pub shared_send_queue: usize,
    pub transport_send_queue: usize,
    pub transport_receive_queue: usize,
    pub connect_queue: u16,
    pub flush_delay: Duration,
    /* private fields */
}
Expand description

Channel multiplexer configuration.

In most cases the default configuration (Cfg::default) is recommended, since it provides a good balance between throughput, memory usage and latency.

In case of unsatisfactory performance (low throughput) your first step should be to increase the receive buffer size.

Fields§

§connection_timeout: Option<Duration>

Time after which connection is closed when no data is.

Pings are send automatically when this is enabled and no data is transmitted. By default this is 60 seconds.

§max_ports: u32

Maximum number of open ports.

This must not exceed 2^31 = 2147483648. By default this is 16384.

§ports_exhausted: PortsExhausted

Default behavior when ports are exhausted and a connect is requested.

This can be overridden on a per-request basis. By default this is wait with a timeout of 60 seconds.

§max_data_size: usize

Maximum size of received data per message in bytes.

Receiver::recv_chunk is not affected by this limit.

Remote channels will spawn a serialization and deserialization thread to transmit and receive data in chunks if this limit is reached. Thus, this does not limit the maximum serialized data size for remote channels but will incur a small performance cost for inter-thread communication when exceeded.

This can be configured on a per-receiver basis. By default this is 512 kB.

§max_received_ports: usize

Maximum port requests received per message.

For remote channels this configures how many more ports than expected (from the data type) can be received per message. This is useful for compatibility when the receiver has an older version of a struct type with less fields containing ports.

This can be configured on a per-receiver basis. By default this is 128.

§chunk_size: u32

Size of a chunk of data in bytes.

By default this is 16 kB. This must be at least 4 bytes. This must not exceed 2^32 - 16 = 4294967279.

§receive_buffer: u32

Size of receive buffer of each port in bytes.

This controls the maximum amout of in-flight data per port, that is data on the transport plus received but yet unprocessed data.

Increase this value if the throughput (bytes per second) is significantly lower than you would expect from your underlying transport connection.

By default this is 512 kB. This must be at least 4 bytes.

§shared_send_queue: usize

Length of global send queue. Each element holds a chunk.

This limits the number of chunks sendable by using Sender::try_send. It will not affect remote channels.

By default this is 16. This must not be zero.

§transport_send_queue: usize

Length of transport send queue. Each element holds a chunk.

Raising this may improve performance but might incur a slight increase in latency. For minimum latency this should be set to 1.

By default this is 16. This must not be zero.

§transport_receive_queue: usize

Length of transport receive queue. Each element holds a chunk.

Raising this may improve performance but might incur a slight increase in latency. For minimum latency this should be set to 1.

By default this is 16. This must not be zero.

§connect_queue: u16

Maximum number of outstanding connection requests.

By default this is 128. This must not be zero.

§flush_delay: Duration

Time to wait when no data is available for sending before flushing the send buffer of the connection.

By default this is 20 milliseconds.

Implementations§

source§

impl Cfg

source

pub fn max_frame_length(&self) -> u32

Returns the maximum size of a frame that can be received by a channel multiplexer using this configuration.

§Panics

Panics if the configuration is invalid.

source

pub fn balanced() -> Self

Configuration that is balanced between memory usage, latency and throughput.

source

pub fn compact() -> Self

Configuration that is optimized for low memory usage and low latency but may be throughput-limited.

source

pub fn throughput() -> Self

Configuration that is throughput-optimized but may use more memory per channel and may have higher latency.

Trait Implementations§

source§

impl Clone for Cfg

source§

fn clone(&self) -> Cfg

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Cfg

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Cfg

source§

fn default() -> Self

The default configuration provides a balance between throughput, memory usage and latency.

source§

impl<'de> Deserialize<'de> for Cfg

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for Cfg

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Cfg

source§

fn cmp(&self, other: &Cfg) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Cfg

source§

fn eq(&self, other: &Cfg) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Cfg

source§

fn partial_cmp(&self, other: &Cfg) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Cfg

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Cfg

source§

impl StructuralPartialEq for Cfg

Auto Trait Implementations§

§

impl Freeze for Cfg

§

impl RefUnwindSafe for Cfg

§

impl Send for Cfg

§

impl Sync for Cfg

§

impl Unpin for Cfg

§

impl UnwindSafe for Cfg

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> RemoteSend for T
where T: Send + Serialize + DeserializeOwned + 'static,