Struct tonic::codec::BufferSettings
source · pub struct BufferSettings { /* private fields */ }
Expand description
Settings for how tonic allocates and grows buffers.
Tonic eagerly allocates the buffer_size per RPC, and grows the buffer by buffer_size increments to handle larger messages. Buffer size defaults to 8KiB.
Example:
Buffer start: | 8kb |
Message received: | 24612 bytes |
Buffer grows: | 8kb | 8kb | 8kb | 8kb |
The buffer grows to the next largest buffer_size increment of 32768 to hold 24612 bytes, which is just slightly too large for the previous buffer increment of 24576.
If you use a smaller buffer size you will waste less memory, but you will allocate more frequently. If one way or the other matters more to you, you may wish to customize your tonic Codec (see codec_buffers example).
Yield threshold is an optimization for streaming rpcs. Sometimes you may have many small messages ready to send. When they are ready, it is a much more efficient use of system resources to batch them together into one larger send(). The yield threshold controls how much you want to bulk up such a batch of ready-to-send messages. The larger your yield threshold the more you will batch - and consequently allocate contiguous memory, which might be relevant if you’re considering large numbers here. If your server streaming rpc does not reach the yield threshold before it reaches Poll::Pending (meaning, it’s waiting for more data from wherever you’re streaming from) then Tonic will just send along a smaller batch. Yield threshold is an upper-bound, it will not affect the responsiveness of your streaming rpc (for reasonable sizes of yield threshold). Yield threshold defaults to 32 KiB.
Implementations§
Trait Implementations§
source§impl Clone for BufferSettings
impl Clone for BufferSettings
source§fn clone(&self) -> BufferSettings
fn clone(&self) -> BufferSettings
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BufferSettings
impl Debug for BufferSettings
source§impl Default for BufferSettings
impl Default for BufferSettings
impl Copy for BufferSettings
Auto Trait Implementations§
impl Freeze for BufferSettings
impl RefUnwindSafe for BufferSettings
impl Send for BufferSettings
impl Sync for BufferSettings
impl Unpin for BufferSettings
impl UnwindSafe for BufferSettings
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request