Files
metal2vulkan/crates
Anees Iqbal bc2bda79d7 A check's own allocations and frees are owed to its next step
On an RTX 3090 (NVIDIA 620.70.06), a vkFreeMemory of a host-pointer import holds back every
other thread's vkQueueSubmit while it runs. The submission checks' import tax freed its 32
imports back to back, so the scheduler's one thread got a submission in only between two
frees. A device made without a check record (every test device: a fresh shader cache) ran
that beside the queue-sharing isolation tests, and the compositor's command buffers beside
long work waited up to 21 ms from commit to submission. Those were the three isolation
failures of the 3090's GPU-time leg.

Now a check's own allocation or free of memory, at the two doors (allocations::Busy), owes
its length to the thread's next step: step_aside waits that long first, then steps aside as
before. The device's other threads' submissions go between the check's calls, and the check's
allocations and frees hold the driver at most half the time they run. A call of microseconds
is owed microseconds. A step told to go on (a caller waits for the verdicts, or the check
stops) pays nothing. Counted among the checks' steps aside.

How it was found (3090, gem10; diagnosis on a scratch branch):
- Traced runtime runs: each compositor vkQueueSubmit returned only after the GPU ran the batch,
  in episodes. Traced with the check, an episode was exactly the import tax's frees: each
  0.5 to 0.7 ms, the scheduler's submit returning between two of them.
- With the checks settled before measuring: 0 stalls in 4 of 4 runs (p99 1.7 to 2.4 ms), against
  12 to 71 stalls over 10 ms with them running.
- A raw Vulkan probe: 32 imports of 512 KiB made and freed in turn beside 4,800 fills a second
  put the fills' latency at p50 3.9 to 8.3 ms alone (0.12 without it) and 11.4 to 12.7 ms beside
  30 ms work on another queue (0.74 without it). These did not block it: timestamps,
  calibration, waits in vkWaitSemaphores, two submit infos, 16 queues, pageable memory,
  device addresses, fresh recording, kept barrier command buffers, one submitting thread, or
  a fence-waited checker on the same queue.

Tests: step_aside's a_check_s_own_call_is_owed_to_its_next_step and
a_call_on_another_thread_is_owed_nothing.
2026-11-11 16:15:33 -08:00
..