Files
metal2vulkan/docs
Anees Iqbal a9f42dd2f9 RUNTIME 2496: Scheduler: a committing thread leaves a VkQueue's batches to the scheduler's thread where its submit calls are slow
What: each VkQueue keeps the time of its last 15 batch vkQueueSubmit calls, whichever thread made
them, timed under the queue's lock in submit_logged (device/submit_calls.rs), and publishes their
floor, the least of them. Where that floor is 100 us or more, a committing thread's pass
(commit_and_submit) leaves the VkQueue's batches to the scheduler's thread, which it wakes at once
through the existing left_over wake, counted as LeftAtCommit::SlowCalls
(WorkCounts::scheduler_at_commit_left_slow_calls, new). Below it the committing thread submits as
since RUNTIME 2461. A thread about to wait for a command buffer still submits for itself whatever
the cost. No batch is reported as left for a host step with none due.

Why: a REGRESSION of RUNTIME 2461, which let a committing thread submit a batch that holds segments
with no host step due. On a host of unified memory every guest batch names host imports, and RADV
lists every import in each kernel submission, so on the Radeon 780M each such call took about 245 us
(p50; 394 p90), now on the guest's committing thread: the consumer measured the walk per render
encoder 84.0 -> 130.9 us and the commit call per part 19 -> 256 us, with 2461's one plain() line
undone matching the parent on every row. The cost is the driver's and the kernel's, so the decision
reads the measured call time, not a driver, GPU or memory kind. The floor rather than the median:
in m3-max-38258 a fresh lavapipe device's first calls held the median of 15 past 100 us for 14 of
200 commits while its calls then took 5.3 us at the median; load and a driver's rare long calls
lengthen calls and never shorten them, as the submission checks' floors already assume
(submit_check.rs), and the import tax this rule is for is paid by every call. Of the guest's
~290 us per inline part, ours before the call is ~43 us (~15%, the consumer's trace).

Tests: commit_and_submit::a_queue_whose_calls_are_slow_leaves_its_batches_to_the_scheduler_s_thread
(each batch call made 150 us slower through a cfg(test) hook, Device::slow_submit_calls: 0 of 40
batches at commit, 40 left for slow calls, floor 207.8 us; without the rule every batch goes at
commit); a_command_buffer_naming_host_pages_is_submitted_at_its_commit warms 15 rounds and asserts
the floor below the bound and nothing left for slow calls (200/200 at commit, floor 2.6-3.1 us).
The guest-shaped bench's SubmitCost leg puts its 250 us stand-in inside the timed call, with two
legs of the other forms (SubmitCostAtCommit, HostPagesHandedOff); on lavapipe release
(m3-max-38261) the hand-off cut the commit call 65.5 -> 8.2 us with commit -> GPU start p50 4089
against 4086 us, and a forced hand-off of the 0.4 us host-pages calls showed no start latency
(2598 against 2606 us).

Docs: scheduler module docs and plain_ready, unshared_hold.rs, commit_and_submit's doc, the runtime
README, RUNTIME-PORTING.md, FAST-PATHS.md's unshared-hold paragraph; api_signatures blessed.

Verified (msi, at f0a34f5d9b): m3-max-38277 clippy 0, lavapipe scheduler/queue/turns suites 101/102
and validation joined_completions|grouped_submissions 19/20 (the two failures fail at the base
b874899768 too, m3-max-38299: grouped_submissions::completions_wake_the_scheduler_only_once_a_head_
may_go 3/3 at both; submission_turns::a_committing_pass_ends_at_its_own_submission_handlers_grouped
1/3 at base alone); m3-max-38302 clippy --cfg m2v_gpu 0, --cfg m2v_cpu_icd 0, rustdoc 0. The 780M
before/after (m3-max-38281) and the Iris run after the merge.
2026-11-16 16:53:53 -08:00
..