Repository navigation
D3D12.X: a sparse pool retired a moment ago is taken back (#913) - #923
Conversation
Freeing the last tile in use of a 64 MiB pool retires the pool for at least 2 s; the next tile allocation found the free list empty and made a new heap. A free / alloc loop thus made a new pool each time: #913 counted 288 pools and about 18 GB asked of a 12 GB card in one test. take_tile now takes back the most recently retired pool before creating a heap. Its tiles are flagged for clearing, as freed tiles of a pool in use already are when they are reused at once. Measured on an RTX 5080 16 GB, peak video memory during `cargo test -p xcl --lib -- --test-threads=4` (one run each): main 09940bb 15816 MiB with 3 failed tests (the #718 cubemap check and two poisoned-lock follow-ons); with this change 3488 MiB, 0 failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
On a 12 GB RTX 5070 Ti Laptop GPU (Windows, driver 621.24), this change reduced peak device-wide VRAM use by about 9 GiB in the debug library suite. Two runs per commit, in base → PR → PR → base order. I built both clean worktrees before measuring and sampled
Idle samples before the runs were 899–920 MiB. The three failures in the first base run were the cubemap reuse check and the two tests that subsequently saw a poisoned lock. The second base run passed at the higher peak. This confirms the memory reduction on a 12 GB card. Retail world loading and per-process residency were outside this measurement. OpenAI Codex (GPT-6.2 Astra) assisted with verification. |
|
Tested on AMD under Linux / Wine: it fixes #913 there too. Video memory went from the full 16 GB card to ~2.3 GB. Tested
Not tested: the head rebased onto AI use: T3 Code (Claude Opus 5.5) built both trees, ran the tests and wrote this comment from the logs. The runs are real, on the hardware above, and I checked the report before posting. |
|
Merged (6bac4b4). Checked on an RX 9070 (RDNA4) on main 6bac4b4 together with #923 and #849: |
Fixes #913.
Freeing the last tile in use of a 64 MiB sparse pool retires the pool for at least 2 s (
retire_free_pools); the next tile allocation found the free list empty andtake_tilemade a new heap. A free / alloc loop therefore made a new pool every time: #913 counted 288 pools and about 18 GB asked of a 12 GB card in one test (a_freed_block_is_decommitted_before_its_address_is_reused), and lib test runs on 12 GB cards fail withE_OUTOFMEMORY. A title that frees and allocates the same way gets the same growth.take_tilenow takes back the most recently retired pool before it creates a heap. Its tiles are flagged for clearing (reused), as the freed tiles of a pool in use already are when they are handed out again at once, so this is no less safe than the existing reuse.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:take_tiletakes a retired pool back first; the pool registration both paths share isadd_pool.a_pool_retired_a_moment_ago_is_taken_back– a tile freed and taken 8 times in a row gets the one retired pool back each time (flagged for clearing) instead of a new heap. It fails without the change (a new, unflagged heap comes back).Tested
stable-x86_64-pc-windows-msvc, debug, DXC 1.9.2602.17cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on this branch: 717 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware; noXCL_SAMPLE_*setnvidia-smi, sampled every 0.5 s) duringcargo test -p xcl --lib -- --test-threads=4, one run each:main09940bbmain's failures:placed_title_textures_share_vram_and_preserve_pixels(the #718 cubemap check), thentransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memoryon its poisoned lock. That the cubemap failure comes from the memory pressure is not shown, only that it went with it here.Regression run
main:This PR:
A first pair of runs, made right after each build, did not compare:
main1618 frames / 16 414 MB, this PR 1488 frames / 21 586 MB (over the 125 % limit), its last 2-second samples at 3–4 presents. The two runs'XCL_ACTIVITYlines show why: both go through the same loading steps, and this PR's run reached them about 12 s sooner (the DirectStorage burst that takes target pages from 3.6 to 4.5 GB came at 44–46 s instead of 56–60 s), so its window ended in the next stage – 12 000 DirectStorage requests per 2 s, target pages to 6.6 GB – whichmain's never reached. At the same step the sparse pools this PR changes were the same in both (1 024 MB); the extra commit was in target pages (vram.rs). The pair above was made afterwards with warm caches for both builds, in the order main → this PR.Not tested
take_tile, next to this change, and aparkedfield toState, which the new test'sStateliteral would then need. Whichever lands second needs a small rebaseAI use
🤖 Generated with Claude Code