From 4f683ad8915dd1487d9a0c7f5f5f8799e2cba7d6 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 22 Nov 2026 15:16:57 -0800 Subject: [PATCH] Tests: the later sharer's queue has a known short run, so it fits the room behind the pieces What: in every_device_copies_an_idle_queues_copy_of_a_long_write_into_a_later_sharer, the third queue first runs one command buffer with no commands, and its expected run is then set to BODY_RUN (1 ms, the test's own input), before the busy gate is made. Why: in job m3-max-68964 the test passed on both arms, 3 of 3. On the cut arm it printed cuts 5 (the writer's six pieces) and shared_holds 1 (the first copy held). But the second copy's queue had no expected run, so its group asked for room at u64::MAX, and room() takes such a group only with fewer than two submissions in flight. The writer's pieces, each of run 0 and ranked behind it, kept two or more in flight until the last one was staged. That released the first copy, which is committed earlier and also at turn 0, so it ranks first. So the second copy followed the first because of its own unknown run, not because of a rule that orders it after the first. With a run of 1 ms the second copy fits room(), and its rank, turn 0, comes before the writer's next piece. That leaves the planner's (h3) shape free to show. Both items are on development c38852d665 too (QueueInner::set_run_for_test, BODY_RUN). Verified: not run when committed. --- crates/metal2vulkan-runtime/src/tests/command.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-runtime/src/tests/command.rs b/crates/metal2vulkan-runtime/src/tests/command.rs index 8946465c2..b4788c692 100644 --- a/crates/metal2vulkan-runtime/src/tests/command.rs +++ b/crates/metal2vulkan-runtime/src/tests/command.rs @@ -2039,7 +2039,10 @@ pub(crate) mod on_device { /// `x = x * 2 + 1`, two kernels of unknown rate in turn, so a runtime that cuts a command /// buffer into pieces of a kernel's rate makes six, more than the device's room takes, and /// the rest wait. A copy of what it writes is then committed to an idle queue, and a copy of - /// that copy to a third idle queue, with no host wait for either. Once the submit thread has + /// that copy to a third idle queue, with no host wait for either. The third queue ran one + /// command buffer before the gate, and its expected run is [`BODY_RUN`], the test's own input, + /// so the second copy fits the device's room behind the writer's pieces: a queue whose run is + /// unknown has room only with one submission in flight. Once the submit thread has /// looked past the second copy (an empty command buffer committed after it is scheduled) the /// gate opens. Metal submits the first copy at its commit, its queue having nothing ahead of /// it, so its hazard tracking orders that copy after the writer and the second copy after it: @@ -2057,6 +2060,11 @@ pub(crate) mod on_device { queue(&device), queue(&device), ); + let earlier = reading.command_buffer().expect("a command buffer"); + (earlier.record_for_test(&[], |_, _| {})).expect("a command buffer's commands"); + earlier.commit().expect("a commit"); + finished(name, &earlier); + earlier.queue().set_run_for_test(BODY_RUN); let busy = Busy::new(&device); let writer = writing.command_buffer().expect("a command buffer"); let mut encoder =