Skip to main content

RunState

Struct RunState 

Source
pub struct RunState {
Show 34 fields pub workload_file: String, pub scenario_name: String, pub adapter: String, pub started_at: Instant, pub started_at_utc: SystemTime, pub profiler: String, pub limit: String, pub tree: SceneTree, pub summaries: HashMap<SceneNodeId, PhaseSummary>, pub sysmon: Option<SysmonSample>, pub phase_session_elapsed: HashMap<SceneNodeId, f64>, pub phase_session_started: HashMap<SceneNodeId, f64>, pub phase_ops: HashMap<SceneNodeId, Vec<OpEntry>>, pub phases: Vec<PhaseEntry>, pub expected_total_phases: usize, pub active_phases: HashMap<PhaseKey, ActivePhase>, pub min_nanos: u64, pub p50_nanos: u64, pub p90_nanos: u64, pub p99_nanos: u64, pub p999_nanos: u64, pub max_nanos: u64, pub log_messages: Vec<LogEntry>, pub log_seq_total: u64, pub ops_history: Vec<f64>, pub rows_history: Vec<f64>, pub rows_sparkline_label: Option<String>, pub max_history: Vec<u64>, pub min_history: Vec<u64>, pub p50_history: Vec<u64>, pub p90_history: Vec<u64>, pub p99_history: Vec<u64>, pub p999_history: Vec<u64>, pub finished: bool,
}
Expand description

Top-level run state shared between executor and TUI.

Fields§

§workload_file: String§scenario_name: String§adapter: String§started_at: Instant§started_at_utc: SystemTime

Wall-clock at session start. Captured alongside the monotonic started_at so the failure-dump path can (a) print a UTC header naming the absolute moment 0.00000 corresponds to, and (b) compute per-entry deltas against it. The monotonic started_at stays authoritative for elapsed-time comparisons; this one is for human-readable display only.

§profiler: String§limit: String§tree: SceneTree

Canonical scene tree: every concrete phase + scope header wired by parent / children pointers. The pre-mapped scenario shape lands here once via scenario_pre_mapped; lifecycle callbacks (set_phase_running / _completed / _failed) mutate node statuses in place.

§summaries: HashMap<SceneNodeId, PhaseSummary>

Heavy per-phase metrics produced at completion. Keyed by SceneNodeId so scope-level renderers can also look up child summaries cheaply. Side-map (rather than baked into SceneNode) so the tree itself stays small / serializable.

§sysmon: Option<SysmonSample>

Latest sysmon sample window (host utilization), when the session-level sampler is enabled. Refreshed every sample interval; None when the sampler is off, so display surfaces add nothing.

§phase_session_elapsed: HashMap<SceneNodeId, f64>

Side-map of the session clock reading captured when each leaf reached a terminal state (completed/failed), keyed by SceneNodeId. Mirrors summaries; feeds PhaseEntry::session_elapsed so a finished row persists the session time at which it finished.

§phase_session_started: HashMap<SceneNodeId, f64>

Session clock at each phase’s Running transition — see PhaseEntry::session_started. Keyed like phase_session_elapsed.

§phase_ops: HashMap<SceneNodeId, Vec<OpEntry>>

Op-level status leaves keyed by their parent phase’s SceneNodeId, in arrival order. Populated only for ops declaring readout: visible (via the readout wrapper’s op-lifecycle events); empty otherwise, so there is no cost for the common case.

§phases: Vec<PhaseEntry>

Denormalized DFS view of tree in display order, kept in sync by rebuild_phases() after every tree mutation. Read by the renderer hot paths via state.phases indexing — rebuilding once per mutation beats walking the tree per frame, and the cost is negligible (mutations are a handful per phase lifecycle, not per-op).

§expected_total_phases: usize

Phase-count denominator from the pre-map walk — pinned at install_tree time and never mutated by runtime phase materialization. The renderer’s X/N margin display reads this as the stable Y, so an operator watching the progress sees a fixed total rather than one that drifts upward as for_each expansion lands new phases at runtime.

When the runtime materializes more phases than the pre-map enumerated (param-driven for_each whose iter source the structural walker couldn’t resolve), the numerator can exceed expected_total_phases — that’s the honest signal that the planning walk under-counted, surfaced as N/Y with N > Y rather than papered over by a moving denominator.

§active_phases: HashMap<PhaseKey, ActivePhase>

Every phase currently in flight, keyed by (name, labels). Empty between phases. Multi-phase scenarios (stanza-level parallelism, multi-activity sessions) populate more than one entry. Most read sites today still assume at most one running phase — those use Self::first_active as a compatibility shim over the map.

§min_nanos: u64

Latency percentiles from last capture (nanoseconds).

§p50_nanos: u64§p90_nanos: u64§p99_nanos: u64§p999_nanos: u64§max_nanos: u64§log_messages: Vec<LogEntry>

Log ring buffer (last 200 entries). Displayed in TUI log panel.

§log_seq_total: u64

Monotonic sequence of every push to log_messages, never decremented. The ring keeps only the last 200 entries; this counter keeps growing forever so crate::display_sink implementations can detect “new entries since I last drained” without wrestling the ring. A renderer remembers the last value it printed; on each tick it looks at log_seq_total - last_printed and reads that many entries off the tail of log_messages. Overflow (renderer slower than 200 events / poll) is detectable as delta > log_messages.len() and the renderer can emit a “dropped N log lines” notice.

§ops_history: Vec<f64>

Rolling ops/s history for sparkline (last 120 samples).

§rows_history: Vec<f64>

Rolling secondary-counter history for sparkline. The counter sampled is whichever adapter counter is first in active.adapter_counters — only populated when an adapter actually reports one, so it’s never a hardcoded “rows”.

§rows_sparkline_label: Option<String>

Display label for the secondary sparkline (e.g. “rows/s” or “inserted/s”). None when no adapter counter is being tracked.

§max_history: Vec<u64>

Rolling max-latency history (nanoseconds). Sampled every drain tick (~250ms). Used by the latency panel to mark windowed peaks (e.g., “last 5s”, “last 10s”) with cross-bar glyphs.

§min_history: Vec<u64>

Rolling per-percentile histories, one push per frame delivered by the metrics scheduler (≈1 Hz). Fed to the time-series latency view and the short-window (5s / 15s max) variants on the barchart. Bounded at HISTORY_CAP so memory doesn’t grow with the run — for true lifetime statistics use the *_lifetime aggregates below.

§p50_history: Vec<u64>§p90_history: Vec<u64>§p99_history: Vec<u64>§p999_history: Vec<u64>§finished: bool

Set to true when the run is complete.

Implementations§

Source§

impl RunState

Source

pub fn new(workload_file: &str, scenario_name: &str, adapter: &str) -> Self

Source

pub fn first_active(&self) -> Option<&ActivePhase>

Borrow any one currently-running phase, if any exist. Compatibility shim for call sites that still assume a single running phase (ETA display, header labels, …). Multi-phase call sites should iterate Self::active_phases directly.

Source

pub fn active_phase(&self, name: &str, labels: &str) -> Option<&ActivePhase>

Borrow the active-phase entry matching a specific (name, labels) pair — used when the caller already knows which phase row it’s rendering detail for.

Source

pub fn active_phase_mut( &mut self, exec_id: u64, name: &str, labels: &str, ) -> Option<&mut ActivePhase>

Mutable borrow of the active-phase entry for a specific (exec_id, name, labels) key. Used by the observer’s progress callback to update in place.

Source

pub fn push_log(&mut self, severity: LogSeverity, message: String)

Push a log entry to the ring buffer (capped at 200). log_seq_total increments unconditionally so display sinks can detect new-since-last-drain without inspecting the ring.

Source

pub fn push_log_tagged( &mut self, severity: LogSeverity, tag: EventTag, message: String, )

Self::push_log with an explicit EventTag. The tag travels with the entry into the ring so the terminal sink can derive its filtering (boundary-attached renders out of scrollback) from the axes at drain time.

Source

pub fn push_log_entry(&mut self, entry: LogEntry) -> u64

Push a pre-built LogEntry into the ring and return the new Self::log_seq_total it was assigned. The ring stays bounded (last 200) — it backs the inspector log view, the TUI log panel, and the post-run failure dump, none of which need unbounded history. The durable, no-drop scrollback stream is a separate channel the actor feeds in lock-step with this push (see crate::run_state_actor::spawn_run_state_actor); the returned seq tags the matching stream item so a terminal-mode sink can skip lines already emitted elsewhere (pre-handoff stderr, or a prior sink’s scrollback).

Source

pub fn push_ops_sample(&mut self, ops_per_sec: f64)

Push an ops/s sample to the sparkline history (capped at 120).

Source

pub fn push_rows_sample(&mut self, rows_per_sec: f64)

Push a rows/s sample to the sparkline history.

Source

pub fn install_tree(&mut self, tree: SceneTree)

Replace the scene tree wholesale — called once from the observer’s scenario_pre_mapped hook with the fully resolved pre-map. Existing summaries are dropped (they never apply across pre-maps).

Source

pub fn add_phase(&mut self, name: &str, labels: &str, _depth: usize)

Add a pending phase to the tree at the synthetic root — fallback path for sources that don’t pre-map.

Source

pub fn add_scope(&mut self, label: &str, _depth: usize)

Add a visual grouping header at the synthetic root.

Source

pub fn set_phase_running( &mut self, scene_node_id: SceneNodeId, name: &str, labels: &str, op_count: usize, )

Mark a phase as running, keyed by the dispatch-time scene_node_id (SRD-100 P1c). Pre-mapped phases flip their own node directly; a phase the pre-map never enumerated is pushed dynamically so it still gets a tree slot.

Source

pub fn final_op_leaves(&self, name: &str, labels: &str) -> Vec<(String, String)>

Mark a phase as completed and attach a metrics summary, keyed by the dispatch-time scene_node_id (SRD-100 P1c). Final per-op timing leaves for a phase at its completion — the durable form of the footer’s SRD-63 op rows, preserved into scrollback under the ✓ outcome block. Terminal ops carry their execution time and session finish-stamp; an op still mid-flight at phase end (a cancelled daemon probe) shows —. Empty when the phase declared no readout: visible ops. Returns (line, duration_cell) pairs: the leaf body carries icon · name · [i/N] · @ session-stamp; the node’s own execution DURATION is the second element, rendered as the leaf row’s default gutter cell (SRD-92: a visible node with no declared gutter gets its execution time as the cell — the scannable per-step time ledger). Single placement: the duration appears only in the cell, the session stamp only in the body.

Source

pub fn set_phase_completed( &mut self, scene_node_id: SceneNodeId, name: &str, labels: &str, duration_secs: f64, summary: PhaseSummary, )

Source

pub fn set_phase_failed( &mut self, scene_node_id: SceneNodeId, name: &str, labels: &str, error: &str, )

Mark a phase as failed, keyed by the dispatch-time scene_node_id (SRD-100 P1c).

Source

pub fn op_starting(&mut self, parent: SceneNodeId, name: &str)

An op-level status leaf started (SRD-63). Creates or re-arms the entry (keyed by name within the parent phase) as Running with a fresh timer.

Source

pub fn op_measure(&mut self, parent: SceneNodeId, op_name: &str, text: &str)

An op-level status leaf completed; persists its execution time and the session clock at completion. Record an op’s key measurable. Arrives just before completion, so the leaf row has it the moment it settles.

Source

pub fn op_completed( &mut self, parent: SceneNodeId, name: &str, duration_secs: f64, )

Source

pub fn op_failed(&mut self, parent: SceneNodeId, name: &str, error: &str)

An op-level status leaf failed; freezes its elapsed time and session clock.

Source

pub fn elapsed_secs(&self) -> f64

Elapsed time since run started.

Source

pub fn margin_body_stamp(&self) -> String

The uncolored status-margin body (session · [n/N] · leaf) for the CURRENT state. The run-state actor stamps this onto every scrollback line at Log-command processing time, so a line’s gutter is computed from exactly the state that preceded it in the command stream — it can never disagree with the event the line describes (the old render-time margin was one snapshot for a whole drained batch, and raced the very transitions the lines reported).

Source

pub fn total_phases(&self) -> usize

Total Phase entries in the pre-mapped scene tree — denominator for the [N/total] and phase X/Y displays.

Trait Implementations§

Source§

impl Clone for RunState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more