Struct mz_persist_client::async_runtime::IsolatedRuntime
source · pub struct IsolatedRuntime {
inner: Option<Runtime>,
}
Expand description
An isolated runtime for asynchronous tasks, particularly work that may be CPU intensive such as encoding/decoding and shard maintenance.
Using a separate runtime allows Persist to isolate its expensive workloads on its own OS threads as an insurance policy against tasks that erroneously fail to yield for a long time. By using separate OS threads, the scheduler is able to context switch out of any problematic tasks, preserving liveness for the rest of the process.
Note: Even though the work done by this runtime might be “blocking” or
CPU bound we should not use the tokio::task::spawn_blocking
API.
There can be issues during shutdown if tasks are currently running on the
blocking thread pool 1, and the blocking thread pool generally creates
many more threads than are physically available. This can pin CPU usage
to 100% starving other important threads like the Coordinator.
Fields§
§inner: Option<Runtime>
Implementations§
source§impl IsolatedRuntime
impl IsolatedRuntime
sourcepub fn new(worker_threads: usize) -> IsolatedRuntime
pub fn new(worker_threads: usize) -> IsolatedRuntime
Creates a new isolated runtime.
sourcepub fn spawn_named<N, S, F>(&self, name: N, fut: F) -> JoinHandle<F::Output>
pub fn spawn_named<N, S, F>(&self, name: N, fut: F) -> JoinHandle<F::Output>
Spawns a task onto this runtime.
Note: We purposefully do not use the tokio::task::spawn_blocking
API here, see the doc
comment on IsolatedRuntime
for explanation.
Trait Implementations§
source§impl Debug for IsolatedRuntime
impl Debug for IsolatedRuntime
source§impl Default for IsolatedRuntime
impl Default for IsolatedRuntime
Auto Trait Implementations§
impl !Freeze for IsolatedRuntime
impl RefUnwindSafe for IsolatedRuntime
impl Send for IsolatedRuntime
impl Sync for IsolatedRuntime
impl Unpin for IsolatedRuntime
impl UnwindSafe for IsolatedRuntime
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> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.