euv_performance/stress/struct.rs
1use super::*;
2
3/// Per-iteration latency percentile distribution, frame-budget misses, allocation counters, and layout/damage telemetry.
4#[derive(Clone, Copy, Debug, Default, Deserialize, Getter, PartialEq, Serialize)]
5pub struct LatencyDistribution {
6 /// Number of measured iterations included in this distribution.
7 #[get(type(copy))]
8 pub(crate) iterations: usize,
9 /// Median (50th percentile) per-iteration latency in microseconds.
10 #[get(type(copy))]
11 pub(crate) p50_us: f64,
12 /// 95th percentile per-iteration latency in microseconds.
13 #[get(type(copy))]
14 pub(crate) p95_us: f64,
15 /// 99th percentile per-iteration latency in microseconds.
16 #[get(type(copy))]
17 pub(crate) p99_us: f64,
18 /// 99.9th percentile per-iteration latency in microseconds.
19 #[get(type(copy))]
20 #[serde(default)]
21 pub(crate) p99_9_us: f64,
22 /// Maximum single-iteration latency in microseconds.
23 #[get(type(copy))]
24 pub(crate) max_us: f64,
25 /// Arithmetic mean per-iteration latency in microseconds.
26 #[get(type(copy))]
27 pub(crate) mean_us: f64,
28 /// Sample standard deviation (frame-time jitter) in microseconds.
29 #[get(type(copy))]
30 pub(crate) jitter_us: f64,
31 /// Number of iterations exceeding the 480Hz frame budget (`2.083ms`).
32 #[get(type(copy))]
33 #[serde(default)]
34 pub(crate) over_2_08ms_count: usize,
35 /// Number of iterations exceeding the 360Hz frame budget (`2.778ms`).
36 #[get(type(copy))]
37 pub(crate) over_2_78ms_count: usize,
38 /// Number of iterations exceeding the 240Hz frame budget (`4.167ms`).
39 #[get(type(copy))]
40 pub(crate) over_4_17ms_count: usize,
41 /// Number of iterations exceeding the 144Hz frame budget (`6.94ms`).
42 #[get(type(copy))]
43 pub(crate) over_6_94ms_count: usize,
44 /// Number of iterations exceeding the 60Hz frame budget (`16.67ms`).
45 #[get(type(copy))]
46 pub(crate) over_16_67ms_count: usize,
47 /// Percentage of measured frames exceeding the 240Hz (`4.167ms`) budget.
48 #[get(type(copy))]
49 pub(crate) missed_240hz_pct: f64,
50 /// Percentage of measured frames exceeding the 360Hz (`2.778ms`) budget.
51 #[get(type(copy))]
52 pub(crate) missed_360hz_pct: f64,
53 /// Percentage of measured frames exceeding the 480Hz (`2.083ms`) budget.
54 #[get(type(copy))]
55 #[serde(default)]
56 pub(crate) missed_480hz_pct: f64,
57 /// Effective sustained throughput in frames per second (`1_000_000 / mean_us`).
58 #[get(type(copy))]
59 pub(crate) effective_fps: f64,
60 /// Arithmetic mean `FrameTelemetry::dirty_area_ratio` across measured frames (`0.0` when not applicable).
61 #[get(type(copy))]
62 pub(crate) mean_dirty_area_ratio: f64,
63 /// Count of measured frames that promoted to full-viewport redraw (`FullRedrawReason != None`).
64 #[get(type(copy))]
65 pub(crate) full_redraw_count: usize,
66 /// Total heap allocations recorded across all measured steady-state frames.
67 #[get(type(copy))]
68 #[serde(default)]
69 pub(crate) alloc_count_total: u64,
70 /// Total heap deallocations recorded across all measured steady-state frames.
71 #[get(type(copy))]
72 #[serde(default)]
73 pub(crate) free_count_total: u64,
74 /// Total heap bytes allocated across all measured steady-state frames.
75 #[get(type(copy))]
76 #[serde(default)]
77 pub(crate) bytes_allocated_total: u64,
78 /// Arithmetic mean heap allocations per measured frame.
79 #[get(type(copy))]
80 #[serde(default)]
81 pub(crate) mean_allocs_per_frame: f64,
82 /// Arithmetic mean heap bytes allocated per measured frame.
83 #[get(type(copy))]
84 #[serde(default)]
85 pub(crate) mean_bytes_per_frame: f64,
86 /// Maximum single-frame heap allocation count observed.
87 #[get(type(copy))]
88 #[serde(default)]
89 pub(crate) max_allocs_per_frame: u64,
90 /// Maximum single-frame heap bytes allocated observed.
91 #[get(type(copy))]
92 #[serde(default)]
93 pub(crate) max_bytes_per_frame: u64,
94 /// Peak positive net live heap bytes observed during the measured window.
95 #[get(type(copy))]
96 #[serde(default)]
97 pub(crate) peak_live_bytes: u64,
98 /// Measured layout invalidation delta during this scenario window.
99 #[get(type(copy))]
100 #[serde(default)]
101 pub(crate) layout_invalidations: u64,
102 /// Measured executed layout passes during this scenario window.
103 #[get(type(copy))]
104 #[serde(default)]
105 pub(crate) layout_passes: u64,
106 /// Measured layout passes that mutated node geometry during this scenario window.
107 #[get(type(copy))]
108 #[serde(default)]
109 pub(crate) layout_changed_passes: u64,
110 /// Measured total scene nodes whose final layout geometry changed during this window.
111 #[get(type(copy))]
112 #[serde(default)]
113 pub(crate) layout_changed_nodes_total: u64,
114 /// Measured total display-list draw commands recorded during this scenario window.
115 #[get(type(copy))]
116 #[serde(default)]
117 pub(crate) draw_commands_total: u64,
118 /// Measured total physical pixels shaded during this scenario window.
119 #[get(type(copy))]
120 #[serde(default)]
121 pub(crate) pixels_shaded_total: u64,
122}
123
124/// Pre-allocated per-scenario telemetry accumulator avoiding measurement-induced heap allocations.
125#[derive(Clone, Debug, Default)]
126pub(crate) struct FrameMeasureAccum {
127 /// Raw per-iteration elapsed durations in microseconds.
128 pub(crate) samples_us: Vec<f64>,
129 /// Per-frame `dirty_area_ratio` samples.
130 pub(crate) dirty_ratios: Vec<f32>,
131 /// Count of measured frames that promoted to full-viewport redraw.
132 pub(crate) full_redraw_count: usize,
133 /// Cumulative heap allocation count across all measured frames.
134 pub(crate) alloc_count_total: u64,
135 /// Cumulative heap free count across all measured frames.
136 pub(crate) free_count_total: u64,
137 /// Cumulative heap bytes allocated across all measured frames.
138 pub(crate) bytes_allocated_total: u64,
139 /// Peak single-frame heap allocation count.
140 pub(crate) max_allocs_per_frame: u64,
141 /// Peak single-frame heap bytes allocated.
142 pub(crate) max_bytes_per_frame: u64,
143 /// Peak net live heap bytes observed during the measured window.
144 pub(crate) peak_live_bytes: u64,
145 /// Measured layout invalidations delta across the window.
146 pub(crate) layout_invalidations: u64,
147 /// Measured layout passes delta across the window.
148 pub(crate) layout_passes: u64,
149 /// Measured layout changed passes delta across the window.
150 pub(crate) layout_changed_passes: u64,
151 /// Measured layout changed nodes total delta across the window.
152 pub(crate) layout_changed_nodes_total: u64,
153 /// Cumulative display-list draw commands recorded across the window.
154 pub(crate) draw_commands_total: u64,
155 /// Cumulative physical pixels shaded across the window.
156 pub(crate) pixels_shaded_total: u64,
157}
158
159/// Per-step result captured from one leaf row mutation inside the A/B partial-damage benchmark.
160#[derive(Clone, Copy, Debug)]
161pub(crate) struct RowMutationStep {
162 /// Elapsed `App::step_frame` wall latency in microseconds.
163 pub(crate) elapsed_us: f64,
164 /// Deterministic rendered framebuffer hash.
165 pub(crate) frame_hash: u64,
166 /// Per-frame damage, paint, and layout telemetry snapshot.
167 pub(crate) telemetry: FrameTelemetry,
168 /// Exact heap allocation delta observed during `step_frame`.
169 pub(crate) alloc_delta: AllocationSnapshot,
170}
171
172/// Single scenario entry recorded inside a `StressMatrixReport`.
173#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
174pub struct StressMatrixEntry {
175 /// Canonical stress scenario identifier.
176 pub(crate) name: String,
177 /// Recorded per-iteration latency distribution and frame-budget telemetry.
178 #[get(type(copy))]
179 pub(crate) latency: LatencyDistribution,
180 /// Human-readable verification metadata and scenario invariants.
181 pub(crate) detail: String,
182}
183
184/// Interleaved A/B comparison validating P1 surgical partial-layout damage against full redraw.
185#[derive(Clone, Debug, Deserialize, Getter, PartialEq, Serialize)]
186pub struct PartialDamageAbSummary {
187 /// Canonical A/B scenario identifier.
188 pub(crate) name: String,
189 /// Distribution captured with `app.set_partial_layout_damage(false)`.
190 #[get(type(copy))]
191 pub(crate) baseline_full_redraw: LatencyDistribution,
192 /// Distribution captured with `app.set_partial_layout_damage(true)`.
193 #[get(type(copy))]
194 pub(crate) candidate_partial_damage: LatencyDistribution,
195 /// Percentage latency reduction at p50 (`> 0.0` means partial damage is faster).
196 #[get(type(copy))]
197 pub(crate) p50_speedup_pct: f64,
198 /// Percentage latency reduction at p95 (`> 0.0` means partial damage is faster).
199 #[get(type(copy))]
200 pub(crate) p95_speedup_pct: f64,
201 /// Percentage latency reduction at p99 (`> 0.0` means partial damage is faster).
202 #[get(type(copy))]
203 pub(crate) p99_speedup_pct: f64,
204 /// Percentage reduction in mean `dirty_area_ratio` from full redraw to surgical partial damage.
205 #[get(type(copy))]
206 pub(crate) dirty_area_ratio_drop_pct: f64,
207 /// `true` when every single measured frame produced bit-exact RGBA framebuffer parity.
208 #[get(type(copy))]
209 pub(crate) bit_exact_parity: bool,
210 /// Number of interleaved A/B frames verified for hash parity.
211 #[get(type(copy))]
212 pub(crate) verified_steps: usize,
213 /// Concise summary of resolution, parity, and dirty-area telemetry.
214 pub(crate) detail: String,
215}
216
217/// Complete serialized report produced by `run_stress_matrix` / `run_filtered_stress_matrix`.
218#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
219pub struct StressMatrixReport {
220 /// Ordered stress scenario results.
221 pub(crate) entries: Vec<StressMatrixEntry>,
222 /// Optional structured interleaved A/B partial-layout damage comparison when that scenario ran.
223 #[get(skip)]
224 pub(crate) partial_damage_ab: Option<PartialDamageAbSummary>,
225 /// Optional stage-attributed cold-start TTFF benchmark breakdown when that scenario ran.
226 #[get(skip)]
227 #[new(skip)]
228 #[serde(default, skip_serializing_if = "Option::is_none")]
229 pub(crate) cold_start_ttff: Option<ColdStartTtffReport>,
230}
231
232/// Deterministic 2D arcade benchmark scene decoupling 60Hz fixed physics from 240Hz/480Hz interpolated rendering.
233#[derive(Clone, Data, Debug)]
234pub(crate) struct BenchGame2dScene {
235 /// Generational ECS entity arena.
236 pub(crate) world: GameWorld,
237 /// Spatial-hash 2D rigid-body physics solver.
238 pub(crate) physics: PhysicsWorld2D,
239 /// Zero-allocation pooled particle emitter.
240 pub(crate) particles: ParticleSystem,
241 /// Frustum-culled arena tilemap.
242 pub(crate) tilemap: TileMap,
243 /// Follow camera tracking the arena player.
244 #[get(type(copy))]
245 pub(crate) camera: Camera2D,
246 /// Immutable double-buffered world snapshots for render-time interpolation.
247 pub(crate) snapshots: DoubleBufferedSnapshot<World2DSnapshot>,
248 /// Active player entity identifier.
249 #[get(type(copy))]
250 pub(crate) player_id: EntityId,
251 /// Cumulative fixed simulation ticks executed.
252 #[get(type(copy))]
253 pub(crate) fixed_steps: u64,
254 /// Cumulative interpolated visual frames rendered.
255 #[get(type(copy))]
256 pub(crate) rendered_frames: u64,
257 /// Persistent scratch buffer formatting HUD text without per-frame allocations.
258 pub(crate) hud_text_buf: String,
259}
260
261/// Deterministic 3D GPU direct-composite benchmark scene decoupling 60Hz simulation from 240Hz/480Hz HUD+GPU compositing.
262#[derive(Clone, Data, Debug)]
263pub(crate) struct BenchGame3dGpuScene {
264 /// Open-world 3D city simulation state.
265 pub(crate) world: World3D,
266 /// Action map driving deterministic vehicle motion.
267 pub(crate) actions: ActionMap,
268 /// Double-buffered 3D simulation snapshots for interpolated presentation.
269 pub(crate) snapshots: DoubleBufferedSnapshot<World3DSnapshot>,
270 /// Shared same-device GPU render target descriptor for zero-readback compositing.
271 pub(crate) gpu_target: GpuCompositeTarget,
272 /// Monotonic GPU submission fence counter.
273 #[get(type(copy))]
274 pub(crate) frame_fence: u64,
275 /// Cumulative fixed simulation ticks executed.
276 #[get(type(copy))]
277 pub(crate) fixed_steps: u64,
278 /// Cumulative interpolated visual frames rendered.
279 #[get(type(copy))]
280 pub(crate) rendered_frames: u64,
281 /// Persistent scratch buffer formatting HUD text without per-frame allocations.
282 pub(crate) hud_text_buf: String,
283}