From a379f41e0bb2ec5e2f06aa69dd3e27ebd31bbba1 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 11 Nov 2026 11:54:55 -0800 Subject: [PATCH] Docs: the unshared hold's measured benefit and cost, and a queue with no run seen FAST-PATHS's row for unshared_isolation, API.md's bullet, the policy's Bounded doc and unshared_hold.rs's costs now say that a batch of a queue with no run seen holds the others back until it completes, and give the owned workload's numbers (queue_share frames --unshared, Off against Bounded): the Iris Xe (m3-max-16880, -16885) and the Radeon 780M (m3-max-16900), the compositor's median and worst waits, the application's rate and GPU idle on a quiet host, and the loss under host CPU load (the hold's 2 ms of slack against Off's queued batches). Bounded stays the default on every one-graphics-queue driver. --- .../metal2vulkan-runtime/src/unshared_hold.rs | 8 ++++-- crates/metal2vulkan/src/device/policy.rs | 8 ++++-- docs/API.md | 17 +++++++---- docs/FAST-PATHS.md | 28 ++++++++++++++----- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/unshared_hold.rs b/crates/metal2vulkan-runtime/src/unshared_hold.rs index c3d52e5e2..2f5898b0b 100644 --- a/crates/metal2vulkan-runtime/src/unshared_hold.rs +++ b/crates/metal2vulkan-runtime/src/unshared_hold.rs @@ -41,8 +41,12 @@ //! thread, which it wakes. //! - **What it costs.** A batch longer than its queue's recent ones still holds the unshared //! queue's command buffer for its whole length: one command buffer's batch is one submission, -//! which the GPU runs to its end. Every batch on such a `VkQueue` costs a place in its -//! [`Flight`] and a lock of its own at the submission and the completion. Counted: +//! which the GPU runs to its end. The next batch goes in about [`BUDGET`] before the one ahead +//! ends, where `Off` keeps every ready batch queued, so the GPU waits for the scheduler's thread +//! where the host's CPU is loaded: on the Iris Xe at a load of about 10, an application's 5 ms +//! command buffers ran 181.8 a second against 189.3 (docs/FAST-PATHS.md); on a quiet host no +//! throughput was lost. Every batch on such a `VkQueue` costs a place in its [`Flight`] and a +//! lock of its own at the submission and the completion. Counted: //! `WorkCounts::heads_held_for_unshared_isolation` (each look that held a head so). use std::collections::VecDeque; diff --git a/crates/metal2vulkan/src/device/policy.rs b/crates/metal2vulkan/src/device/policy.rs index 4dc652ca6..1a03a5712 100644 --- a/crates/metal2vulkan/src/device/policy.rs +++ b/crates/metal2vulkan/src/device/policy.rs @@ -566,9 +566,11 @@ pub enum UnsharedIsolationPolicy { /// unshared queue's command buffer goes in behind about one batch of theirs. A batch's /// expected GPU work is its command queue's: the host's view of how long that queue's /// recent batches ran on the `VkQueue`, raised at once by a longer one and halved toward a - /// shorter one. The next batch is submitted before the one ahead ends, so the GPU is not - /// left idle between them; a batch longer than its command queue's recent ones still holds - /// the unshared queue for its whole length, as one command buffer is one submission. + /// shorter one; while a batch of a command queue with no run seen yet is in flight there, no + /// other is submitted until it completes. The next batch is submitted before the one ahead + /// ends, so the GPU is not left idle between them where the host's scheduler thread runs in + /// time; a batch longer than its command queue's recent ones still holds the unshared queue + /// for its whole length, as one command buffer is one submission. #[default] Bounded, /// Every ready batch is submitted at once: an unshared queue's command buffer waits behind diff --git a/docs/API.md b/docs/API.md index 023e75d6b..96e913099 100644 --- a/docs/API.md +++ b/docs/API.md @@ -261,12 +261,17 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`: submitted there only while less than 2 ms of the other queues' expected GPU work is in flight on it; else the scheduler holds it, in its place in the order, until enough completes. A batch's expected work is its command queue's: the host's view of how long its recent batches ran, raised - at once by a longer one and halved toward a shorter one. The next batch goes in before the one - ahead ends, so the GPU is not left idle between them, and the unshared queue's command buffer - waits behind about one batch of theirs: the whole of one, however long, as a submission runs to - its end. Counted: `WorkCounts::heads_held_for_unshared_isolation`. - `unshared_isolation = UnsharedIsolationPolicy::Off` submits every ready batch at once, so the - unshared queue's command buffers wait behind every batch submitted before them there. + at once by a longer one and halved toward a shorter one; while a batch of a command queue with + no run seen yet is in flight, no other goes until it completes. The next batch goes in before + the one ahead ends, so the GPU is not left idle between them where the scheduler's thread runs + in time, and the unshared queue's command buffer waits behind about one batch of theirs: the + whole of one, however long, as a submission runs to its end. Beside an application keeping three + 30 ms command buffers in flight, a compositor's median wait fell from 75 to 17.5 ms on the Iris + Xe and from 71-84 to 18 ms on the Radeon 780M, with no throughput lost on a quiet host; under + the host's CPU load the GPU idles more (docs/FAST-PATHS.md has the numbers). Counted: + `WorkCounts::heads_held_for_unshared_isolation`. `unshared_isolation = + UnsharedIsolationPolicy::Off` submits every ready batch at once, so the unshared queue's command + buffers wait behind every batch submitted before them there. - **An attachment loaded `DontCare` and not stored, cleared where its driver clears it no slower** (`UnstoredDontCarePolicy::Driver`, the default; the runtime's choice, no pipeline differs). Metal's draws read zero (a colour) or the pass's clear value (depth, stencil) of such an attachment diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index d6a901a33..9e4a15120 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -121,13 +121,27 @@ known. The rest of the differences are docs/API.md section 9's precision notes. shares with them (`unshared_hold.rs`; a device with one graphics queue: RADV, ANV, lavapipe): another queue's batch goes there only while less than 2 ms of their expected GPU work is in flight on it, its queue's expected run being the host's view of its recent batches' runs, raised - at once by a longer one and halved toward a shorter one. So a compositor's command buffer waits - behind about one batch of an application's, as Metal runs it beside the application's work, and - the next batch goes in before the one ahead ends. `unshared_isolation = - UnsharedIsolationPolicy::Off` submits every ready batch at once: peak rate with no hold, the - unshared queue's command buffer behind every batch submitted before it. Not an accuracy choice: - it trades the other queues' submission ahead for the unshared queue's wait. The runtime's choice: - no pipeline differs. + at once by a longer one and halved toward a shorter one; a batch of a queue with no run seen yet + holds the others back until it completes. So a compositor's command buffer waits behind about + one batch of an application's, as Metal runs it beside the application's work, and the next + batch goes in before the one ahead ends. `unshared_isolation = UnsharedIsolationPolicy::Off` + submits every ready batch at once: peak rate with no hold, the unshared queue's command buffer + behind every batch submitted before it. Not an accuracy choice: it trades the other queues' + submission ahead for the unshared queue's wait. The runtime's choice: no pipeline differs. + Measured with the runtime's `queue_share` example (`frames --unshared`: an application keeping + three command buffers in flight beside a compositor committing one draw every 16 ms), `Off` + against `Bounded`. On the Iris Xe (ANV, Mesa 26.2.6, a quiet host; m3-max-16880, -16885), with + 30 ms command buffers, the compositor's median wait fell from 75 to 17.5 ms and the application + ran 33.2-33.5 command buffers a second under both (the GPU idle 0.12% against 0.15-0.16%); with + 5 ms ones, from 12.6 to 4.7 ms, at 196.4-198.6 a second under both. On the Radeon 780M (RADV, Mesa 26.2.6; + m3-max-16900), with 30 ms ones, the median fell from 71-84 to 18 ms and the worst from 94-114 to + 35-40 ms, about one command buffer. The cost: no throughput measurable on a quiet host, but the + hold leaves 2 ms of slack where `Off` keeps two batches queued, so under the host's CPU load the + GPU waits for the scheduler's thread more often: on the Iris at a load of about 10, with 5 ms + command buffers, 181.8 a second against 189.3 (the GPU idle 8.9% against 4.5%; m3-max-16885), + and on the 780M 192.4 against 203.7 (m3-max-16900). The 780M's rate otherwise follows its + command buffers' own GPU time, which moved 4.1-4.8 ms between runs of either value on a host + other jobs loaded. The default on every driver with one graphics queue. - `pointer_domain`, `handle_domain`, `containment` and `isolation` choose how resources resolve and how guests are contained, not an answer of Metal's arithmetic or sampling.