D3D12.X: pack sparse pool tile reuse into the fullest heap #2898
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2898"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by itsSio on 2026-11-26T22:17:23Z.
Part of #2688.
sparse.rsstored free sparse pool tiles in a flatVec<(u32, u32)>and poppedcoolingFIFO beforefree, scattering reuse across nearly-empty draining 64 MiB pools soretire_free_poolscould not reclaim them and splittingUpdateTileMappingsacross more heaps.This partitions free tiles by heap (
FreePools):reuse_tiledrains cooled tiles into their heaps and packs the fullest partially-used heap (1..POOL_TILES, lowest index on ties), leaving nearly-empty and all-free heaps untouched for retirement unless no partial heap has space.retire_free_poolschecks heap counts in O(pools), andbefore_execute_onpassesfree.has_empty_heap()toretire_dueso an all-free heap completed duringdrain_coolingretires even whencoolingis empty. Orthogonal to #2630.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs(+190/-29): per-heapFreePools, fullest-heapreuse_tile,free_heaps/retire_free_pools/retire_dueupdates, and unit testreuse_tile_packs_fuller_heaps_so_nearly_empty_pools_retire.Tested
32.0.16.1088), Ryzen 7 9800X3D, 32 GB RAM, Win11 26200,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug (release for smoke & A/B):cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1748 passed, 7 failed, 48 ignored, 27SKIPPED(21 no wave64, 3 wave32 per-lane f16/cvt refused, 2 no heap windows, 1pso_measurementdriver cache; all 7 pre-existing onaf2cecc4:texture_upload::testsx2,d3d12_mesh_stream,gpu_compute_e2e,gpu_two_pass_cache_e2ex2, intermittente2edriver log write).hle::d3d12x::sparse::tests: 61 passed, 0 failed, 1 ignored.XCL_ADAPTER=warp XCL_TEST_WARP=1):reuse_tile_packs_fuller_heaps_so_nearly_empty_pools_retire1 passed, 0 failed.XCL_DEVICE_TYPE=lockhart XCL_PREPARE=0 XCL_NETWORK=0 XCL_ACTIVITY=1, warm cache,af2cecc4vs8cf249e5): peak commit22042 -> 21818 MB(-224 MB), final commit20250 -> 20144 MB(-106 MB), final local VRAM8159 -> 8093 MB(-66 MB), steady sparse pools5440 -> 5376 MB(-64 MB, slack855 -> 791 MB),UpdateTileMappings891 -> 736(-17.4%for 120k mapped tiles), frames5173 -> 5237,0removals/crashes.32.0.16.1088), Ryzen 5 5600X, 16 GB RAM, Win11 26200,rustc 1.99.1(stable-x86_64-pc-windows-msvc), DXC1.8.2502.11, debug:cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1749 passed, 6 failed, 48 ignored, 30SKIPPED(same 6 pre-existingaf2cecc4failures; 0 new failures).XCL_ADAPTER=warp XCL_TEST_WARP=1):reuse_tile_packs_fuller_heaps_so_nearly_empty_pools_retire1 passed, 0 failed.Regression run
Not tested
AI use
Ran via Samaritan:
FreePoolsand its unit test, ran the paired RTX 5080 A/B measurement, dual-PC test suites, WARP checks, smoke run, and initial PR prep/coordination.sparse.rs(PASS), live upstream duplicate and mergeability audit againstnvidia-dev(eae01502), andscripts/pr_check.py/URL verification.Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-26T22:37:12Z.
I compared
8cf249e5with its directnvidia-devparentaf2cecc4on Microsoft WARP. I populated two 64 MiB sparse heaps, one with 1,024 tiles and the other with two. I released a tile from each, waited for fence retirement and the normal cooling interval, then mapped and wrote a new tile.Both revisions matched all 67,239,936 initial bytes and passed five full 65,536-byte tile readbacks across reuse and retirement. The difference came at allocation: the parent reused the draining heap and retained two active slots. The PR reused the denser heap, allowing the draining heap’s active slot to retire and leaving one. This checks data preservation and pool bookkeeping. I did not measure deferred heap destruction, physical VRAM savings, or a title workload.
I used Codex GPT-6.2 Sol for the fixture and WARP runs. A separate GPT-6.2 Sol agent independently checked the fixture, artifacts, and recorded results. Codex GPT-6.2 Astra wrote this comment.
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T22:37:56Z.
AMD run for the Not tested line.
Tested: pass, head
8cf249eapplied on its basenvidia-deveae0150, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X.cargo test -p xcl --lib -- hle::d3d12x::sparse --test-threads=4 --nocapture:reuse_tile_packs_fuller_heaps_so_nearly_empty_pools_retireamong them.nvidia-devwithout the PR: 62 passed, 0 failed.The sparse tests that need a device make it with
D3D12CreateDevice(None, ..), so they ran on the first adapter, the RX 9070 XT here.Not tested: Series X/S sweeps in a title, stacking with #2630, Intel, Linux / Wine.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-26T22:39:41Z.
Ran the sparse-pool reuse tests at
8cf249e5on 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.
The new
reuse_tile_packs_fuller_heaps_so_nearly_empty_pools_retiretest passes, as do all 61 tests in thesparsemodule (one ignored). These are CPU-side pool bookkeeping tests; noUpdateTileMappingswas issued on the adapter. The PR has no comments yet and the author tested on an RTX 5080, so this adds a second NVIDIA datapoint with driver 32.0.16.2124.Not tested: the release smoke and A/B frame times from the description, a paired 60 s smoke run, the full workspace suite and its seven known failures, AMD and Intel GPUs, native wave64 hosts, Wine, 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.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T23:44:07Z.
Independent desktop NVIDIA (natural 8 GB VRAM) verification of PR #2898 at head
8cf249e55603a3e6dc4c34aa9e1b4fec5077d997(1commit; exact parent & merge-base onnvidia-dev:af2cecc40886a8682ecf3267f5328c6dc4b66ad7).Environment
7956 MiBreported by D3D12,7022 MBDXGI local video memory budget observed in this run), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
8cf249e5)cargo test --release -p xcl --lib reuse_tile_packs_fuller_heaps_so_nearly_empty_pools_retire -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1648 filtered out× 3 (0.00s,0.00s,0.00s)cargo test --release -p xcl --lib hle::d3d12x::sparse::(3 consecutive runs)61 passed; 0 failed; 1 ignored; 1587 filtered out× 3 (2.32s,2.30s,2.19s;early_commit_timingis#[ignore])cargo build --release -p xcl --bin xcl1m 25s, exit0)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base on
nvidia-dev(af2cecc40886a8682ecf3267f5328c6dc4b66ad7, cached baseline on the same machine):PR #2898 (
8cf249e55603a3e6dc4c34aa9e1b4fec5077d997):Runtime log observations (
xcl.log)9384log lines,0[ERROR]/ device-removal / panic lines.sparse windows timing:entrywrite-watch 468 ms (528988 dirty pages), lock wait 10 ms, chunk scan 48 ms, upload 193 ms (39181 runs, 30367 of them in 235 dispatches).19099 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14925 MB committed by the process; video memory 6181 MB local, 4778 MB non-local; sparse pools 896 MB (838 MB mapped); video memory budget 7022 MB.Limits of coverage
reuse_tile_packs_fuller_heaps_so_nearly_empty_pools_retire, 3/3) and the fullhle::d3d12x::sparse::suite (61/0/1, 3/3,early_commit_timingremained#[ignore]) passed on RTX 4060.title: 29640639stayed atsparse pools 896 MB (838 MB mapped)and confirms clean steady-state behavior onnvidia-devwithout exercising multi-minute world streaming churn or measuring long-run sparse pool retirement counts; frame-count and peak-commit deltas vs. the cachedaf2cecc4baseline reflect normal single-run startup/worker variance and are not attributed to this PR.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T00:17:32Z.
Tested: Clean
8cf249e55603a3e6dc4c34aa9e1b4fec5077d997, Windows 11 build 26200, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, debug.cargo test --locked -j 2 -p xcl --lib --no-run; ran exacthle::d3d12x::sparse::tests::a_tile_given_back_is_not_used_again_before_it_cooledanda_pool_goes_once_its_last_tile_cooled_with_nothing_parkedwith--test-threads=1 --nocapturein separate lock acquisitions. Both passed, 0 failures, ignores or skips. A default-device D3D12 probe confirmed the hardware A770 for each run. The fixtures exercised reuse after cooling and retirement of an empty pool on a later submit.Not tested: Two-heap packing on Arc, physical VRAM savings, deferred heap destruction, full suite or retail smoke.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran and reran the checks and wrote this report.Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T04:49:20Z.
Independent 180 s paired check on NVIDIA GeForce RTX 3060 Ti (8 GB) (
8cf249e5merged withnvidia-devecc0bb57, Series S /lockhartprofile, identical warm cache snapshot).Setup
621.40,nvprofileshader heap 2048 MB), DXC1.9.2602.17.XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_PSO_WAIT_MS=50 XCL_GFX_PSO_WAIT_MS=200 XCL_CS_PSO_WAIT_MS=50 XCL_PREPARE_GRAPHICS=0 XCL_DRED=1+XCL_PRESS_AT(18:A..74:A).Results (180 s paired runs)
PresentX)nvidia-dev(ecc0bb57)#2898(8cf249e5+ecc0bb57)Not tested: longer runs past 180 s, Series X (
anaconda) profile, AMD GPUs.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T05:49:07Z.
Review: COMMENTED
pop_packedranks heaps by tiles available for immediate reuse. That makes a draining heap look full while most of its freed tiles are still cooling. In a CPU-only harness using the exactreuse_tileandfree_heapscode, heap 0 had one reusable tile and 1,023 cooling tiles, while heap 1 had two reusable tiles and 1,022 live tiles. The allocation chose heap 0 and left neither heap eligible for retirement after cooling. Taking an available tile from heap 1 would have let heap 0 retire at that point. Could the ranking account for cooling tiles when estimating occupancy while still handing out only reusable tiles? The existing packing test cools both heaps before allocation and would benefit from a case with different cooling ages. Heap ranking · Cooling and retirementAI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source, ran the CPU-only fixture, and drafted this comment. No GPU or title was used.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T22:54:22Z.
merge-check
base: d1be8103 (
nvidia-dev)head: 8cf249e5
merge: Clean trial merge into this
nvidia-devwithgit merge --no-commit --no-ff.build:
cargo build --workspace --lockedpassed.tests:
cargo test --workspace --locked --no-fail-fast -- --test-threads=4on the unmodified merge: 1,824 passed, 9 failed, 48 ignored; 27 GPU skip notices. The same command on clean base: 1,823 passed, 9 failed, 48 ignored; 27 GPU skip notices. All nine failing test instances matched, including the repeatedsplit_compute_prefers_the_offline_whole_pipelineandtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsinstances. The PR adds one passing test. A new test against the productionreuse_tile/free_heapscode failed in isolation on the unmodified merge: 0 passed, 1 failed, choosing heap 0 where heap 1 would let heap 0 retire after cooling.review: Not yet. This confirms the earlier cooling-age finding in the production code. Heap 0 has one reusable tile and 1,023 still cooling; heap 1 has two reusable tiles and 1,022 in use.
pop_packedranks only reusable tiles, picks heap 0, and prevents its retirement afterCOOL. A local candidate tracks cooling tiles per heap at the two production enqueue sites and the dequeue, then ranks only heaps with a reusable tile byreusable + cooling(fewest means most tiles still in use). It prefers a partially cooling heap over an immediately retireable all-free heap on a tie. This keeps selection O(number of heaps) and updates counts in O(1) per tile; it does not scan the cooling queue on each allocation. The new production-code regression and all sparse tests passed with it: 68 passed, 0 failed, 1 ignored, 0 skipped. The candidate full suite recorded 1,825 passed, 9 failed, 48 ignored; 27 GPU skip notices, with the same nine base failures. The existing cooling test's exact tile order changes under this policy; the candidate keeps exact assertions for the new order and its minimum cooling time.performance: No title A/B or allocation timing was measured in this check. The candidate preserves the PR's per-allocation heap scan and adds constant-time cooling bookkeeping; its effect on frame time and total video memory remains unmeasured here.
verdict: not yet: account for cooling tiles in the selection and add a production-code regression before merging.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti 12 GB / NVIDIA 621.35, rustc 1.99.1 MSVC, DXC 1.8.2502.11. OpenAI Codex (GPT-6.2 Sol) ran the tests, checked the change, and wrote this report; Codex (GPT-6.2 Astra) independently reviewed the allocator and candidate invariant.
Focused negative control:
cargo test -p xcl --lib reuse_tile_counts_cooling_tiles_when_packing_heaps --locked -- --nocapture --test-threads=1on the test-only edit failedleft: Some(0), right: Some(1); the candidate selected heap 1 and passed. This is a local, uncommitted candidate. A clean-head title smoke and memory A/B of the candidate remain to be run after an author revision.Local candidate correction and regression diff
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T23:42:22Z.
merge-check claim
head:
8cf249e556Imported from ivall/xcl. Originally posted by throny on 2026-11-28T00:04:34Z.
merge-check
base:
d1be8103(nvidia-dev)head:
8cf249e556merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1825 passed, 8 failed, 48 ignored (27 SKIPPED lines). The 8 failures are the base's own on this GPU, the same six names with and without the PR (async_compute_pso_registers_real_pso_and_not_standin, split_compute_prefers_the_offline_whole_pipeline, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, two texture_upload tests; #2771 and #2788 fix three of them). Base alone: 1824 passed, 8 failed, 48 ignored.
review: none blocking. Open from the thread and still on this head: pop_packed ranks heaps by reusable tiles only and ignores cooling ones (an efficiency point, not correctness). The existing test about a freed tile cooling first still passes, by the heap-index tie-break, but its 'oldest first' description no longer matches. The cooling retain was removed safely (free pools are drained first now). For whoever merges: #3039 conflicts with this PR in text and in meaning in sparse.rs (its system-memory tiles must not go into the new FreePools: the per-heap table would be resized to a huge index); merge this first and rebase #3039 on it.
performance: default path: each tile taken costs a scan over the heaps under the sparse lock plus a drain, and each submit one more scan; retiring free heaps more eagerly could cause heap create / destroy churn (not measured). A tester in the thread measured more frames and less commit; not re-measured here.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).