runtime_lane::exits::exits_right_after_learning_of_completion_are_clean failed on the RTX 5080
in lane 10 of development's round at 9bd38c7994: handler_learns_exit's exit took 2.08 s, against
the lane's EXIT_LIMIT of 1.5 s. In that case the program drops its device while a command buffer
is in flight, then exits once the command buffer's completed handler has run. The device's last
reference goes on the handler thread, so its teardown (DeviceShared::drop, one section of the
exit guard) runs while the program's exit begins, and the exit's hook waits for that section.
Each step of that teardown was timed in a scratch build (b5080 entry holds-exit-2, beside another
process's lane on the GPU). vkDestroyDevice, through the validation layer into NVIDIA's driver,
took 0.3 to 2.6 s; every other step took under 0.25 s in all. 86 of the 120 exits ran past the
hook's 2 s bound and ended at once. In each stack taken 1.2 s after the child's last line, the
teardown's thread was in vkDestroyDevice. The same tail showed with 47174c4775 (the queue-switch
check's round hold) reverted: entry holds-exit-1, 30 exits a tree, the two trees' exits in the
same two modes (about 25 ms, and 150 to 250 ms with a tail to 0.6 and 0.95 s).
The teardown now reads the guard at three points: before its wait for idle, before its pipeline
caches and memory go, and before vkDestroyDevice. Once the exit has closed the guard, the device,
its objects and its memory are left to the process's end, as where the exit began before the
teardown, so the exit waits for no more than the teardown's step in progress. A teardown that no
exit races is unchanged. exit_guard's module docs ("Once closed", BOUND), the teardown's comments
and docs/API.md's process-exit difference say so.
Verified, RTX 5080 Laptop GPU, b5080 entry holds-exit-3 (a shared batch). Runtime_lane::
framebuffer_fetch looped beside on the GPU. handler_learns_exit's child ran as the lane runs it,
alternating two builds 60 times each: development dc064aec27 with the step timings, and the same
with this change. Each exit was measured as the lane measures it, less the exiting thread's wait
for a CPU:
before (dc064aec27) this change
teardown on the handler 43 of 60 41 of 60
left at wait-for-idle - 41 of 41
hook's wait (handler) 0.17 to 1.03 s 1 to 7.5 ms
exit, median 478 ms 206 ms
exit, 90th percentile 932 ms 411 ms
exit, longest 1130 ms 590 ms
exits of 500 ms or more 29 1
exits of 1 s or more 2 0
- With this change, an exit whose teardown ran on the handler still takes 0.17 to 0.59 s past the
hook. That time is in the exit handlers registered before the hook's last registration (the
driver's and the layer's), with the device left to them. Before, that remainder was 24 to
138 ms.
- exit_guard's unit tests passed 46 of 46 (homelab-gem10-1, m3-max-8041).
Not run before this commit: the exits lane whole (development's round runs it), and the change
beside the heavier GPU load of holds-exit-2 (queued: holds-exit-4).
(cherry picked from commit 4ee7b0934a7e2db25b2262cf9c03d84313336be3)