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,
/* 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: u32Maximum number of open ports.
This must not exceed 2^31 = 2147483648. By default this is 16384.
ports_exhausted: PortsExhaustedDefault 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: usizeMaximum 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: usizeMaximum 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: u32Size 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: u32Size 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.
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: usizeLength 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: usizeLength 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: u16Maximum number of outstanding connection requests.
By default this is 128. This must not be zero.
Implementations
sourceimpl Cfg
impl Cfg
sourcepub fn max_frame_length(&self) -> u32
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.
sourcepub fn balanced() -> Self
pub fn balanced() -> Self
Configuration that is balanced between memory usage, latency and throughput.
sourcepub fn compact() -> Self
pub fn compact() -> Self
Configuration that is optimized for low memory usage and low latency but may be throughput-limited.
sourcepub fn throughput() -> Self
pub fn throughput() -> Self
Configuration that is throughput-optimized but may use more memory per channel and may have higher latency.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Cfg
impl<'de> Deserialize<'de> for Cfg
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Cfg
impl Ord for Cfg
sourceimpl PartialOrd<Cfg> for Cfg
impl PartialOrd<Cfg> for Cfg
sourcefn partial_cmp(&self, other: &Cfg) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
impl Eq for Cfg
impl StructuralEq for Cfg
impl StructuralPartialEq for Cfg
Auto Trait Implementations
impl RefUnwindSafe for Cfg
impl Send for Cfg
impl Sync for Cfg
impl Unpin for Cfg
impl UnwindSafe for Cfg
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
