D3D12.X: an allocator Reset keeps the recordings the title still submits #897

Manually merged
github merged 1 commit from gh-pr/897/head into gh-pr/897/base 2026-11-26 04:36:05 +00:00
Owner

@⁠theaustinayers on GitHub · 2026-11-24 07:54 UTC · original
theaustinayers:alloc-swap → main · +296 −7 · 4 files · 1 commits · merged 2026-11-24 07:56 UTC

A retail title's device was removed (0x887a0001) a few seconds after its world started, in every run. The debug layer names it: "The command allocator was reset after the command list was recorded" (id 541). A trace of every list reset, allocator reset and submit showed the title's own order: one recording made at 61.4 s, submitted at 61.6 s, again at 63.2 s on a second queue, the allocator it was given reset at 67.2 s, and the same recording submitted a third time at 67.8 s. Its console lets it; on the PC the recording lives in the allocator and is gone at the Reset.

The title's allocator now stands for a PC allocator that changes: at the title's Reset, if lists still hold recordings on the one in use (or the GPU has not finished them), it is put aside as it is and another takes its place.

What is in it

  • crates/xcl/src/hle/d3d12x/alloc_pool.rs (new): which PC allocator each list's recording is on, a fence value a queue after each submit, and the swap at the title's Reset – to an allocator put aside earlier that no list uses any more and whose submits are done, or a new one. A list holds one recording, so no more are put aside than there are lists. GPU test a_recording_outlives_the_reset_of_the_titles_allocator (with XCL_ALLOC_SWAP=0 it fails at its first assertion).
  • real.rs: alloc_reset asks alloc_pool first; reset_pc_allocator; a note of each submit in q_execute_command_lists.
  • list_x.rs: every PC list Reset (the title's, the mid-list split's, KickoffX's) takes the PC allocator in use; CreateCommandList notes the list's allocator; KickoffX's submits are noted.
  • XCL_ALLOC_SWAP=0 turns it off.

Tested

  • NVIDIA GeForce RTX 5090 (driver 621.14), Ryzen 9 9950X3D, Windows 11 build 26300, rustc 1.100.0, debug build for tests, release for the runs
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4: 716 passed, 0 failed, 41 ignored; no SKIPPED tests on this adapter
  • A retail title, on a build of main at beaa245 with this change and the trace: before, the device was removed 5–9 s into the world in every run (4 runs). With it, no device removal and no stale submit in the trace in 5 world runs: 4 reached their limit of 100–120 s; the first ran 134 s and was ended on an NVIDIA driver error (nvlddmkm 153) whose cause I do not know. In 60 s of world: 240 Resets swapped, 163 allocators made, 77 reuses. (A sixth run crashed at 22 s in the menus in tiling::detile_level reading title memory – not this code.)

Regression run

main (dbe9324 is the commit of #873, merged as 1ec4c98):

xcl-smoke v1
commit: dbe932400410828fd0490f86714a1f397d4a1504
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1627 (PresentX 1627)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16291 MB

PR:

xcl-smoke v1
commit: 11920b5e0d127f04d45363ac8475e82d174d9e40
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1639 (PresentX 1639)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16186 MB

Not tested

  • The head commit itself in the title's world: the world runs above were made with the same alloc_pool logic on a build that also carried the trace and other local changes. The 60 s regression run is of the head commit and does not reach the world.
  • AMD and Intel GPUs, Wine / vkd3d-proton.
  • Memory over a long session: an allocator put aside stays until the list that recorded on it is reset again; 116 were held that way after 60 s of world. A list that is released while it holds a recording keeps its allocator put aside for good (not handled here).
  • The world is still at about one frame every 2–6 s with this (the GPU is at 97–100 % from the world's start): this PR only keeps the device.

AI use

  • Claude Code, Claude Fable 5.2: wrote the trace that found the order, the code, the test and this description. The runs above were made on the hardware named.

🤖 Generated with Claude Code

**@⁠theaustinayers** on GitHub · 2026-11-24 07:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/897) `theaustinayers:alloc-swap` → `main` · +296 −7 · 4 files · 1 commits · merged 2026-11-24 07:56 UTC A retail title's device was removed (`0x887a0001`) a few seconds after its world started, in every run. The debug layer names it: "The command allocator was reset after the command list was recorded" (id 541). A trace of every list reset, allocator reset and submit showed the title's own order: one recording made at 61.4 s, submitted at 61.6 s, again at 63.2 s on a second queue, the allocator it was given reset at 67.2 s, and the same recording submitted a third time at 67.8 s. Its console lets it; on the PC the recording lives in the allocator and is gone at the Reset. The title's allocator now stands for a PC allocator that changes: at the title's Reset, if lists still hold recordings on the one in use (or the GPU has not finished them), it is put aside as it is and another takes its place. **What is in it** - `crates/xcl/src/hle/d3d12x/alloc_pool.rs` (new): which PC allocator each list's recording is on, a fence value a queue after each submit, and the swap at the title's Reset – to an allocator put aside earlier that no list uses any more and whose submits are done, or a new one. A list holds one recording, so no more are put aside than there are lists. GPU test `a_recording_outlives_the_reset_of_the_titles_allocator` (with `XCL_ALLOC_SWAP=0` it fails at its first assertion). - `real.rs`: `alloc_reset` asks `alloc_pool` first; `reset_pc_allocator`; a note of each submit in `q_execute_command_lists`. - `list_x.rs`: every PC list Reset (the title's, the mid-list split's, KickoffX's) takes the PC allocator in use; CreateCommandList notes the list's allocator; KickoffX's submits are noted. - `XCL_ALLOC_SWAP=0` turns it off. **Tested** - NVIDIA GeForce RTX 5090 (driver 621.14), Ryzen 9 9950X3D, Windows 11 build 26300, rustc 1.100.0, debug build for tests, release for the runs - `cargo build --workspace`, then `cargo test --workspace -- --test-threads=4`: 716 passed, 0 failed, 41 ignored; no SKIPPED tests on this adapter - A retail title, on a build of main at beaa245 with this change and the trace: before, the device was removed 5–9 s into the world in every run (4 runs). With it, no device removal and no stale submit in the trace in 5 world runs: 4 reached their limit of 100–120 s; the first ran 134 s and was ended on an NVIDIA driver error (nvlddmkm 153) whose cause I do not know. In 60 s of world: 240 Resets swapped, 163 allocators made, 77 reuses. (A sixth run crashed at 22 s in the menus in `tiling::detile_level` reading title memory – not this code.) **Regression run** main (dbe9324 is the commit of #873, merged as 1ec4c98): ``` xcl-smoke v1 commit: dbe932400410828fd0490f86714a1f397d4a1504 gpu: NVIDIA GeForce RTX 5090 title: NYCMain seconds: 60 exit: 0x0 frames shown: 1627 (PresentX 1627) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16291 MB ``` PR: ``` xcl-smoke v1 commit: 11920b5e0d127f04d45363ac8475e82d174d9e40 gpu: NVIDIA GeForce RTX 5090 title: NYCMain seconds: 60 exit: 0x0 frames shown: 1639 (PresentX 1639) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16186 MB ``` **Not tested** - The head commit itself in the title's world: the world runs above were made with the same `alloc_pool` logic on a build that also carried the trace and other local changes. The 60 s regression run is of the head commit and does not reach the world. - AMD and Intel GPUs, Wine / vkd3d-proton. - Memory over a long session: an allocator put aside stays until the list that recorded on it is reset again; 116 were held that way after 60 s of world. A list that is released while it holds a recording keeps its allocator put aside for good (not handled here). - The world is still at about one frame every 2–6 s with this (the GPU is at 97–100 % from the world's start): this PR only keeps the device. **AI use** - Claude Code, Claude Fable 5.2: wrote the trace that found the order, the code, the test and this description. The runs above were made on the hardware named. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A retail title's device was removed (0x887a0001) a few seconds into its world.
The debug layer: "The command allocator was reset after the command list was
recorded" (id 541). A trace of every list reset, allocator reset and submit
showed the title's own order: one recording made at 61.4 s, submitted at
61.6 s, at 63.2 s on a second queue, the allocator it was given reset at
67.2 s, and the same recording submitted a third time at 67.8 s. Its console
lets it; on the PC the recording lives in the allocator and is gone.

The title's allocator now stands for a PC allocator that changes. At the
title's Reset, when lists still hold recordings on the PC allocator in use or
the GPU has not finished them, that one is put aside as it is and another
takes its place: one put aside earlier that nothing uses any more, or a new
one. A list reset on the title's allocator records on the one in use. A list
holds one recording, so no more are put aside than there are lists.

Measured on the retail title (RTX 5090) with this change on a build that also
carried the trace: no device removal and no stale submit in the trace in five
runs (before: removed 5-9 s into the world in every run). Four of them reached
their limit of 100-120 s; the first ran 134 s and was ended on an NVIDIA
driver error (nvlddmkm 153) whose cause is not known. In 60 s of world: 240
resets swapped, 163 allocators made, 77 reuses.

XCL_ALLOC_SWAP=0 turns it off.

Assisted-by: Claude Code (Claude Fable 5.2)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:36:03 +00:00
github manually merged commit 11920b5e0d into gh-pr/897/base 2026-11-26 04:36:05 +00:00
Author
Owner

@⁠shelbykb2 on GitHub · 2026-11-24 17:47 UTC · original

A result for the allocator swap on an AMD RX 6800 (16 GB) with a newer retail game. Builds are local: main at 384f7f7 plus later alloc_pool commits up to 01d4c77, with other open PRs and local changes on top, so take it as a pointer, not a clean A/B of main.

With the swap on (default), 14 runs in a row ended with a device removal 0x887a0007 at 213-347 s into the run, always at about 2,640-2,770 presented frames. With XCL_D3D12_DEBUG=1 the debug layer logs Kernel memory failure. There might be a memory leak. (id 834) at the removal. DRED page-fault reporting shows no fault, and no operation is stuck on any queue.

What grows: this title uses about 246 command allocators and resets each one before the lists recorded on it, while those lists still hold recordings that have already executed. The swap counts them as live, so nearly every title allocator gets a second PC allocator (389 made by about 210 s in one run: 246 because none was put aside yet, 143 because a recording held the spare). Each keeps the memory of its largest recording. Non-local video memory outside our own resources rises from 4.6 GB at world start to about 6.1 GB, and the removal comes at that level every time.

With XCL_ALLOC_SWAP=0: 4 runs to their timers (310, 400, 450, 560 s; up to 3,177 frames), no removal, and the same memory levels off near 5.7 GB. No 0x887a0001 either; these builds have the slot #139 list Reset change of #929. I did not run the debug layer in those four, so I cannot say whether id 541 still appears.

Two things I tried that did not bound it: releasing a segment's hold when it is set aside at Reset, and capping idle spares per title allocator.

Measured in runs on my machine; the diagnostics and this report were written with Claude Code (Claude Opus 5.5, reviewed with Claude Fable 5.2).

**@⁠shelbykb2** on GitHub · 2026-11-24 17:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/897#issuecomment-7139703419) A result for the allocator swap on an AMD RX 6800 (16 GB) with a newer retail game. Builds are local: main at 384f7f7 plus later `alloc_pool` commits up to 01d4c77, with other open PRs and local changes on top, so take it as a pointer, not a clean A/B of main. With the swap on (default), 14 runs in a row ended with a device removal `0x887a0007` at 213-347 s into the run, always at about 2,640-2,770 presented frames. With `XCL_D3D12_DEBUG=1` the debug layer logs `Kernel memory failure. There might be a memory leak.` (id 834) at the removal. DRED page-fault reporting shows no fault, and no operation is stuck on any queue. What grows: this title uses about 246 command allocators and resets each one before the lists recorded on it, while those lists still hold recordings that have already executed. The swap counts them as live, so nearly every title allocator gets a second PC allocator (389 made by about 210 s in one run: 246 because none was put aside yet, 143 because a recording held the spare). Each keeps the memory of its largest recording. Non-local video memory outside our own resources rises from 4.6 GB at world start to about 6.1 GB, and the removal comes at that level every time. With `XCL_ALLOC_SWAP=0`: 4 runs to their timers (310, 400, 450, 560 s; up to 3,177 frames), no removal, and the same memory levels off near 5.7 GB. No `0x887a0001` either; these builds have the slot #139 list Reset change of #929. I did not run the debug layer in those four, so I cannot say whether id 541 still appears. Two things I tried that did not bound it: releasing a segment's hold when it is set aside at Reset, and capping idle spares per title allocator. Measured in runs on my machine; the diagnostics and this report were written with Claude Code (Claude Opus 5.5, reviewed with Claude Fable 5.2).
This discussion has been locked. Commenting is limited to contributors.
No description provided.