Skip to content

D3D12.X: retire idle NVIDIA command pools between presents - #3122

Closed
Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:codex/nv-command-pool-retirement-20261128
Closed

Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:codex/nv-command-pool-retirement-20261128

Conversation

@Prime1997

@Prime1997 Prime1997 commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Idle split command lists and alternate native command allocators stayed owned after their recordings finished, including while world loading stopped calling PresentX. Reclaim completed spare objects every two seconds, keep a small reuse pool, and return an idle logical allocator to its primary only after Reset succeeds.

NVIDIA adaptation of iggyvilla's AMD #3110. Required binding-cleanup ordering overlaps the problem addressed by #2138 and #2707; their broader orphan/concurrency work is not included. Part of #2688.

What is in it

  • Explicitly completed spare cleanup before retirement; unfinished bindings, GPU work, failed signals and device-removal fence values retain their owners.
  • Release native objects outside pool locks, with activity-log object counts for the next runtime comparison. No claim that these objects explain the full observed RAM growth.

Tested

  • Standalone PR head: 2156e42d6e6a69878539b12641a7dfe52556368a.
  • Combined integration d54d80e1bc9d070cbec4a619abb5f4b89880b2f5 compiled with cargo build --locked --release -p xcl --target-dir <isolated-target>: exit 0, 229.200 seconds. This is compilation of the combined candidate, not a build or runtime validation of this standalone PR. Zero tests executed; no GPU checks or smoke run.
  • Source review by a second Codex agent and git diff --check.

Regression run
Pending. No main/head smoke comparison has been run for this revision.

Not tested
Four new CPU-only regression fixtures, full suite, NVIDIA/AMD runtime behavior and memory savings. Existing native PSOs and driver heaps are not evicted.

AI use
Codex (GPT-6) adapted the contributor repair, wrote the lifetime safeguards and fixtures, and performed source review.

Optional contributor/test coordination: https://discord.gg/6B4TykyC4W

Adapt iggyvilla PR xcl-dev#3110 to nvidia-dev. The narrow pending-binding retirement prerequisite addresses the ordering problem also covered by xcl-dev#2138/xcl-dev#2707. Keep live recordings and unfenced work owned; return to primary only after Reset succeeds.

Four CPU fixtures added but not run. Independently source reviewed; no measured memory reduction claimed.

Assisted-by: Codex (GPT-6)
@Prime1997

Copy link
Copy Markdown
Collaborator Author

Failed interactive integration result for d54d80e1bc9d070cbec4a619abb5f4b89880b2f5, containing this PR's change together with the other memory/removal repairs. This was not a standalone test of 2156e42d6e6a69878539b12641a7dfe52556368a and does not establish which change caused or prevented a symptom.

  • RTX 3060 Ti 8 GiB, 32 GiB system RAM, release, about 402 seconds with 126 read-only monitoring samples. XCL ended the title itself with 0x887a0005 (DEVICE_REMOVED); no external stop or automated inputs.
  • Peak process commit: 22,994 MiB; peak resident process-tree RAM: 15.79 GiB. Peak DXGI local usage: 6,839 MiB; all 196 console memory lines were below their simultaneous local budget, with minimum headroom 218 MiB. Sampling cannot rule out a transient overrun.
  • Last positive presentation interval was observed around 173 seconds. Audio/diagnostic activity continued during the later rendering stall.
  • DRED state was UNKNOWN. Both page-fault output and breadcrumbs returned 0x887a0004 (unsupported), so there is no reliable GPU fault location. System commit still had 34,764 MiB headroom at removal; no out-of-memory result was established.

The command-pool log reports 3,471 spare lists retired, 38 parked, 25 allocator owners, 35 alternate allocators put aside (9 idle), and zero allocators retired. Object reclamation is observed; a byte saving or full RAM-growth repair is not established.

This run does not justify merge approval or a claim that RAM growth/device removal is fixed. Full standalone validation and matching main/head smoke reports remain outstanding. No builds or synthetic GPU tests ran during gameplay. Logs, hashes, counter samples and source/installed-data preservation checks are retained locally.

AI use: OpenAI Codex (GPT-6) launched the prepared candidate at the user's request, monitored existing logs and read-only counters, and prepared this report; a separate Codex agent reviewed the log evidence.

Optional contributor/test coordination: https://discord.gg/gK3y7WRRY

@kole07139

Copy link
Copy Markdown

Test report for head 2156e42d. Two existing alloc_pool tests fail on this head and pass on its base.

  • Library tests: 1773 passed, 8 failed, 28 ignored. Beyond the base's 6, these two fail 3 of 3 when run alone; on 54225f58 they pass 3 of 3 alone:
    • hle::d3d12x::alloc_pool::tests::a_recording_outlives_the_reset_of_the_titles_allocator: alloc_pool.rs:1028, "the allocator put aside is free again" (left: 2297796011296, right: 2297796013056).
    • hle::d3d12x::alloc_pool::tests::ended_recordings_keep_their_memory_until_the_gpu_passes_their_allocator: alloc_pool.rs:913, left: (Some(0), [x+1, x]), right: (Some(0), [x+1, x+1]), so the second reset does not get the spare again.
  • The four new tests pass: idle_reclaim_waits_for_binding_retirement_and_keeps_live_owners, returning_to_primary_keeps_the_alternate_until_reset_succeeds, device_removal_is_not_allocator_completion, only_finished_aged_spares_leave_the_pool.
  • A possible reading, from the diff only (not instrumented): move_list now keeps the old backing in retiring until its binding blocks are retired, and Backing::free requires retiring to be empty. Both tests move a list to another allocator and then expect the first one to be free again, without driving that retirement.

Tested: NVIDIA GeForce RTX 3070 8 GB (driver 617.42, wave32), Intel i9-9900K, 32 GB RAM, Windows 11 Pro N 26200, rustc 1.99.0, DXC 1.8.2502.11, debug. Each head was tested alone, with its own target directory, on its base nvidia-dev 54225f58. The library tests were run as cargo test -p xcl --lib --no-fail-fast -- --test-threads=4 --skip a_refused_gpu_upload_segment_becomes_custom. That one test is left out because the library test binary stops at its fail-stop (0x7C10003), as throny reported on #3041, with or without this PR; alone it passes. On the base the same command gives 1771 passed, 6 failed, 28 ignored. The 6 failures (placed_title_textures_share_vram_and_preserve_pixels, three stream_recheck_*, d32s8_targets_take_their_own_size_of_video_memory, gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark) are the base's own and are not repeated below.

I also merged the four heads #3122–#3125 together on 54225f58 (only README.md conflicts, plus the two new tests of #3123 and #3125 at the same place in sparse.rs; both kept). On that tree cargo test --workspace --no-fail-fast -- --test-threads=4 gives: library binary stopped at the same fail-stop; the other test binaries 132 passed, 0 failed, 20 ignored. The library command above: 1779 passed, 9 failed, 28 ignored, that is the base's 6 plus the 3 named below.

Not tested: a title run or smoke run of this head, a release build, AMD and Intel GPUs.

AI use: Claude Code (Claude Opus 5.5) ran the merges, builds and tests, and wrote this report.

@jeroenhaentjens

Copy link
Copy Markdown
Contributor

Standalone Windows game-load test of this PR head 2156e42d6e6a69878539b12641a7dfe52556368a on a Quadro RTX 3000 (5,955 MiB VRAM), 32 GiB RAM, Xbox Series X profile, GTA VI 1.0.2.1. Release binary SHA-256 4EAD064B326C46E6EB8489B7112270B5ED3E9C05E29885D9D6F1080A2BA2F604.

The title reached PLAYER1, accepted input, played the intro and began the illustrated world-loading screen. With XCL_ACTIVITY=1, the command-pool log reached 4 spare lists retired, 0 allocators retired (11 parked, 5 alternates put aside). At 161 seconds of host execution, XCL logged 23,044 MB of process commit, 6,944 MB of target pages and 10,948 MB of local video memory against a 5,187 MB DXGI budget. It reported 37,949 textures holding 11,498 MB of pages counted by texture ownership (shared pages can be counted more than once). The external guard closed the test when free physical RAM fell below 3 GiB. The world was not observed.

This was an isolated profile with a cold candidate DXIL cache, XCL_PREPARE_GRAPHICS=0, 16 GiB Windows page file, 1080p/60 requested, 16,667 µs host frame interval and network disabled. A synthetic nonmatching pipeline key was used in this test cache to bypass the optional startup precompile, so the runtime had to compile pipelines on demand. These conditions differ from the prior warm-cache combined-PR run, and this is not a matched main/head speed comparison. It establishes that the standalone head executes the retirement path but does not get this machine through world loading within its RAM guard. No merge approval is implied.

OpenAI Codex built the standalone head, ran the title, recorded process memory and checked the activity log.

@KDenKC

KDenKC commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@Prime1997 a whole-suite run of your head on an RTX 3090 against its base on the same machine: two existing alloc_pool tests fail on the head and pass on the base.

Tested: 2156e42d and its base nvidia-dev 54225f58.

  • RTX 3090 24 GB, NVIDIA 621.24, i7-10700T x8 (a VM with the GPU passed through), Windows 11 26H2 (26300.9974), Rust 1.99.1 (stable-x86_64-pc-windows-msvc), debug, no XCL_* set.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment --skip uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window (the three end the lib test binary on 621.24, at the base too): base 1,900 passed, 7 failed, 48 ignored; head 1,902 passed, 9 failed, 48 ignored.
  • New on the head:
    • alloc_pool::tests::a_recording_outlives_the_reset_of_the_titles_allocator: alloc_pool.rs:1028, "the allocator put aside is free again";
    • alloc_pool::tests::ended_recordings_keep_their_memory_until_the_gpu_passes_their_allocator: alloc_pool.rs:913, assertion left == right (left (Some(0), [..])).
  • They fail the same way with only their group running (cargo test -p xcl --lib -- alloc_pool::tests --nocapture --test-threads=1: 10 passed, 2 failed), and pass on the base in the full run. So not a full-run effect.
  • The other 7 failures are the base's own on this VM: 4 title_textures (one 0x8007000E in the full run and PoisonError from it), 2 vram 0x8007000E, e2e test_title_runs_and_game_folder_is_untouched.

Not tested: a title run; a release build; AMD / Intel.

AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.

@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the alloc_pool group at 2156e42d on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib -- alloc_pool::tests --test-threads=1
10 passed; 2 failed; 0 ignored; 0 measured; 1798 filtered out      (exit 101)

The two failures are the same ones reported in the thread on RTX 3070 and RTX 3090, reproduced here on a third NVIDIA card:

  • hle::d3d12x::alloc_pool::tests::a_recording_outlives_the_reset_of_the_titles_allocator
  • hle::d3d12x::alloc_pool::tests::ended_recordings_keep_their_memory_until_the_gpu_passes_their_allocator

I am reporting the measured outputs, not attributing the cause. The four new tests in this group pass. I did not run a title, a paired smoke run or the full workspace suite.

Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@andrewDoing

Copy link
Copy Markdown
Contributor

I checked the proposed explanation for the native a_recording_outlives_the_reset_of_the_titles_allocator failure on RTX 5070 / NVIDIA 616.92 at 2156e42d6e6a69878539b12641a7dfe52556368a. The primary allocator was reusable after the same GPU work when the fixture ran the binding retirement step used by the normal list reset.

After moving the recording to the alternate backing Old primary still marked retiring Primary reused at next allocator Reset Completed queue fence
Existing fixture sequence, calling alloc_pool::reset_list directly Yes No 3
Same sequence plus bind::reset(list, alternate, 0) after successful list reset No Yes 3

Both fresh processes executed the three native queue submissions and reported a healthy device. The test observed the old backing's retiring marker before the binding reset in both cases. There was no presentation and no wait for a background sweep. Two focused controls passed, zero skips.

This points to a specific fixture change: exercise the successful list-reset lifecycle (or pair the direct helper call with its binding reset) before asserting reuse. list_x::reset_pc_inner already calls bind::reset after a successful native reset. The fixture used a real command list and allocator with empty binding payloads. It did not run the title wrapper, the background trim thread, a retail title, or the other failing test ended_recordings_keep_their_memory_until_the_gpu_passes_their_allocator.

AI use: OpenAI Codex (GPT-6) prepared and ran the test-only controls and wrote this report.

@Prime1997

Copy link
Copy Markdown
Collaborator Author

Closing as superseded on main. This was written against nvidia-dev. After the move to main (#3203) its allocator half no longer applies: main already retires spare recordings and reclaims idle command allocators in its own design (31930d8, 8e7b566), and alloc_pool.rs there has been rewritten since, so this branch conflicts across six files.

The one part main does not have is releasing idle spare command lists before their wrapper goes. That is left for a separate small PR against main with a played run behind it; #2138, #2707 and #3110 work in the same area.

Checked and closed with Claude Code on Prime's behalf.

@Prime1997 Prime1997 closed this Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants