From 96ba9a104c70d09629e70979bf9d9bfc09cc15ac Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 8 Nov 2026 01:15:38 -0800 Subject: [PATCH] The unshared-queue test bursts on until a choice withholds a join tests::queue_share_device::no_queue_joins_an_unshared_queue_s_vk_queue_and_ one_placed_there_leaves asserts that, where the device shares VkQueues, at least one of the choices its three other queues make after the unshared queue's 16 bursts withheld a join from the unshared queue's VkQueue (WorkCounts::joins_withheld_from_unshared), so that its check that no queue landed there is not empty. A choice withholds one only while that VkQueue is busy and its oldest batch young (queue_share.rs), which a choice made right after a burst finds unless the host comes back late: each burst is 24 command buffers of a 1 MiB fill, done on the RTX 5080 within some tens of microseconds. On a development round's RTX 5080 suite partition (dv-rt1-221823, at 7e9acd5e73) none of the 48 choices withheld one, and the test failed at its assertion. The test now goes on bursting past the 16, where the device shares, until a choice withheld a join, for at most its WAIT (20 s), and prints the bursts and the choices' counts. Nothing else changes. Verified, RTX 5080, entry holds-holds-unshared-1-010148 (c, beside a development lane), eight copies of the test at once for 5 min each: - development's test with the counts printed (scratch, 16 bursts): 72 of 72 passed; in each Adaptive leg every choice either withheld a join or found no other VkQueue busy (the burst seen complete before it), withheld 1 to 42 of the 48, the least 1 against 47 found idle: the choices that withhold none find the burst done, the failure's case, not a busy VkQueue passed over unseen. - this change: 80 of 80 passed, each within the 16 bursts there (withheld 3 to 44 of 48), so the longer run is taken only where a choice missed them all. - its build under --cfg m2v_gpu: no warning (msi, m3-max-7629). (cherry picked from commit 0af88b819edb4977a9a67911bfd0dbb3d9e859d3) --- .../src/tests/queue_share_device.rs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs b/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs index 04680fff5..95ca810ea 100644 --- a/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs +++ b/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs @@ -345,7 +345,19 @@ fn no_queue_joins_an_unshared_queue_s_vk_queue_and_one_placed_there_leaves() { // robin's next `VkQueue` (`Device::new_command_queue_unshared`), so every `round_robin`-th // queue after it is on its `VkQueue` (on a device of one queue, each), and no other. let round_robin = device.shared().round_robin(); - for _ in 0..16 { + // A choice withholds a join from the unshared queue's `VkQueue` only while that + // `VkQueue` is busy and its oldest batch in flight young (`queue_share.rs`), as a choice + // right after a burst finds it, unless the host was slow to come back from the burst + // (its batches complete or seen complete long before): where the device shares, the + // bursts go on past the 16 until a choice withheld one, for at most `WAIT`. + let began = Instant::now(); + let mut bursts = 0; + while bursts < 16 + || (shares + && device.work_counts().joins_withheld_from_unshared == 0 + && began.elapsed() < WAIT) + { + bursts += 1; let kept = burst(&unshared, &scratch, 24); for (after, queue) in others.iter().enumerate() { let made = queue.command_buffer().unwrap(); @@ -365,8 +377,14 @@ fn no_queue_joins_an_unshared_queue_s_vk_queue_and_one_placed_there_leaves() { home, "the unshared queue moved" ); + let counts = device.work_counts(); + println!( + "{bursts} bursts: {} choices withheld a join from the unshared queue's VkQueue, {} \ + found no other VkQueue busy", + counts.joins_withheld_from_unshared, counts.picks_with_none_busy + ); if shares { - assert!(device.work_counts().joins_withheld_from_unshared > 0); + assert!(counts.joins_withheld_from_unshared > 0); // Every round robin's `VkQueue` holds a queue, so the next unshared queue shares // one with a queue, which leaves at its next idle point. let filled: Vec = (0..round_robin)