From 6eb83eabff032ecd90fa6bc9be2cae6f6d297ba4 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 19 Nov 2026 08:12:06 -0800 Subject: [PATCH] rt README: a command buffer is scheduled once the one submit thread's earlier calls return, whatever their queue; the Iris Xe's figures The known gaps of queues gain the rule behind the running-signal case's declaration. Every queue's command buffers go to the device's one VkQueue, which takes one vkQueueSubmit2 call at a time, since Vulkan requires a queue's host access to be externally synchronized. The device's one submit thread makes every call (submit.rs has one call site, reached only from the thread's pass), and it schedules a command buffer once its earlier calls have returned, whichever queue they were for. So one long driver call delays every queue's scheduling by its length. The API.md accepted difference the declaration cites now states the same ground. Measured on an Iris Xe (RPL-P, ANV): - m3-max-52564: the device's first submission, 192 fills of a new 256 MiB block, spent 27-30 ms in vkQueueSubmit2. The other queue's waiter was scheduled 0.02 ms after that call returned, in 3 of 3 runs. - m3-max-52745, the separating run with the probe's block size as a scratch switch, never committed: the first call took 2.1 and 2.5 ms with 1 MiB, 9.1 ms with 64 MiB and 28.4 ms with 256 MiB. Its time grows with the new block the submission first uses. The probe's later submissions took at most 0.18 ms. - In the same job, the 256 MiB run (the case's own shape) read Committed and the case's declaration fired at both MTLEvent sites, verdict 'announced'. --- crates/metal2vulkan-rt/README.md | 14 ++++++++++++++ docs/API.md | 13 +++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index e8d0d1c32..3eb03cf59 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -1242,6 +1242,20 @@ on both cards, which says nothing of a device that ran work. (15 ms at the 90th). The last command buffer's own report is not late: on the 2080 it came 97.2-97.5 ms after its commit, where the old runtime's came 94.9-96.4 ms after. The harness prints each command buffer's lateness, from its `gpu_end_time` to its completed handler (`late_us`). +- Every queue's command buffers go to the device's one `VkQueue`, which takes one + `vkQueueSubmit2` call at a time (Vulkan requires a queue's host access to be externally + synchronized), all of them made by the device's one submit thread. A command buffer is + scheduled (its status, its scheduled handlers, `wait_until_scheduled`) by that thread once its + earlier calls have returned, whichever queue they were for, so one long driver call delays + every queue's scheduling by its length. Metal promises no time between a command buffer's + dependencies resolving and its scheduling. Measured on an Iris Xe (RPL-P, Mesa's ANV, job + m3-max-52564): the device's first submission, one command buffer filling a new 256 MiB block + 192 times, spent 27 to 30 ms in the call, and another queue's command buffer whose wait that + submission's signal met, committed 0.05 ms after it, was scheduled 0.02 ms after the call + returned, where an Apple M3 Max schedules it while the signalling command buffer still runs. + The call's time grows with the new block it is the first to use: 2.1 and 2.5 ms with a 1 MiB + block, 9.1 ms with 64 MiB and 28.4 ms with 256 MiB (job m3-max-52745); the probe's later + submissions spent at most 0.18 ms each. - On NVIDIA, short command buffers committed back to back reach the GPU in more submissions than the old runtime made of them, and such a burst runs behind it. The cost is NVIDIA's latency per submission: the runtime submits sooner, each command buffer as soon as it can. On an RTX 2080 diff --git a/docs/API.md b/docs/API.md index 3fddd04c8..e51a15088 100644 --- a/docs/API.md +++ b/docs/API.md @@ -6631,12 +6631,13 @@ each item named states the rule in full. (`metal2vulkan-rt`'s `CommandBuffer::status`, `add_scheduled_handler` and `wait_until_scheduled`). Apple defines `MTLCommandBufferStatusScheduled` as "All dependencies have been resolved and the command buffer has been scheduled for execution", and promises no - time between the two. The new runtime schedules each command buffer on the device's one submit - thread, once that thread's earlier `vkQueueSubmit2` calls have returned, whichever queue they - were for (the runtime's README, the known gaps of queues). So a command buffer whose wait an - earlier submission's signal meets stays `Committed`, its scheduled handlers not run, for as long - as that submission's driver call lasts, where an Apple M3 Max had scheduled it while the - signalling command buffer still ran. + time between the two. Every queue's command buffers go to the device's one `VkQueue`, which + takes one `vkQueueSubmit2` call at a time, all made by the device's one submit thread, and the + new runtime schedules each command buffer there once that thread's earlier calls have returned, + whichever queue they were for (the runtime's README, the known gaps of queues). So a command + buffer whose wait an earlier submission's signal meets stays `Committed`, its scheduled + handlers not run, for as long as that submission's driver call lasts, where an Apple M3 Max had + scheduled it while the signalling command buffer still ran. **Process exit**