pub struct BatchConfig {
pub max_batch_size: usize,
pub batch_timeout: Duration,
pub workers: usize,
}Expand description
How requests are grouped into batches.
Batching is off by default: every request runs its own forward pass at once, as in a
hand-written server. Whether merging requests pays depends on the model. A convolutional
network on a CPU (or most models on a GPU) runs a batch of 4 in about the time of 2 single
passes, and serves more requests with batching on; a transformer on a CPU takes nearly 4
times as long for 4, and merging only makes requests wait. Turn it on with
max_batch_size above 1 for models of the first kind (benches/burn measures both).
Fields§
§max_batch_size: usizeMost items in one forward pass; 1 (the default) turns batching off. A request with more items than this still runs, alone.
batch_timeout: DurationLongest wait for requests still being received, counted from when the first request of the batch was queued
workers: usizeForward passes that may run at the same time; requests are merged into batches only while all of them are busy
Implementations§
Trait Implementations§
Source§impl Clone for BatchConfig
impl Clone for BatchConfig
impl Copy for BatchConfig
Source§impl Debug for BatchConfig
impl Debug for BatchConfig
Source§impl Default for BatchConfig
impl Default for BatchConfig
impl Eq for BatchConfig
Source§impl PartialEq for BatchConfig
impl PartialEq for BatchConfig
impl StructuralPartialEq for BatchConfig
Auto Trait Implementations§
impl Freeze for BatchConfig
impl RefUnwindSafe for BatchConfig
impl Send for BatchConfig
impl Sync for BatchConfig
impl Unpin for BatchConfig
impl UnsafeUnpin for BatchConfig
impl UnwindSafe for BatchConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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