Mark a queue long by its command buffer's own GPU time, not the host's view of its head's age
What: a command queue is now marked long where one of its command buffers' own timestamps (its first batch's start to its last's end) span over LONG_HEAD (2 ms), in the completion turn that read them (CommandBufferShared::place_gpu_times), before the turn finishes it. The waiter's host-age check in command_buffer/completion.rs (HeadWatch, Device::head_watch) is removed, and went_long returns at once unless the device shares. A device whose command buffers write no timestamps the host reads (gpu_times_from_host, a driver whose timestamps wait for every queue's, or no calibrated timestamps) no longer shares: queue_switch_check::timed() gates the check, and recall settles Unchecked and counts the new WorkCounts::queue_sharing_untimed where the device has two VkQueues of one family to share. Two runtime extensions, doc-hidden, for the lanes and the probe: CommandQueue::vk_queue_sharing() (its VkQueue and long mark) and Device::shares_vk_queues(). Why: the host's view of a batch's age as its VkQueue's oldest also holds its wait for the GPU to start it and the waiter's lateness to see it complete, so short command buffers marked their queues long for good. On the RTX 5080 Laptop GPU, 2x3 runs in a slow stretch had each thread's queue marked long mid-run (at 20 ms to 1,238 ms) and settled apart, the PerQueue placement, at PerQueue's rates. Measured cause, with a diagnostic build printing each host-age mark beside the command buffer's own GPU span: beside another process's 30 ms command buffers, draws of 11 and 16 us of GPU time were seen 2.0 and 2.3 ms after they became their VkQueue's oldest, 1.8 and 2.1 ms of that before they started; that run's thread queue settled apart and ran at PerQueue's 4.1k. In the runs without contention, every true mark had a GPU span within 1.2 ms of its host age (the 30 ms command buffers and the probe's 2.7 ms sizing one); under contention the sizing command buffer's host age exceeded its span by 4.2 ms. Neither suggested alternative fits: the false marks came mid-run, not only in a queue's first command buffers, and decaying the mark after short heads would let the trap and alternating shapes' long queues rejoin and stall the compositor again. Tests: tests::queue_share_device gains a_device_that_answers_gpu_times_from_the_host_does_not_ share_and_counts_it (expected, not run, to fail without the gate on the 5080: there it printed "Unchecked ... could share: true", so the recorded Idles verdict would make it share), and asserts queue_sharing_untimed == 0 elsewhere; its isolation runs print each queue's VkQueue and mark over the run. The queues lane's a_queue_joining_another_s_busy_vk_queue_is_announced_once now makes its device under QueueSharingPolicy::Adaptive (over the lane's exact_answers()), lets the busy queue's fills be submitted first, and asserts queue_joins > 0 exactly where the device shares, saying why where it does not. cross_queue_shadows gains the signal-in-between and the waiting-writer cases on one VkQueue: no spin, Adaptive, the check settled, queue 2 joining queue 1's busy VkQueue; they assert the join, neither queue long, the hold still withheld while the waiting writer has not completed, and the bytes. Docs: QueueSharingPolicy::Adaptive, the FAST-PATHS row (the rule, the untimed exclusion, the new ranges), docs/API.md (the policy section and the notice), the queue-sharing notice's cost text, queue.rs and queue_share.rs; api_signatures blessed (additions only). Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, msi, under gpu-locks, no VM), release probe: - 2 threads x 3 in flight, 10 runs each in turn: Adaptive 48.3, 28.0, 50.7, 52.9, 28.1, 53.7, 48.6, 29.9, 31.5, 53.0k against PerQueue 21.4, 24.9, 27.8, 28.0, 27.6, 27.4, 27.1, 23.3, 26.9, 27.3k, Adaptive above PerQueue in each pair; no thread's queue marked long in any run (gone long 1 each: the probe's sizing queue). The 28-31k runs keep the shared placement, with waiter parks 0.23 against 0.02-0.05 per command buffer in the fast ones: a host-side mode, not a move. - Beside another process's 30 ms command buffers, 3 runs each: the old rule 4.1k (a thread's queue marked long by its host age), 5.2k, 6.6k; this rule 6.7k, 5.4k, 5.1k (no mark); PerQueue 4.1k, 4.1k, 4.0k. There, draws' own spans reached 1.16 to 1.52 ms (timesliced), under the bound. - Isolation, 3 runs each: trap and slow-alternating 64 completions over 10 ms under Adaptive (the one first-long stall, at most 26.4 to 30.1 ms) against none under PerQueue (at most 5.6 to 9.7 ms); alternating none under Adaptive (at most 5.7 to 9.8 ms) against 7, 0, 0 under PerQueue. Unchanged from the host-age rule's runs. - 8 threads: 3 in flight 53.4k, 54.4k against 27.8k, 27.4k; 1 in flight 50.1k, 49.3k against 14.0k, 13.9k. - Device tests (debug, --cfg m2v_gpu): tests::queue_share_device 8/8, the joining lane test and cross_queue_shadows 7/7 (the one-VkQueue cases: X's and Y's queues both on VkQueue 1, neither long, holds withheld 2, gated copies in 2). The compositor isolation test, old rule and new in turn, 3 each: p99 2.66-2.94 ms against 2.16-2.83 ms, 0 stalls, the same placement (the compositor alone on VkQueue 1, the application long on VkQueue 0, gone long 1). Its one earlier failure under this rule (p99 7.93 ms, 20 stalls, 5,579 of ~9,600 commits made) ran right after a 74 s compile inside the hold, with the same placement and gone long 1: host load, not the rule. On the M3 Max (MoltenVK, no sharing), tests::queue_share*, command_queues, cross_queue_shadows, gpu_time and host_memory: 90/90. clippy -D warnings plain and --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc; fast_paths, degradation*, api_signatures, api_surface, work_counts pass. No RUNTIME_VERSION bump or pin here. (cherry picked from commit 4fd88b7564cd9cd3651543bb3f8cd529b021709e, two claims corrected to what was run) (cherry picked from commit eb0153e9d0fe6d272f2411c65f0a1ecda2c78bc2)
This commit is contained in:
1 parent
3e55a67849
commit
7996b9a164
15 files changed
+484
-126
No files matched your search
+9
-6
@@ -225,9 +225,9 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
|
||||
on the RTX 5080 Laptop GPU idles about 50 us at each such switch), a command queue that makes a
|
||||
command buffer while it holds no other uncompleted one moves onto the busy `VkQueue` of its
|
||||
family whose oldest batch has run under 0.5 ms, so short command buffers of several queues run
|
||||
with no switch between them. A queue whose batch ran over 2 ms as its `VkQueue`'s oldest is
|
||||
long: no queue joins its `VkQueue`, and it moves once more, at its next such make, to an idle
|
||||
`VkQueue` of its own. So a queue waits behind another's long command buffer once per queue
|
||||
with no switch between them. A queue one of whose command buffers ran on the GPU for over 2 ms,
|
||||
by its own timestamps, is long: no queue joins its `VkQueue`, and it moves once more, at its next
|
||||
such make, to an idle `VkQueue` of its own. So a queue waits behind another's long command buffer once per queue
|
||||
that goes long, about that command buffer's length: the first long command buffer of a queue
|
||||
that shared holds the command buffers committed behind it there for its whole length,
|
||||
announced `queue-sharing` at the device's first join (section 9). A queue made with
|
||||
@@ -237,7 +237,10 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
|
||||
where a shared one's had one stall of 30 ms beside 30 ms command buffers). Presenting queues, and a queue that lent its `VkQueue`
|
||||
(`CommandQueue::with_vk_queue`), never move. Before the check answers, and on a device whose
|
||||
check finds no idling or that has no two `VkQueue`s of one family (MoltenVK, RADV, lavapipe),
|
||||
each queue keeps the `VkQueue` it took at its creation, round robin.
|
||||
each queue keeps the `VkQueue` it took at its creation, round robin. So does a device whose
|
||||
command buffers write no GPU timestamps it reads (`DeviceOptions::gpu_times_from_host`, or a
|
||||
driver whose timestamps wait for every queue's), counted `WorkCounts::queue_sharing_untimed`: a
|
||||
queue is known long only by its command buffers' timestamps.
|
||||
`queue_sharing = QueueSharingPolicy::PerQueue`, which `exact_answers()` selects, keeps each
|
||||
command queue on that `VkQueue` everywhere and runs no check.
|
||||
|
||||
@@ -2614,8 +2617,8 @@ bound.
|
||||
`Device::new_command_queue_unshared`, which never move and which no queue joins. Cost: its
|
||||
command buffers run in one `VkQueue`'s order with those of the command queues that share it,
|
||||
where Metal's queues wait for each other only inside one command: the first command buffer of
|
||||
each such queue that runs as its `VkQueue`'s oldest for over 2 ms holds the command buffers the
|
||||
others committed behind it for its whole length, and its later ones while its queue holds work,
|
||||
each such queue whose GPU work runs over 2 ms holds the command buffers the others committed
|
||||
behind it for its whole length, and its later ones while its queue holds work,
|
||||
until that queue moves at its next idle point; a command buffer's GPU start time includes the
|
||||
other queues' work before it; QueueSharingPolicy::PerQueue keeps each command queue on the
|
||||
`VkQueue` it took at its creation.
|
||||
|
||||
Reference in new issue
Block a user