pub struct HostVcpuSchedstat {
pub total_on_cpu_ns: u64,
pub total_run_delay_ns: u64,
pub sampled_vcpus: u32,
}Expand description
Host-side vCPU scheduling-dilation sample, summed over the run’s vCPU host threads.
Dilation D = 1 + Σrun_delay / Σon_cpu, where the two sums are
taken over each vCPU host thread’s /proc/self/task/<tid>/schedstat
(field 1 = time on-CPU ns, field 2 = time runnable-but-not-running
ns). D == 1.0 means the vCPU threads always got the CPU the instant
they were runnable; D > 1.0 quantifies host-side scheduling delay
(e.g. 1.03x = threads waited 3% on top of their run time).
Idle-immune: a halted vCPU is blocked (not runnable), so it accrues
no run_delay — halt time never inflates D. Measured HOST-side
deliberately: the guest run-queue’s own run_delay would measure the
scheduler under test, which is the thing being evaluated; the host
thread’s schedstat measures the CPU the vCPU thread was starved of by
the HOST, orthogonal to the guest scheduler.
RAW totals are stored (not the ratio) so future consumers can
recompute or re-aggregate; Self::dilation derives the ratio.
total_on_cpu_ns == 0 yields dilation() == None — this happens
BOTH when no vCPU thread ran at all AND on a host built without
CONFIG_SCHEDSTATS (every schedstat line reads "0 0 0"). None is
thus graceful and distinguishable from a genuine D == 1.0.
Fields§
§total_on_cpu_ns: u64Σ schedstat field 1 (time the vCPU threads spent ON-CPU), ns.
total_run_delay_ns: u64Σ schedstat field 2 (time the vCPU threads spent runnable but not running — host-side scheduling delay), ns.
sampled_vcpus: u32Number of vCPU host threads that contributed to the sums (a TID still 0 — an AP that never stamped its TID — and an unreadable schedstat are both skipped).
Implementations§
Source§impl HostVcpuSchedstat
impl HostVcpuSchedstat
Sourcepub fn dilation(&self) -> Option<f64>
pub fn dilation(&self) -> Option<f64>
Host dilation D = 1 + Σrun_delay / Σon_cpu, or None when no
on-CPU time was sampled (no vCPU ran, or the host lacks
CONFIG_SCHEDSTATS and every line read "0 0 0"). None is
deliberately distinguishable from a true D == 1.0 (which needs
nonzero on-CPU time with zero run-delay).
Sourcepub fn delta_from(&self, anchor: &HostVcpuSchedstat) -> HostVcpuSchedstat
pub fn delta_from(&self, anchor: &HostVcpuSchedstat) -> HostVcpuSchedstat
Field-wise saturating delta self - anchor over the two schedstat
sums — the on-CPU / run-delay accrued BETWEEN two cumulative
snapshots of the same vCPU threads. sampled_vcpus carries self’s
count (the reading the delta closes at). Saturating so a schedstat
that momentarily regressed (a TID that vanished then reappeared, a
torn read) contributes 0 rather than wrapping — conservative: a
per-phase D can only be UNDER-stated by such a clamp, never
fabricated. The result’s Self::dilation is the phase-local D.
Trait Implementations§
Source§impl Clone for HostVcpuSchedstat
impl Clone for HostVcpuSchedstat
Source§fn clone(&self) -> HostVcpuSchedstat
fn clone(&self) -> HostVcpuSchedstat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HostVcpuSchedstat
impl Debug for HostVcpuSchedstat
Source§impl Default for HostVcpuSchedstat
impl Default for HostVcpuSchedstat
Source§fn default() -> HostVcpuSchedstat
fn default() -> HostVcpuSchedstat
Source§impl<'de> Deserialize<'de> for HostVcpuSchedstat
impl<'de> Deserialize<'de> for HostVcpuSchedstat
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 PartialEq for HostVcpuSchedstat
impl PartialEq for HostVcpuSchedstat
Source§impl Serialize for HostVcpuSchedstat
impl Serialize for HostVcpuSchedstat
impl Copy for HostVcpuSchedstat
impl Eq for HostVcpuSchedstat
impl StructuralPartialEq for HostVcpuSchedstat
Auto Trait Implementations§
impl Freeze for HostVcpuSchedstat
impl RefUnwindSafe for HostVcpuSchedstat
impl Send for HostVcpuSchedstat
impl Sync for HostVcpuSchedstat
impl Unpin for HostVcpuSchedstat
impl UnwindSafe for HostVcpuSchedstat
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more