A command buffer with completed handlers ran its whole transition to
Completed on its queue's handler thread, its completion-seen handlers
included, so they started a thread wake after the queue waiter's turn: the
consumer's handler_cost bench (a completion-seen and a completed handler on
each 4 KiB fill) put that wake into the completion-seen latency. On an idle
M3 Max (MoltenVK 1.4.2) the turn-to-handler time was 22 us at the median
with a completed handler against 1 us without.
Now the waiter runs such a transition to its completion-seen handlers
(To::Seen: its status final, those handlers run) where its queue's context
is idle, and posts the rest (To::Rest: follow release, completed handlers,
slot, releases, gate) to that context while it still runs it, so the queue's
later items stay behind the rest. The rest holds its own Hold, so the gate,
and wait_until_completed, open only after the completed handlers and once
the context is done with the rest (the order a10704b730 set). A command
buffer with a Follow (it signals at its end an event another queue's
command buffer may wait for) keeps the whole transition on the handler
thread, so the cross-queue order (follow.rs) is untouched. Where the waiter
cannot run it here (the line busy, a deallocator held), the transition goes
whole, as before (Item::whole).
complete() is split into complete_seen() and complete_rest(), unchanged in
order. Docs: add_completion_seen_handler, completion.rs, the runtime README
and RUNTIME-PORTING.
Not yet run on a device.
(cherry picked from commit e1f36ec2f08735c92872a3d5eed8689b398373ce)