Repository navigation
Description
What happens
When the game destroys an RR instance, a_destroy takes the runtime-wide lock R().mu and calls destroy_locked (clean/rr_f/runtime/src/rr_runtime.cpp:3598, :2331). That waits up to 2 s for the instance's last serial. Then destroy_instance_resources (:1711) hands the instance's resources to defer_release, which correctly keeps them until the serial is done. It then waits a second time, up to 2 s (:1719), and releases the shader-visible descriptor heap in->heap and the timestamp query heap in->qh (:1720, :1722) whether or not that wait succeeded. Only a log line records the failure.
The game's command list can still use both objects: EndQuery and ResolveQueryData on the query heap (:2851, :3372, :3407), and the descriptor heap for the dispatches. in->null_tmpl is a CPU-only heap used only as a copy source at record time (:2768), so releasing it is harmless.
If the wait times out, the thread has been stalled for up to 4 s while holding the runtime-wide lock.
When it can happen
Only if the list that uses the heaps has not finished when the game destroys the instance. Two cases:
- The game records an evaluate and destroys the instance before it submits that list, for example a settings or resize handler in the middle of a frame. The waits cannot succeed, so the game thread stalls for 4 s and the heaps are then released under the list.
- The queue is stalled for longer than the waits without device removal. This is rare.
There is no parking of destroyed instances on the RR path. The adapter contract puts the duty on the runtime (clean/rr_f/proxy/include/wg_rr_adapter.h:153, "must defer GPU destruction past frames in flight"). After device removal, wait_serial stops early and releasing is fine.
Found by reading the code. It has not been reproduced.
To do
- Widen
Deferred(rr_runtime.cpp:381) to hold any pageable/COM object, with a separate flag for thelive_resourcesaccounting. - Pass
heapandqhtodefer_releasewith the same serial as the resources. - Remove the second
wait_serialat:1719. This also removes the stall. - The first wait in
destroy_locked(:2334) is only for harvesting timings and can be shortened.
If the list never runs, the heaps stay on the deferred list until drop_device (:1081). That is a small amount of memory.
Test
CPU-only: factor pump and defer_release so a test can drive a fake marker value and fake COM objects that count Release. Defer a heap at serial 5 with the marker at 4 and expect no Release. Set the marker to 5, pump, and expect one Release.
A hardware test is still needed for the full destroy path.
Related: #62, #58 (objects released while a recorded list may still use them), #64, #65.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
RR runtime: retire list in rr_retire.h with a CPU test (instance dest…
RR runtime: keep an instance's heaps until its last frame completes; …
Release notes 0.6.5: the fixes merged since (#22, #23, #63, #70, #73, #…