diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 93943c519..a8360a32b 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -185,7 +185,8 @@ four histograms of each command buffer's stages, in 23 power-of-two buckets from 2^22 us (about 4.19 s) or more, filled from the times the command buffer already reports: commit to scheduled (`commit_to_scheduled`, counted as it is scheduled), scheduled to GPU start, the GPU run, and GPU end to the host time its handlers begin (counted as it retires, for one that -completes with GPU times); the segments the submit thread held for an event's value that neither +completes with GPU times), each beside its spans' sum in nanoseconds (`commit_to_scheduled_nanos` +and the three like it); the segments the submit thread held for an event's value that neither the host had set nor a submitted signal promised, by the length of each hold (`event_holds`, in the same buckets); the groups a queue held behind three submissions in flight that went once a completion left fewer running (`held_starts`), and the GPU's time behind them, from the latest diff --git a/crates/metal2vulkan-runtime/src/counters.rs b/crates/metal2vulkan-runtime/src/counters.rs index 549e9dfa8..b33ae81fb 100644 --- a/crates/metal2vulkan-runtime/src/counters.rs +++ b/crates/metal2vulkan-runtime/src/counters.rs @@ -506,8 +506,9 @@ struct Atomics { submit_calls_over_100_ms: AtomicU64, queue_lock_wait_nanos: AtomicU64, queue_lock_wait_max_nanos: AtomicU64, - /// Each [`Stage`]'s histogram, at its index. + /// Each [`Stage`]'s histogram, at its index, and its spans summed. stages: [[AtomicU64; STAGE_BUCKETS]; 4], + stage_nanos: [AtomicU64; 4], event_holds: [AtomicU64; STAGE_BUCKETS], held_starts: AtomicU64, held_start_gap_nanos: AtomicU64, @@ -867,10 +868,11 @@ impl Counters { a.queue_lock_wait_max_nanos.fetch_max(nanos, Relaxed); } - /// A command buffer's span of `nanos` nanoseconds at `stage`, in its histogram - /// ([`Metrics::commit_to_scheduled`] and the three after it). + /// A command buffer's span of `nanos` nanoseconds at `stage`, in its histogram and its sum + /// ([`Metrics::commit_to_scheduled`] and the three after it, and their `_nanos` sums). pub(crate) fn stage(&self, stage: Stage, nanos: u64) { self.atomics.stages[stage as usize][stage_bucket(nanos)].fetch_add(1, Relaxed); + self.atomics.stage_nanos[stage as usize].fetch_add(nanos, Relaxed); } /// A segment the submit thread held `nanos` nanoseconds for an event's value @@ -1371,6 +1373,7 @@ impl Counters { (a.over_by_cause[cause as usize].each_ref()).map(|n| n.load(Relaxed)) }; let stage = |stage: Stage| (a.stages[stage as usize].each_ref()).map(|n| n.load(Relaxed)); + let stage_nanos = |stage: Stage| a.stage_nanos[stage as usize].load(Relaxed); Metrics { submissions: a.submissions.load(Relaxed), submit_infos: a.submit_infos.load(Relaxed), @@ -1382,9 +1385,13 @@ impl Counters { queue_lock_wait_nanos: a.queue_lock_wait_nanos.load(Relaxed), queue_lock_wait_max_nanos: a.queue_lock_wait_max_nanos.load(Relaxed), commit_to_scheduled: stage(Stage::CommitToScheduled), + commit_to_scheduled_nanos: stage_nanos(Stage::CommitToScheduled), scheduled_to_gpu_start: stage(Stage::ScheduledToGpuStart), + scheduled_to_gpu_start_nanos: stage_nanos(Stage::ScheduledToGpuStart), gpu_run: stage(Stage::GpuRun), + gpu_run_nanos: stage_nanos(Stage::GpuRun), gpu_end_to_handler: stage(Stage::GpuEndToHandler), + gpu_end_to_handler_nanos: stage_nanos(Stage::GpuEndToHandler), event_holds: (a.event_holds.each_ref()).map(|n| n.load(Relaxed)), held_starts: a.held_starts.load(Relaxed), held_start_gap_nanos: a.held_start_gap_nanos.load(Relaxed), @@ -1650,6 +1657,9 @@ pub struct Metrics { /// that presents a drawable, that call's return. Counted as each is scheduled; one that ends /// unscheduled counts none. pub commit_to_scheduled: [u64; STAGE_BUCKETS], + /// The spans [`commit_to_scheduled`](Self::commit_to_scheduled) counts, summed, in + /// nanoseconds. + pub commit_to_scheduled_nanos: u64, /// Command buffers that completed with GPU times by the span from their /// [`kernel_end_time`](crate::CommandBuffer::kernel_end_time) to their /// [`gpu_start_time`](crate::CommandBuffer::gpu_start_time), in the buckets of @@ -1658,12 +1668,17 @@ pub struct Metrics { /// completion thread as each retires, before its handlers run; one that ends with an error, /// or completes without GPU times, counts none here or in the two below. pub scheduled_to_gpu_start: [u64; STAGE_BUCKETS], + /// The spans [`scheduled_to_gpu_start`](Self::scheduled_to_gpu_start) counts, summed, in + /// nanoseconds. + pub scheduled_to_gpu_start_nanos: u64, /// The same command buffers by their GPU run: the span from their /// [`gpu_start_time`](crate::CommandBuffer::gpu_start_time) to their /// [`gpu_end_time`](crate::CommandBuffer::gpu_end_time), their two timestamps' own span, in /// the buckets of [`commit_to_scheduled`](Self::commit_to_scheduled); 0 for one with nothing /// for the GPU. pub gpu_run: [u64; STAGE_BUCKETS], + /// The spans [`gpu_run`](Self::gpu_run) counts, summed, in nanoseconds. + pub gpu_run_nanos: u64, /// The same command buffers by the span from their /// [`gpu_end_time`](crate::CommandBuffer::gpu_end_time) to the host time their handlers /// begin, whether they have any or not, in the buckets of @@ -1671,6 +1686,9 @@ pub struct Metrics { /// round's command buffers in order, so the span holds the earlier ones' retirements and /// handlers in the round. pub gpu_end_to_handler: [u64; STAGE_BUCKETS], + /// The spans [`gpu_end_to_handler`](Self::gpu_end_to_handler) counts, summed, in + /// nanoseconds. + pub gpu_end_to_handler_nanos: u64, /// Segments the submit thread held for an event's value that neither the host had set nor a /// signal submitted to the driver promised: a value the host sets later, or one a command /// buffer not yet submitted signals. A wait whose signal is submitted is not held: it goes to diff --git a/crates/metal2vulkan-runtime/src/tests/command.rs b/crates/metal2vulkan-runtime/src/tests/command.rs index 06154a668..cef6693b8 100644 --- a/crates/metal2vulkan-runtime/src/tests/command.rs +++ b/crates/metal2vulkan-runtime/src/tests/command.rs @@ -1954,8 +1954,10 @@ pub(crate) mod on_device { }); } - /// Each command buffer that completes lands one count in each of the four stage histograms: - /// three committed in turn, each finished before the next, add three to each histogram. + /// Each command buffer that completes lands one count in each of the four stage histograms, + /// and its span in each stage's sum: three committed in turn, each finished before the next, + /// add three to each histogram, and to the sums the spans their own times give (from its + /// commit, its kernel start, to its handlers' start, which lies before it is seen finished). #[test] fn every_device_counts_each_command_buffer_once_in_every_stage_histogram() { each_device("command_stage_histograms", |name, _, device| { @@ -1973,17 +1975,44 @@ pub(crate) mod on_device { ] .map(|histogram| histogram.iter().sum::()) }; - let before = sums(counters.metrics()); + let nanos = |m: crate::Metrics| { + [ + m.commit_to_scheduled_nanos, + m.scheduled_to_gpu_start_nanos, + m.gpu_run_nanos, + m.gpu_end_to_handler_nanos, + ] + }; + let before = counters.metrics(); + let mut spans = [0; 3]; + let mut handled_by = 0; for word in 1..=3 { let command_buffer = queue.command_buffer().expect("a command buffer"); fill(&command_buffer, &buffer, word); command_buffer.commit().expect("a commit"); finished(name, &command_buffer); assert_eq!(command_buffer.error(), None, "{name}"); + let c = &command_buffer; + let (start, end) = (c.gpu_start_time(), c.gpu_end_time()); + spans[0] += c.kernel_end_time() - c.kernel_start_time(); + spans[1] += start.saturating_sub(c.kernel_end_time()); + spans[2] += end - start; + handled_by += host_time() - end; } - let after = sums(counters.metrics()); - let added: Vec = after.iter().zip(before).map(|(a, b)| a - b).collect(); + let after = counters.metrics(); + let added: Vec = (sums(after).iter().zip(sums(before))) + .map(|(a, b)| a - b) + .collect(); assert_eq!(added, [3; 4], "{name}: each histogram's counts added"); + let added: Vec = (nanos(after).iter().zip(nanos(before))) + .map(|(a, b)| a - b) + .collect(); + assert_eq!(added[..3], spans, "{name}: the stages' sums added"); + assert!( + added[3] <= handled_by, + "{name}: GPU end to handlers {} past its bound {handled_by}", + added[3] + ); drop((buffer, arena, queue, device)); }); } diff --git a/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs b/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs index 30adc48cb..5d2ac0489 100644 --- a/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs +++ b/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs @@ -378,6 +378,38 @@ struct Function { /// A kernel apart from its specializations: the library object it came from and its name. type Kernel = (u64, Arc); +/// The runtime's four histograms of its command buffers' stages, in [`STAGES`]'s order, each in +/// its 23 buckets of powers of two (`rt::Metrics::commit_to_scheduled`). +type Stages = [[u64; 23]; 4]; + +/// The stage histograms' names, as `rt::Metrics` names them. +const STAGES: [&str; 4] = [ + "commit_to_scheduled", + "scheduled_to_gpu_start", + "gpu_run", + "gpu_end_to_handler", +]; + +/// The stage histograms of `metrics`. +fn stages(m: &rt::Metrics) -> Stages { + [ + m.commit_to_scheduled, + m.scheduled_to_gpu_start, + m.gpu_run, + m.gpu_end_to_handler, + ] +} + +/// A `stages AT NAME=C0,...,C22 ...` line of the report: each stage histogram's counts, bucket +/// by bucket. +fn stages_line(at: &str, stages: &Stages) -> String { + let named = STAGES.iter().zip(stages).map(|(name, counts)| { + let counts: Vec = counts.iter().map(u64::to_string).collect(); + format!(" {name}={}", counts.join(",")) + }); + format!("stages {at}{}", named.collect::()) +} + /// A compute pipeline state's making: its wall time, and whether its kernel was new to the play /// (no state of another specialization of it made before). struct Creation { @@ -528,6 +560,9 @@ pub struct NewRuntime { kernels: HashSet, /// Where each pipeline state's making went: the translator's, the driver's and the rest. makes: makes::Makes, + /// The runtime's stage histograms as each frame ended, read as the next frame's first call + /// is located (`Backend::locate`): the report's `stages` lines. + frame_stages: Vec, /// The device's `minImportedHostPointerAlignment`, where it imports host memory: the /// alignment of the host pages a no-copy buffer's memory is imported from (`imports`). host_alignment: Option, @@ -927,6 +962,7 @@ impl NewRuntime { creations: Vec::new(), kernels: HashSet::new(), makes: makes::Makes::default(), + frame_stages: Vec::new(), }) } @@ -2935,6 +2971,24 @@ impl Backend for NewRuntime { ("held_release_bytes", metrics.held_release_bytes), ("held_release_starts", metrics.held_release_starts), ("stamps_not_available", metrics.stamps_not_available), + ("untimed_command_buffers", metrics.untimed_command_buffers), + ( + "commit_to_scheduled_nanos", + metrics.commit_to_scheduled_nanos, + ), + ( + "scheduled_to_gpu_start_nanos", + metrics.scheduled_to_gpu_start_nanos, + ), + ("gpu_run_nanos", metrics.gpu_run_nanos), + ("gpu_end_to_handler_nanos", metrics.gpu_end_to_handler_nanos), + ("held_starts", metrics.held_starts), + ("held_start_gap_nanos", metrics.held_start_gap_nanos), + ("runtime_command_buffers", metrics.runtime_command_buffers), + ( + "runtime_command_buffer_gpu_nanos", + metrics.runtime_command_buffer_gpu_nanos, + ), ("waits_behind_counter", metrics.waits_behind_counter), ("external_acquires", metrics.external_acquires), ("external_releases", metrics.external_releases), @@ -3033,8 +3087,12 @@ impl Backend for NewRuntime { }); let mut lines: Vec = lines.collect(); // A maximum since the device was made: it does not sum, so it is not a frame's counter. - let longest = self.device.counters().metrics().commit_lock_wait_max_nanos; + let metrics = self.device.counters().metrics(); + let longest = metrics.commit_lock_wait_max_nanos; lines.push(format!("commit lock wait longest {longest} ns")); + let ended = self.frame_stages.iter().enumerate(); + lines.extend(ended.map(|(frame, stages)| stages_line(&frame.to_string(), stages))); + lines.push(stages_line("end", &stages(&metrics))); lines.extend(self.makes.lines()); if let Some(copies) = self.managed { let from = match self.identity { @@ -3131,6 +3189,11 @@ impl Backend for NewRuntime { fn locate(&mut self, frame: u64, call: u64) { self.at = (frame, call); + // A frame's first call: the frames before it have ended. + while (self.frame_stages.len() as u64) < frame { + let metrics = self.device.counters().metrics(); + self.frame_stages.push(stages(&metrics)); + } } fn announced_bytes_recorded(&mut self) { diff --git a/crates/metal2vulkan-validation/src/replay/player.rs b/crates/metal2vulkan-validation/src/replay/player.rs index 4354f13cf..952091198 100644 --- a/crates/metal2vulkan-validation/src/replay/player.rs +++ b/crates/metal2vulkan-validation/src/replay/player.rs @@ -524,6 +524,11 @@ pub struct Times { pub upload: u64, /// Reading the runtime's counters (`Backend::counters`). pub count: u64, + /// The command buffers the frame waited for that completed with no GPU interval + /// (`Backend::gpu_interval`) or one of no length, which `gpu_busy` cannot hold, and the part + /// of `wait` spent waiting for them. + pub untimed_waits: u64, + pub untimed_wait: u64, /// The union of the GPU intervals of the command buffers the frame waited for /// (`Backend::gpu_interval`); 0 where the backend gives none. pub gpu_busy: u64, @@ -722,7 +727,8 @@ impl Report { lines.push(format!( "end {at} wall_nanos={} unix_nanos={}{resident} times stream={} write={} read={} wait={} \ resource={} resource_max={} pipeline={} pipeline_max={} other={} upload={} \ - count={} player={} gpu_busy={} gpu_longest={} gpu_longest_cb={} live{live}", + count={} player={} untimed_waits={} untimed_wait={} gpu_busy={} gpu_longest={} \ + gpu_longest_cb={} live{live}", end.wall_nanos, end.unix_nanos, t.stream, @@ -737,6 +743,8 @@ impl Report { t.upload, t.count, t.player(end.wall_nanos), + t.untimed_waits, + t.untimed_wait, t.gpu_busy, t.gpu_longest, t.gpu_longest_cb, @@ -829,6 +837,14 @@ impl Report { relaid.heaps, relaid.moved, relaid.grown )); } + let times = self.ends.iter().map(|end| end.times); + let (untimed, untimed_wait, wait) = times.fold((0, 0, 0), |(n, u, w), t| { + (n + t.untimed_waits, u + t.untimed_wait, w + t.wait) + }); + lines.push(format!( + "untimed waits {untimed}: command buffers waited for with no GPU interval, \ + {untimed_wait} ns of the frames' {wait} ns of waits" + )); lines.push(self.texture_writes.line()); lines.push(self.managed_reads.line()); lines.push(format!("total{}", counted(&self.total))); @@ -2188,8 +2204,10 @@ impl<'b, B: Backend> Player<'b, B> { for id in &ready { let began = std::time::Instant::now(); self.backend.wait(*id)?; - self.times.wait += since(began); - if let Some(interval) = self.backend.gpu_interval(*id) { + let waited = since(began); + self.times.wait += waited; + let interval = self.backend.gpu_interval(*id); + if let Some(interval) = interval { let nanos = interval.1.saturating_sub(interval.0); if nanos > self.times.gpu_longest { self.times.gpu_longest = nanos; @@ -2197,6 +2215,10 @@ impl<'b, B: Backend> Player<'b, B> { } self.intervals.push(interval); } + if interval.is_none_or(|(start, end)| end <= start) { + self.times.untimed_waits += 1; + self.times.untimed_wait += waited; + } let pending = self.pending.remove(id).expect("a pending command buffer"); for (event, value) in pending.signals { let known = self.events.entry(event).or_default(); diff --git a/crates/metal2vulkan-validation/src/replay/rt_replay.rs b/crates/metal2vulkan-validation/src/replay/rt_replay.rs index 58c79b098..90f121e64 100644 --- a/crates/metal2vulkan-validation/src/replay/rt_replay.rs +++ b/crates/metal2vulkan-validation/src/replay/rt_replay.rs @@ -447,6 +447,66 @@ fn a_draw_into_a_pass_plays_on_the_new_runtime() { assert_eq!(report.first_skip, None); } +/// A play's report carries the runtime's stage sums among its executed counters, and its stage +/// histograms as each frame ended and at the play's end: two frames of one fill each count one +/// command buffer more in each histogram by each frame's end. +#[test] +fn a_play_reports_the_runtime_s_command_buffer_stages() { + let dir = ScratchDir::new("rt-replay-stages").unwrap(); + let path = written(&dir, |w| { + w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?; + w.call("newCommandQueue", 1, 2, &[], &[])?; + let made = [Value::Uint(4), Value::Uint(0)]; + w.call("newBufferWithLength:options:", 1, 3, &made, &[])?; + let range = uints(&[("location", 0), ("length", 4)]); + for (cb, value) in [(10, 7), (20, 9)] { + w.call("commandBuffer", 2, cb, &[], &[])?; + w.call("blitCommandEncoder", cb, cb + 1, &[], &[])?; + let fill = [Value::Object(3), range.clone(), Value::Uint(value)]; + w.call("fillBuffer:range:value:", cb + 1, 0, &fill, &[])?; + w.call("endEncoding", cb + 1, 0, &[], &[])?; + w.call("commit", cb, 0, &[], &[])?; + w.call("m2v.present", 1, 0, &[Value::Nil], &[])?; + } + Ok(()) + }); + let (report, lines) = play("stages", &path); + let executed = &report.total.executed; + let sums = [ + "commit_to_scheduled_nanos", + "scheduled_to_gpu_start_nanos", + "gpu_run_nanos", + "gpu_end_to_handler_nanos", + "held_starts", + "held_start_gap_nanos", + "runtime_command_buffers", + "runtime_command_buffer_gpu_nanos", + "untimed_command_buffers", + ]; + for key in sums { + assert!(executed.contains_key(key), "{key}: {executed:?}"); + } + let counted = |at: &str| -> Vec { + let prefix = format!("stages {at} "); + let line = lines.iter().find(|line| line.starts_with(&prefix)); + let line = line.unwrap_or_else(|| panic!("no stages {at} line: {lines:?}")); + let histograms = line[prefix.len()..].split(' ').map(|named| { + let (_, counts) = named.split_once('=').expect("a histogram"); + let counts: Vec = counts.split(',').map(|c| c.parse().unwrap()).collect(); + assert_eq!(counts.len(), 23, "{line}"); + counts.iter().sum::() + }); + histograms.collect() + }; + // Frame 0's line, then the play's end, which frame 1 ended. + let (first, end) = (counted("0"), counted("end")); + assert_eq!(first.len(), 4, "{lines:?}"); + for (at, (first, end)) in first.iter().zip(&end).enumerate() { + assert!(*first >= 1, "{at}: {lines:?}"); + assert!(*end > *first, "{at}: {lines:?}"); + } +} + /// A draw of points after the triangle (call 19) plays, nothing skipped, the target still green. #[test] fn a_draw_of_points_plays_on_the_new_runtime() { diff --git a/crates/metal2vulkan-validation/src/replay/tests.rs b/crates/metal2vulkan-validation/src/replay/tests.rs index ba3cb15f1..266ce2600 100644 --- a/crates/metal2vulkan-validation/src/replay/tests.rs +++ b/crates/metal2vulkan-validation/src/replay/tests.rs @@ -2132,6 +2132,45 @@ fn a_frame_end_names_its_longest_command_buffer() { ); } +/// A frame's end counts the command buffers it waited for that completed with no GPU interval, +/// or one of no length (#4), and the wait spent on them, which its GPU busy time leaves out; the +/// report sums them. +#[test] +fn a_frame_end_counts_its_waits_for_untimed_command_buffers() { + let mut kept = Kept { + gpu: HashMap::from([(3, (100, 300)), (4, (500, 500))]), + ..Kept::default() + }; + let (report, ended) = played(&mut kept, |w| { + w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?; + w.call("newCommandQueue", 1, 2, &[], &[])?; + for command_buffer in [3, 4, 5] { + w.call("commandBuffer", 2, command_buffer, &[], &[])?; + w.call("commit", command_buffer, 0, &[], &[])?; + } + w.call("m2v.present", 1, 0, &[Value::Nil], &[])?; + w.call("commandBuffer", 2, 6, &[], &[])?; + w.call("commit", 6, 0, &[], &[])?; + w.call("m2v.present", 1, 0, &[Value::Nil], &[])?; + Ok(()) + }); + ended.unwrap(); + let untimed: Vec<_> = (report.ends.iter()) + .map(|end| (end.times.untimed_waits, end.times.gpu_busy)) + .collect(); + assert_eq!(untimed, [(2, 200), (1, 0)]); + for end in &report.ends { + assert!(end.times.untimed_wait <= end.times.wait, "{end:?}"); + } + let lines = report.lines(); + let line = lines.iter().find(|line| line.starts_with("end 0 ")); + let line = line.expect("an end line"); + assert!(line.contains(" untimed_waits=2 untimed_wait="), "{line}"); + let total = lines.iter().find(|line| line.starts_with("untimed waits ")); + let total = total.expect("the untimed waits line"); + assert!(total.starts_with("untimed waits 3: "), "{total}"); +} + /// A dispatch an `m2v.privateBytes` record names plays as the program made it, and the report /// counts it. #[test] diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 07adcd122..ffd0e48b4 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -1582,6 +1582,7 @@ field metal2vulkan-runtime::Metrics.cache_writes_dropped pub cache_writes_droppe field metal2vulkan-runtime::Metrics.commit_lock_wait_max_nanos pub commit_lock_wait_max_nanos: u64 field metal2vulkan-runtime::Metrics.commit_lock_wait_nanos pub commit_lock_wait_nanos: u64 field metal2vulkan-runtime::Metrics.commit_to_scheduled pub commit_to_scheduled: [u64; STAGE_BUCKETS] +field metal2vulkan-runtime::Metrics.commit_to_scheduled_nanos pub commit_to_scheduled_nanos: u64 field metal2vulkan-runtime::Metrics.consumer_allocation_max_nanos pub consumer_allocation_max_nanos: u64 field metal2vulkan-runtime::Metrics.consumer_allocation_nanos pub consumer_allocation_nanos: u64 field metal2vulkan-runtime::Metrics.consumer_allocations pub consumer_allocations: u64 @@ -1607,7 +1608,9 @@ field metal2vulkan-runtime::Metrics.first_use_wait_max_nanos pub first_use_wait_ field metal2vulkan-runtime::Metrics.first_use_wait_nanos pub first_use_wait_nanos: u64 field metal2vulkan-runtime::Metrics.first_use_waits pub first_use_waits: u64 field metal2vulkan-runtime::Metrics.gpu_end_to_handler pub gpu_end_to_handler: [u64; STAGE_BUCKETS] +field metal2vulkan-runtime::Metrics.gpu_end_to_handler_nanos pub gpu_end_to_handler_nanos: u64 field metal2vulkan-runtime::Metrics.gpu_run pub gpu_run: [u64; STAGE_BUCKETS] +field metal2vulkan-runtime::Metrics.gpu_run_nanos pub gpu_run_nanos: u64 field metal2vulkan-runtime::Metrics.held_release_bytes pub held_release_bytes: u64 field metal2vulkan-runtime::Metrics.held_release_starts pub held_release_starts: u64 field metal2vulkan-runtime::Metrics.held_releases pub held_releases: u64 @@ -1677,6 +1680,7 @@ field metal2vulkan-runtime::Metrics.runtime_command_buffer_gpu_nanos pub runtime field metal2vulkan-runtime::Metrics.runtime_command_buffers pub runtime_command_buffers: u64 field metal2vulkan-runtime::Metrics.sampler_element_writes pub sampler_element_writes: u64 field metal2vulkan-runtime::Metrics.scheduled_to_gpu_start pub scheduled_to_gpu_start: [u64; STAGE_BUCKETS] +field metal2vulkan-runtime::Metrics.scheduled_to_gpu_start_nanos pub scheduled_to_gpu_start_nanos: u64 field metal2vulkan-runtime::Metrics.shared_long_reuses pub shared_long_reuses: u64 field metal2vulkan-runtime::Metrics.shared_remade_after_frees pub shared_remade_after_frees: u64 field metal2vulkan-runtime::Metrics.shared_take_allocations pub shared_take_allocations: SiteAllocations diff --git a/docs/REPLAY-STREAM.md b/docs/REPLAY-STREAM.md index 116e6ae77..aeb816d5d 100644 --- a/docs/REPLAY-STREAM.md +++ b/docs/REPLAY-STREAM.md @@ -921,7 +921,10 @@ make or release a buffer, texture, heap or block and `resource_max` the longest longest of them, `other` every other call the runtime ran, `upload` the host's copies from the guest's RAM, which a backend stages and copies (the recording's plumbing, the player's share), `count` reading the runtime's -counters, and `player` what of the wall time is left, the player's own work; then `gpu_busy`, the +counters, and `player` what of the wall time is left, the player's own work; then +`untimed_waits` and `untimed_wait`, the command buffers the frame waited for that completed with +no GPU interval or one of no length (the runtime's start 0, or its end not past its start), which +`gpu_busy` cannot hold, and the nanoseconds of `wait` spent on them; then `gpu_busy`, the union of the GPU intervals of the command buffers the frame waited for, where the runtime gives them, which runs beside the rest, then `gpu_longest` and `gpu_longest_cb`, the longest of those intervals, one command buffer's, and that command buffer's stream id (the first of equal ones; 0 @@ -963,7 +966,8 @@ not compared, and the textures' own checks carry the bytes. `unsnapshotted N` wh `m2v.privateBytes` records name dispatches (`N` of them, each played as it is), `parted N` where a recorded range met a live one in part (`N` the older ranges ended), `relaid HEAPS moved OFFSETS grown BYTES` where it laid placement heaps out again (the heaps, the -offsets it moved in them and the bytes it added to their sizes), `texture_writes ...` (the +offsets it moved in them and the bytes it added to their sizes), `untimed waits N: ...` (the +frames' `untimed_waits` and `untimed_wait` summed, beside their `wait`), `texture_writes ...` (the CPU's writes into Managed textures, above), `managed reads on two copies: ...` (the reads of Managed bytes no announcement took to the GPU copy, above), `total COUNTS` (its `calls` the calls played: where @@ -973,6 +977,15 @@ making's wall time, and whether no state of another specialization of the kernel function by name, was made before), its `commit lock wait longest N ns` (the runtime's `commit_lock_wait_max_nanos`: the longest wait of a commit for the runtime's work lock in the play; the executed counter `commit_lock_wait_nanos` gives the waits by frame, summed), its +`stages F commit_to_scheduled=C0,...,C22 scheduled_to_gpu_start=... gpu_run=... +gpu_end_to_handler=...` for each frame `F` a later call followed and `stages end ...` at the play's +end (the runtime's four histograms of its command buffers' stages, `Metrics::commit_to_scheduled` +and the three after it, bucket by bucket, as they stood then, since the device was made: a span's +histogram is the difference of two lines; the executed counters `commit_to_scheduled_nanos` and +the three like it sum each stage's spans, `held_starts` and `held_start_gap_nanos` count the +groups a queue held behind three submissions in flight and the GPU's time behind them, and +`runtime_command_buffers` and `runtime_command_buffer_gpu_nanos` the runtime's own uploads and +copy-ins and their GPU time, outside every Metal command buffer's GPU interval), its `pipeline makes N states: C new (MADE), SPLIT; H held, SPLIT; B beside a pre-pass call, whose work their figures count` and, for each of the ten slowest makings, slowest first, `pipeline make slowest K #ID KINDS new|held (MADE): SPLIT` (where each render and compute pipeline state's making