1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! Read-only access to runtime observations; callers cannot construct internal state.
impl crate::RuntimeSnapshot {
/// Latest inert, bounded scope report; original error sources remain caller-owned.
pub fn last_scope_failure(&self) -> Option<&crate::scope_failure_report::ScopeFailureReport> {
self.last_scope_failure.as_deref()
}
/// Bounded terminal component failures, retained through shutdown.
pub fn failures(&self) -> &crate::ThreadFailures {
&self.failures
}
/// Current shutdown progress, including waits beyond task and native-job completion.
pub fn shutdown_phase(&self) -> crate::ShutdownPhase {
self.shutdown_phase
}
/// Whether new root scopes and task admissions are accepted (subject to capacity).
pub fn accepting(&self) -> bool {
self.accepting
}
/// Most recent stalled scope; only one bounded report is retained per runtime.
pub fn last_stall(&self) -> Option<&crate::StallSnapshot> {
self.last_stall.as_ref()
}
/// Readiness registration and delegated native-work bounds and activity.
pub fn services(&self) -> &crate::ServiceSnapshot {
&self.services
}
/// Per-carrier health and ownership counters.
pub fn carriers(&self) -> &[crate::CarrierSnapshot] {
&self.carriers
}
/// Number of live tasks.
pub fn active(&self) -> usize {
self.active
}
/// Number of tasks waiting in the run queue.
pub fn runnable(&self) -> usize {
self.runnable
}
/// Number of tasks parked on wait generations.
pub fn parked(&self) -> usize {
self.parked
}
/// Number of active monotonic timers.
pub fn timers(&self) -> usize {
self.timers
}
/// Cumulative scheduler counters.
pub fn stats(&self) -> crate::RuntimeStats {
self.stats
}
/// Stack-cache counters.
pub fn stacks(&self) -> crate::StackSnapshot {
self.stacks
}
/// Task records retained by the active scope.
pub fn tasks(&self) -> &[crate::TaskSnapshot] {
&self.tasks
}
}
impl crate::CarrierSnapshot {
/// Opt-in elapsed handoff/idle histograms and useful-channel-work counts.
/// Read after shutdown for final totals. This separate feature adds clocks;
/// its timings are diagnostic and cannot qualify default-build performance.
#[cfg(feature = "handoff-profiling")]
pub fn handoff_profile(&self) -> &crate::diagnostics::HandoffProfile {
&self.handoff_profile
}
/// Opt-in carrier-local batch and idle counters, published with this snapshot.
/// Read after shutdown for final totals; active observations may lag. The
/// `scheduler-profiling` feature adds no clock reads or shared counter atomics.
#[cfg(feature = "scheduler-profiling")]
pub fn scheduler_profile(&self) -> crate::diagnostics::SchedulerProfile {
self.scheduler_profile
}
/// Stable runtime-local identity.
pub fn id(&self) -> crate::CarrierId {
self.id
}
/// Current carrier health.
pub fn status(&self) -> crate::CarrierStatus {
self.status
}
/// Tasks with retained stacks or unstarted admission.
pub fn active(&self) -> usize {
self.active
}
/// Local runnable stacks.
pub fn runnable(&self) -> usize {
self.runnable
}
/// Local parked stacks.
pub fn parked(&self) -> usize {
self.parked
}
/// Active monotonic timers.
pub fn timers(&self) -> usize {
self.timers
}
/// Unstarted packets waiting in the bounded inbox.
pub fn pending_starts(&self) -> usize {
self.pending_starts
}
/// Selected wake notices waiting in reserved slots.
pub fn pending_wakes(&self) -> usize {
self.pending_wakes
}
/// Cumulative carrier counters.
pub fn stats(&self) -> crate::RuntimeStats {
self.stats
}
/// Carrier-local stack cache.
pub fn stacks(&self) -> crate::StackSnapshot {
self.stacks
}
}
impl crate::StallSnapshot {
/// Explicit policy that caused this observation; reporting alone never cancels work.
pub fn policy(&self) -> crate::StallPolicy {
self.policy
}
/// Root scope selected for recovery.
pub fn scope(&self) -> crate::diagnostics::ScopeId {
crate::diagnostics::ScopeId::new(self.scope)
}
/// Monotonic detection time.
pub fn detected_at(&self) -> std::time::Instant {
self.detected_at
}
/// Observed quiescent interval before recovery.
pub fn quiescent_for(&self) -> std::time::Duration {
self.quiescent_for
}
/// Live tasks before abort, bounded by the configured task admission limit.
pub fn tasks(&self) -> &[crate::TaskSnapshot] {
&self.tasks
}
}
#[cfg(test)]
#[path = "diagnostics_accessors_test.rs"]
mod diagnostics_accessors_test;