Files
metal2vulkan/crates/metal2vulkan-runtime/examples
Anees Iqbal b01ec7ceeb RUNTIME 2467: Scheduler: awake through a burst of commit_and_submit calls; passing holds signal only where a making waits
What:
- Scheduler (scheduler/mod.rs, inbox.rs): a commit_and_submit within BURST_WINDOW (100 us) of the
  one before wakes the scheduler's thread after its own pass; the thread then stays counted as the
  inbox's passer while the last commit_and_submit came within the window, spinning on the inbox,
  so later commits of the burst post and return, left to it, and its next pass takes them in
  commit order. submit_before_waiting, a waker's poke for what is not in the inbox, and a stop end
  the burst. An idle device's thread spins not at all; a burst costs that thread's CPU for its
  length and one window more.
- Passing holds (resource_ids.rs): the last hold to end signals only where a making waits.
- dispatch_chain bench: back-to-back command buffers, encoding threads on one queue,
  commit-to-start latency, CPU per second busy and idle.
- Docs: commit_and_submit and the runtime README describe the burst.

Why: a guest's decode walk commits small command buffers (5 compute encoders of 1 dispatch) 35 to
76 us apart on its critical path, and each commit_and_submit made the scheduler's pass inline on
the committing thread (Inbox::pass_on inside the commit). Left to an awake scheduler thread, the
commit call returns early.

Verified (lane walkcpu):
- msi lavapipe (m3-max-37234), commit call per command buffer of 5 encoders x 1 dispatch:
  64 back to back 9.2 -> 4.5 us; two threads on one queue 11.5-12.6 -> 5.1 us, commit-to-submit
  p99 61 -> 42 us. About 95% of a burst's commits went to the awake thread. Scheduler thread CPU
  idle 0.0 ms/s before and after; in a burst 34 us per command buffer.
- Isolated commits (2 ms apart) still pass inline: passes_at_commit 1 per command buffer.
- Open: commit-to-submit inside a burst, p50 4.5 -> 5.6 us, p99 15-23 -> 29-37 us; the lane is
  splitting the burst's head from the rest to find the cause.
- clippy (plain at b8a81d328d, m3-max-37217; GPU and CPU-ICD cfgs at 675023517e, m3-max-37223),
  rustdoc (37223): 0.
- New tests: inbox linger unit test; device test of 48 back-to-back commits on 1 then 2 threads
  (handlers keep per-queue commit order, at least a quarter left to the awake thread); passing
  holds unit test (1000 holds, no making: 0 signals; 2000 raced rounds: every making goes on).
2026-11-16 10:44:41 -08:00
..