Skip to content

D3D12.X: a title allocator takes a free spare another one put aside - #2725

Draft
veyn-sudo wants to merge 1 commit into
xcl-dev:mainfrom
veyn-sudo:pr/share-spare-allocators
Draft

veyn-sudo wants to merge 1 commit into
xcl-dev:mainfrom
veyn-sudo:pr/share-spare-allocators

Conversation

@veyn-sudo

Copy link
Copy Markdown

When the title resets a command allocator while lists still hold recordings on its PC allocator, alloc_pool puts that one aside and goes on with another: one this title allocator put aside earlier that is free again, or a new one. A title that resets many allocators so makes a PC allocator for almost every one of them and keeps it, although others lie free. This lets a title allocator take a free spare of the same list type that another one put aside.

Part of #2688 (workstream 6: memory that grows in the world). Related: #2138 drops free spares beyond two per title allocator, and #2707 resets idle ones so their memory comes back. Both deal with spares already made; this makes fewer of them. #2707 also changes title_reset_in, so whichever merges second needs a rebase.

What is in it

  • crates/xcl/src/hle/d3d12x/alloc_pool.rs: title_reset_in looks for a free spare of the same type among the other title allocators' when it has none of its own, and takes it over (it then goes with this title allocator's forget). Never another title allocator's own allocator: that one goes with the title's Release. Test: a_free_spare_another_title_allocator_put_aside_is_taken (also: not one in use, not one of another type).

Tested

  • RTX 2070 SUPER (driver 617.14), i7-9700K, 32 GB, Windows 11 26300, Rust 1.99.0, debug for the tests, release for the title.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on ad9172c0: 1436 passed, 0 failed, 47 ignored; 25 SKIPPED lines (21 no wave64, 3 f16 forms refused, 1 no heap windows).
  • A retail title's world on a local tree (main + D3D12.X: unpin retired split segments from alloc_pool and guard title_list::release ABA #1453 + other open PRs, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1), with a temporary count of the spares: before, at 162 s, 315 title allocators had 327 PC allocators made, 287 of them free, and the process's non-local video memory grew 1.3 → 3.0 GB in 40 s. With this, 282 made at 191 s (flat after 160 s), non-local memory flat at about 2.6 GB from 160 s on, and the run went from 169 s to 194 s before the memory guard stopped it.

Regression run

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1556 (PresentX 1556)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14673 MB

this PR:

xcl-smoke v1
commit: ad9172c015a8b33aa90ca002704ea4d3db212b40
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1585 (PresentX 1585)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14372 MB

Not tested

AI use

  • Claude Code with Claude Opus 5.5 wrote the code and the test, ran everything on my PC and wrote this description.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WStEFektfHt5AEbK6Wupac

A title that resets many allocators while lists hold their recordings made a PC allocator for
each and kept it: in a retail title's world 315 title allocators had 327 made, of which about 290
were free, and the process's non-local video memory grew with them, 1.3 to 3 GB in 40 s. A title
allocator with no free one of its own now takes one of the same type that another put aside (never
that one's own allocator, which goes with the title's Release).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WStEFektfHt5AEbK6Wupac
@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 verification of PR #2725 at ad9172c015a8b33aa90ca002704ea4d3db212b40 (exact parent origin/main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)

Targeted RTX 4060 release unit tests (ad9172c0)

  • cargo test --release -p xcl --lib hle::d3d12x::alloc_pool::tests::a_free_spare_another_title_allocator_put_aside_is_taken -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::alloc_pool:: -- --test-threads=4: 5 passed, 0 failed, 0 ignored (0.22 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::list_x:: -- --test-threads=4: 40 passed, 0 failed, 0 ignored (0.70 s, 0 skipped, exit 0).

Observations

  • Cross-allocator spare reuse in title_reset_in passes the new regression test (a_free_spare_another_title_allocator_put_aside_is_taken) and all 45 targeted alloc_pool:: + list_x:: tests cleanly in --release on this RTX 4060 host.
  • Quiet 60 s retail smoke (XCL_ACTIVITY=1) ran cleanly (exit: 0x0, 1582 frames shown, 60 60 60 steady-state presents per 2 s, 0 device removals, 0 crashes, 14008 MB peak commit vs parent b49be183's 14018 MB / 1518 frames; steady-state VRAM 6116 MB local / 4685 MB non-local at 58.2 s).
  • During this 60 s no-input menu/intro window, the title logged 4 reset-while-busy swaps (14.9..18.8 s, ending at 4 made, 4 put aside now and 214 blocks held for 214 allocators), with no allocator errors or stalls.

Paired 60 s RTX 4060 smoke (b49be183 vs ad9172c0)

Parent origin/main (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2725 head (ad9172c0):

xcl-smoke v1
commit: ad9172c015a8b33aa90ca002704ea4d3db212b40
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1582 (PresentX 1582)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14008 MB

Limits of coverage

  • Full workspace test suite was not re-run on ad9172c0 (only targeted alloc_pool:: and list_x:: release tests plus paired quiet 60 s smoke).
  • The quiet 60 s no-input menu/intro smoke only triggered 4 reset-while-busy allocator swaps (4 made, 4 put aside), so it verifies zero runtime regression rather than long-session world-load non-local VRAM reduction under high allocator churn (cross-allocator spare reuse itself is exercised by a_free_spare_another_title_allocator_put_aside_is_taken).
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit tests and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, log figures, and smoke blocks were taken directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) verification of exact PR head ad9172c015a8b33aa90ca002704ea4d3db212b40 on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1434 passed, 2 failed, 47 ignored (8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1 heap_window_out_of_memory_falls_back_to_the_switch_form no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • The new test hle::d3d12x::alloc_pool::tests::a_free_spare_another_title_allocator_put_aside_is_taken passed.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3) are pre-existing on unmodified main on this RX 9060 XT / driver 32.0.31044.16.
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: ad9172c015a8b33aa90ca002704ea4d3db212b40
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1617 (PresentX 1617)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18716 MB

(Compare against main b49be183 on this machine: 1603 frames, 18576 MB peak, 0 device removals, 0 crashes.)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.

bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
A retail world run measured hundreds of free PC allocators stranded in separate title-allocator namespaces while non-local memory kept growing. Let an allocator without an idle spare take a same-type spare from another namespace before creating another native allocator.

Fence probes run outside the pool lock. Exact backing snapshots and donor reset tokens reject concurrent use or an unlocked native Reset, then the candidate is transferred and claimed through the requester's normal reset generation. Adapted from PR xcl-dev#2725.

The Windows GNU cross-target library/test check passes; native Windows tests and smoke were unavailable.

Assisted-by: Codex (GPT-5.6-sol)
@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
A retail world run measured hundreds of free PC allocators stranded in separate title-allocator namespaces while non-local memory kept growing. Let an allocator without an idle spare take a same-type spare from another namespace before creating another native allocator.

Fence probes run outside the pool lock. Exact backing snapshots and donor reset tokens reject concurrent use or an unlocked native Reset, then the candidate is transferred and claimed through the requester's normal reset generation. Adapted from PR xcl-dev#2725.

The Windows GNU cross-target library/test check passes; native Windows tests and smoke were unavailable.

Assisted-by: Codex (GPT-5.6-sol)
@jennydeth

Copy link
Copy Markdown

Windows / NVIDIA results for ad9172c with the retail title (1.0.2.1) on an RTX 3060 12 GB.

Regression run (default settings, 600 s)

main b49be18:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 2047 (PresentX 2047)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 35859 MB

This PR, ad9172c:

xcl-smoke v1
commit: ad9172c015a8b33aa90ca002704ea4d3db212b40
gpu: NVIDIA GeForce RTX 3060
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 1951 (PresentX 1951)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 35596 MB
  • This PR has 1,951 frames against main's 2,047 (95 %) and peak commit of 35,596 MB against 35,859 MB (99 %), with no removal and no crash in either. Neither run reaches the world: presents stop at 100.3 s on main and at 96.0 s with this PR, while big compute programs are still compiling.
  • Allocator counter (allocator resets so far with recordings still held or on the GPU – another PC allocator took its place (N made, …)): at 32 resets, 23 made with this PR against 20 on main in the 600 s pair. In the direct DXIL runs, 64 made at 64 resets with this PR against 31 at 32 on main today. So in these runs nearly every reset made a new PC allocator, and I can't see the spares of other allocators being taken. One run each, and the line only says how many were made, not where a reused one came from.
  • Direct DXIL (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_DRED=1, warm caches, 900 s): the device was lost (0x887a0005, NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #2403) at 114.2 s, last present at 110.3 s, with the same DRED line as on main (page fault at GPU VA 0x0; allocations there: []; recently freed: []). Three b49be18 runs today with the same switches lost it at 110.6, 211.2 and 216.0 s, so one run can't tell this PR apart from main there.

Tested

  • NVIDIA GeForce RTX 3060 12 GB, driver 32.0.16.2101 (32-lane waves only); Ryzen 5 5600X; 32 GB RAM; Windows 11 Pro 10.0.26300.9974; Rust 1.100.0 (stable-x86_64-pc-windows-msvc); release; DXC 1.9.2609.5.
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4 on ad9172c: 1436 passed, 0 failed, 47 ignored. SKIPPED (29): 21 × no wave64; 3 × per-lane form refused; 3 × no D3D12 debug layer / d3d12SDKLayers.dll; 1 × no heap windows; 1 × pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache).
  • Retail title 1.0.2.1, scripts/smoke.ps1 -Game <folder> (XCL_NETWORK=0), the same scripted pad presses into the story load in every run; XCL_FRAME_DUMP=300 in the pair, 100 in the direct DXIL runs. Every run was of a copy named xcl-noprofile.exe: this machine has xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590's 1 GiB shader-heap profile on xcl.exe, and a copy under another name does not match it.

Not tested: how often a spare comes from another title allocator (no log line for it); AMD / wave64.

AI use: Claude Code (Claude Opus 5.5) built the commit, ran the suite and the runs on my machine, read the logs and wrote this.

Osanchez pushed a commit to Osanchez/xcl that referenced this pull request Nov 26, 2026
Runs 4-6 on an RTX 5080 grew non-local video memory to 45 GB within a
minute of the first intro frames and ended in E_OUTOFMEMORY and a device
removal; run 7 with XCL_ALLOC_SWAP=0 stayed near 16 GB. The entry records
the cause and the user's decision to adopt xcl-dev#2725, xcl-dev#2549, xcl-dev#2581 and xcl-dev#2707
through the gate.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RbZY1Ag73eDeCUZHpW3is
Osanchez pushed a commit to Osanchez/xcl that referenced this pull request Nov 26, 2026
Commit:   1a3b698
Reviewer: Claude Code (Claude Opus 5.5), Opus worker, full read (findings)

Review findings, none stopping the merge: most new unit tests drive the
test-only copy title_reset_in, not the rewritten title_reset; xcl-dev#2725 must
be ported onto the new title_reset instead of merged; reset_list can
return E_FAIL after 5 s on a resetting backing.

Conflict in crates/xcl/src/hle/d3d12x/alloc_pool.rs (reset_list): our
side has the telemetry_list_reset call, the PR replaces the bookkeeping.
The PR's bookkeeping is taken and the telemetry call is kept after every
successful native Reset, also on the PR's new early-return path.
@throny

throny commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Test report: in the world on an RTX 4080 16 GB. No harm; no measurable change on this card.

Tested

at the end of the run without (3 runs) with (2 runs)
blocks held / allocators 107 / 61, 120 / 56, 161 / 66 107 / 52, 130 / 60
non-local video memory 5,469–5,625 MB 5,582–5,593 MB
committed 39.9–40.4 GB 38.6–40.7 GB
  • So in these windows the blocks held and the non-local memory are the same with and without; the growth the PR is about did not show up on this card within 5 minutes of world (its non-local share is steady at about 5.5 GB, 4.1 GB of it the UMA window), so this is a "does no harm" report, not a confirmation of the saving.
  • The longer run ended with the device removal this card has in about half of its world runs on this branch (see [OFFICIAL] Swarm: RAM and VRAM use down, towards stable 30 FPS on AMD and NVIDIA #2688); the short one was ended by my own guard.

Not tested

  • A run long enough, or on a card with less RAM, to show the growth; the suite; AMD.

AI use: Claude Code (Claude Fable 5.2) ran this on the owner's machine and wrote the report.

@veyn-sudo

Copy link
Copy Markdown
Author

@jennydeth @throny thank you both. Your two reports agree, and they point at a gap in how I measured this.

The saving in the description (327 → 282 PC allocators made, non-local memory flat from 160 s) was measured on our local tree, which also has #1453. As the description says under Not tested, without #1453 the retired split segments keep their spares, so few of them are free for another title allocator to take. That fits what you both saw on main / nvidia-dev: about one new PC allocator per reset, and no change in blocks held or non-local memory.

The PR's log line also can't show whether a spare came from another allocator, so a run can't tell a take-over from a fresh allocator. I'm setting the PR back to draft until I have:

If it turns out to matter only with #1453, I'll stack it on #1453 and say so at the top.

AI use: Claude Code (Claude Opus 5.5) wrote this.

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.

5 participants