Files
metal2vulkan/crates
Anees Iqbal 8bc4fef06d Show a command buffer's kernel start only once its end is known
The scheduler stored a command buffer's kernel start as it began submitting
the first batch and the end as it finished the last, each in its own atomic,
so `kernel_start_time` answered a start while `kernel_end_time` still answered
0 for as long as the submission took. Metal never shows that: a Swift probe on
the M3 Max under macOS 27.0.1 read each command buffer's pair 7 to 8.5 million
times while it was committed and always saw both or neither.

`KernelTimes::start`, which `kernel_start_time` reads, now answers 0 until
the end is stored: it loads the end first (acquire) and the start only where
the end is set. The start is stored before the end on every path (the first
batch's taking, a hang's early scheduling), so a start shown means a later
read of the end sees it, and an end seen means the start shows, in either
order of the two reads. The cost is one more atomic load per
`kernel_start_time`. The scheduler's own reads of the start (whether to begin,
a hang's recovery window, the GPU times' life check) take the stored value
through the new `KernelTimes::began`.

Test: `tests::gpu_time::a_kernel_start_shows_with_its_end_alone` checks that
after `begin` and before `end_at` the start reads 0 while `began` has it, and
that once the end is stored both reads, in either order, see both. The
branch report carries its runs and its negative control (the start read
raw, as before: the test fails).

(cherry picked from commit 86701a2e00b0518e7eac3beb4740222edd3982bf)
2026-11-05 07:39:33 -08:00
..