What: a thread in CommandBuffer::commit_and_submit now runs the submission
checks of the head committed first of all itself, without the scheduler's
lock, right before it submits that head, where the head is ready but for its
checks (no host step, no group, no storage-form switch, no rebind) and every
event value it waits for was reached on the device or by the host. It then
passes again under the lock (Inbox::pass_again, which takes nothing in) and
submits that head first, and so on up to PASS_SUBMISSIONS batches in all. A
head whose checks wait for a submitted GPU signal to land, or whose checks the
scheduler's thread took first, stays the scheduler thread's, as before.
Why: reims's Vulkan platform sets a check on every command buffer it commits,
so commit_and_submit never submitted at commit for them (plain_ready held out
every checked head). Metal checks a submission as it submits it, on whichever
thread submits, so running the check on the committing thread is Metal's
behaviour; the check follows the submission handler's rule there (no lock the
caller holds, no GPU wait).
How:
- Held::checks_taken marks a batch whose checks were taken, by check_heads
(left to the scheduler's thread, replacing its Left::holds lookup) or by a
committer (claim_check), so the two never both run them.
- claim_check looks at Order::first_mut (the head take_first would take), so
no head is passed over: commit order holds across threads.
- The committer's handlers keep their Turns tickets: each pass under the lock
takes its own ticket, and its handlers run before the next check.
- The check runs through run_work -> CommandBufferShared::run_checks, the
scheduler's own path, so a code (or a panic) fails the submission exactly
as there (fail_submission, the CB completing with Injected(code)).
- plain_ready now holds out only a checked head whose checks are still to run,
so a head whose checks ran goes with any plain pass.
- Counted: WorkCounts::batches_checked_at_commit (new), beside
batches_submitted_at_commit; classified as Submission by its "batches_"
prefix in the conformance cost rules.
Verified on the M3 Max (MoltenVK, --cfg m2v_gpu, maclock, load 50-90):
- New tests in tests::commit_and_submit:
- a_checked_command_buffer_is_checked_and_submitted_on_the_committing_thread:
40 of 40 checked and submitted on the caller, check then handler, before the
call returned; batches_checked_at_commit 40.
- a_refusing_check_fails_its_submission_alike_at_commit_and_on_the_scheduler:
two submissions split by an event signal, the second refused with code 8:
identical status, error, completed-handler status, submissions seen, bytes
and event value on both paths.
- checked_command_buffers_keep_commit_order_across_commit_and_commit_and_submit:
2 threads x 500 checked CBs, commit and commit_and_submit in turn: checks
and submission handlers in commit order, each check once; 308 of 1000
checks on a committing thread.
- The five commit_and_submit tests: --stress-count 10, 10/10 passed.
- Negative controls:
- claim_check answering None: all three new tests fail (0 checked at commit).
- claim_check neither honouring nor setting checks_taken: the order test
fails 4/4 (checks out of commit order, checks run twice).
- runtime_lane::submission_checks' in-flight test gains a commit_and_submit
variant whose wait is met only by a GPU signal in flight: its check ran only
after the signal landed and never on the caller, Event and SharedEvent.
submission_checks, grouped_submissions and queue_order lanes: 24/24 passed.
- Runtime tests matching scheduler|check|teardown|completion|submission|inbox|
order: 169/169 passed. Conformance cost, fast_paths and api_signatures
tests 38/38; clippy -D warnings (runtime + validation, --cfg m2v_gpu) clean;
public rustdoc clean. api_signatures.tsv blessed (one new field).
(cherry picked from commit 91d0ea691a95649cbdc7828d4cc9ee6762a7ae53)
(cherry picked from commit 6c5fca926e855ee7d7236bc850bb9b281f4dd9cd)