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.
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
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§
source§impl<'de> Deserialize<'de> for Cfg
impl<'de> Deserialize<'de> for Cfg
source§fn 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>,
source§impl Ord for Cfg
impl Ord for Cfg
source§impl PartialEq for Cfg
impl PartialEq for Cfg
source§impl PartialOrd for Cfg
impl PartialOrd for Cfg
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more