On ANV over i915 every kernel submission lists every VkDeviceMemory of the device, at a cost per
object; the consumer's guest drag on the Iris Xe had 302 entries per execbuffer (260 of them host
imports) at 112 to 128 execbuffers a frame. The runtime now makes fewer kernel submissions and
fewer command buffers per frame, under two new runtime policies.
What changes:
- DevicePolicy::completion, CompletionPolicy { Grouped (default), Exact }; exact_answers()
selects Exact. Under Grouped, on a driver whose queue merges consecutive submits (Mesa's common
queue: ANV, RADV, lavapipe, NVK and the rest), the scheduler holds ready batches of one VkQueue
and submits up to four in one vkQueueSubmit, only the last signalling, so Mesa merges them into
one kernel submission:
- a batch whose only signals are events' joins, the group's end signalling each event to the
highest index held; a batch waiting for a signal the group holds sends the group first;
- only a group's first member may wait for anything not yet seen complete, since Mesa gathers
every member's waits before the first member's commands; a later waiter goes alone after the
group in the same call. Metal never holds one command buffer back for another's wait;
- batches that cannot join (first work, binary semaphores, fences, sparse updates, wrapped
images, storage-form switches) submit the held group first;
- a pass that finds nothing ready keeps the group held while two or more earlier submissions of
its queue are not seen complete, gated on the second-to-last, so commits arriving meanwhile
join. It goes once full, when a head waits for the GPU, or when a thread waits for one of its
command buffers;
- a held batch that ends its command buffer turns Scheduled, takes its kernel end time and runs
its submission handlers as it is held, so waitUntilScheduled returns at once, as Metal
schedules a command buffer committed behind running work within 0.2 ms;
- submission checks run ahead for up to three batches behind a line's head, so checked command
buffers are found ready together; a failed group restores its waits, signals its last value
and fails each member once; the group's submission allocates nothing.
New degradation kind grouped-completion (Precision), announced once per device: a group's
members but the last are seen complete late, by at most three later batches' GPU time plus one
completion turn, and intermediate event values are seen late, never wrong.
- An event-signalling batch's end goes into its work's last command buffer, as every other batch's,
unless its signal must wait for another queue's earlier signal.
- DevicePolicy::batch_order, BatchOrderPolicy { Ends (default), Exact }; exact_answers() selects
Exact. On ANV, RADV and NVIDIA's driver, measured to run a queue's submissions one after another,
each batch ends with a barrier to every later command of its queue, the tracker takes an earlier
batch of that queue as ordered (no barrier per dependency), and a batch's start timestamp with
nothing planned before it is written at the bottom of the pipe. Other drivers and Exact keep the
barriers per dependency.
- WorkCounts: grouped_submissions, batches_grouped, group_ends_full / _wait / _apart /
_first_work / _drained / _checks / _held, event_waits_met, batches_with_none_pending and kin by
pending depth, groups_kept_pending and groups_sent_for_waits; frame_costs prints them, with
kernel submissions and ioctl time where the i915 execbuffer script is loaded, and gains guest-
shaped legs over 260 and 520 host imports.
- Docs: FAST-PATHS rows for both policies (the grouping row with the guest's frame rates), API.md
entries, add_submission_handler's doc, the runtime README and the scheduler modules' docs.
Why: each fewer kernel submission saves the scheduler thread an ioctl of about 80 to 130 us there,
and each barrier per dependency buys nothing on drivers that run a queue's submissions in order.
The bound of four was kept: eight measured about three fewer submissions a frame for twice the
completion lateness and no frame-time change.
Verified:
- Iris Xe, guest shape over 520 host imports, Grouped against Exact: 26.2-26.7 execbuffers a frame
against 67.0, ioctl 2.77-2.81 against 6.89-6.96 ms, scheduler 52-53 against 122-123 us per
command buffer, through completion 5.98 against 8.70 ms a frame.
- UHD 770, the held group at a 1 ms commit pace: 25.0 kernel submissions a frame against 58.1,
scheduler 67-82 against 113-124 us per command buffer, the same frame time and GPU idle;
completion seen 1.82-1.86 ms after GPU end against 0.43-0.46 ms.
- In the guest on the Iris Xe, Grouped made 24.4-27.5 kernel submissions a frame against Exact's
42.4-43.8 and saved 0.4-1.7 ms of scheduler CPU a frame; the frame rate was alike within
boot-to-boot noise (15.7-17.3 against 16.4-17.6 fps).
- runtime_lane::grouped_submissions (held signals on one and two queues, waiters leading, groups
held behind running work with and without submission handlers and checks, both policies, the
validation layer silent): 19 of 19 on ANV and lavapipe; the held-handler case fails without its
change. commit_work, gpu_times, grouped_submissions, queue_order, events and first-use lanes 77 of
77 on the Radeon 780M, RX 7900 XTX and RTX 5080; under synchronization validation 34 of 34 on
the UHD 770. The runtime's device tests 1066 of 1066 on ANV; the unit suites 4534 of 4534.
- clippy -D warnings (plain, m2v_gpu, m2v_cpu_icd) and rustdoc.