Files
metal2vulkan/crates/metal2vulkan-runtime/src/command_buffer
Anees Iqbal d62ca65f36 RUNTIME 2328: Scheduled behind a host step waiting at its gate
A command buffer whose remaining batches wait only for its queue's host
step behind work already submitted now reads Scheduled at once, as Metal's
does once its dependencies are resolved, instead of with its last batch
once that work ended (50-90 ms late behind an 89 ms pass on an RTX 3090).

The precedent is hang.rs, whose thread makes the command buffers committed
behind a GPU hang Scheduled early (Scheduling::Behind). The scheduler now
does the same at a look that finds a line's head waiting at its gate
(schedule_behind_steps). It walks the line from the head
(Order::leading_mut), and each batch must wait for nothing else: the head
for its step alone; each later one for no host step, check, decode, rebind
or binary semaphore, with its event values reached, and committed after no
other line's batch. At each command buffer's last batch it calls
CommandBufferShared::schedule_early:
- hang_scheduling becomes Scheduling::Early;
- the kernel end is set now, and the start where no batch began;
- the transition is posted;
- the submission handlers run in that pass's turn.

Not made early: one whose queue has a hang in flight or holding, one with
a storage-form switch riding on it, one already failed, and nothing at all
while a group holds a storage-form command buffer's last batch. Batches
submitted later leave the submitting flag as the early pass set it
(hang::scheduled_early). WorkCounts::scheduled_behind_host_steps counts
these command buffers. It is reported, never gated, in the conformance
cost (a LOOKS count).

held_step_order's (b) test used the long command buffer's kernel end as
the pass's submission time, and that end is now early. It reads the long
work's GPU end instead.

New test command_buffers_behind_a_waiting_step_read_scheduled: the long
command buffer, and a follower with a submission handler on its queue,
read Scheduled within 10 ms of commit while the step waits. The handler
runs first, the counter moves by 2, and the follower's times stay in
life order.

Proof (m3-max-30907, lavapipe): command_buffers_behind_a_waiting_step_read_scheduled passes; 249/250 touched tests
(the one failure is scheduler_wakes under the test queue limits of 58de9ba9a1, not this change). Negative control
(m3-max-30908, schedule_behind_steps disabled): the long one reads Scheduled 118-162 ms after commit and the new test fails.
2026-11-14 19:01:45 -08:00
..