startup: opt-in release of upload ring chunks at a fenced submit #2949
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2949"
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 R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-26T22:45:47Z.
Title: startup: opt-in release of upload ring chunks at a fenced submit
Change
Fixes #ISSUE (after #2849 the upload ring still runs out in the post-load animation). Refs #2837, #2849.
X2W_D3D12_RING_RELEASE_AT_SUBMIT=1(opt-in): a closed command list stops holding its upload ring chunks once its submit is fenced, instead of holding them until Reset. The queue fence still keeps the chunks from reuse until the GPU has passed it. Unset, the ring behaves exactly as onmain.upload_reservation.h:ReleasedUploadChunks,release_upload_chunks_at_submit,resubmitted_upload_chunks; chunk arrays sized for 512 MiB.d3d12_xs_device.cpp:note_submitsreleases each submitted list's holds after a signalled fence (no signal: nothing changes).queue_executeleaves that list out ofExecuteCommandListsbefore the execute (released_chunks_recycled, underdraw_lock+allocator_lock), counts and logs it (... were reused; refused, it is not executed); it stays refused until its Reset, and the other lists of the call still run.startup_list_resubmitstep 2). With the switch, such a resubmit after a chunk reuse is refused, so that list does not run. The mode suits titles that Reset a list before submitting it again; the main executable did so in every measured submit (0 of more than 500,000 over five runs).docs/startup-runtime.md;docs/experiments/startup-upload-ring-release-at-submit.md.discard_upload_chunksat the same call sites and #2864 areserve_upload_ringcaller; text conflicts only, whichever lands second.Verification
Windows 10 22H2, i7-4790K, RTX 3080 Ti (NVIDIA 32.0.16.1047) and WARP; dev and release; commit
33d31412on6ee878d8.35 tests per preset, run with the switch unset and set: 33/35 pass in each run. The two failures are
startup_list_resubmit_nodebug_hardwareandstartup_list_resubmit_nodebug_untracked_hardware(SegFault). Both fail the same way on unmodifiedmain6ee878d8on this host, with and without the switch.upload_reservation, newcheck_release_at_submit: release, fence guard, reuse, resubmit with one intact and one reused chunk, and the re-fence. Negative controls (local mutations): keeping the holds failsrelease: holds dropped; ignoring generations failsa resubmit finds chunk 1 intact and chunk 0 reused.startup_address_console_gate_ring_keep{,_release}_{warp,hardware}: list A uploads 32 × 16 MiB and is never Reset; a second list then draws payload 32 over the right half; A is submitted again, and the target is read back after that submit.startup_address_console_gate_ring{,_reuse},startup_slot133_heap_cap_capped), so they keep testing the default when it is set in the environment.bufferupload ring reservation refusedChecklist
docs/startup-runtime.md, experiment note)AI-assisted: the change, tests and this description were written with Claude; I ran the startup comparison.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T04:56:23Z.
Review: COMMENTED
The release-after-submit experiment has a correctness gap in the resubmit case documented by the fixture.
note_submitsdiscovers a recycled generation only afterExecuteCommandLists, and the resubmit fences only the intact chunks. The re-executed list can therefore fetch overwritten upload data, and the recycled chunk is also unprotected from later ring reuse while that draw runs. Please detect this before queue submission and either refuse the stale resubmit or retain/reconstruct the recorded bytes. The fixture should assert that the stale list did not execute with replacement bytes; logging the post-submit detection alone cannot establish that.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:14:57Z.
Review: COMMENTED
PR #2949 by @lukaslw-lab — startup: opt-in release of upload ring chunks at a fenced submit
What works
Issues
Recommendations
Overall
Well-architected memory optimization that cleanly separates the opt-in path. The generation-based tracking is elegant and the fence-guarding is correct. After the fence-failure cleanup fix, this should be solid.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-27T05:39:55Z.
Thanks, agreed: the post-submit report could not stop the stale execute. A stale resubmit is now refused before the queue submits it.
Change (
3fcd36fc+ docs8c183700, on top of a merge ofmain57f9e07f; no force-push)queue_executechecks each closed list in thelist_readyloop, withdraw_lockandallocator_lockheld, beforeExecuteCommandLists(released_chunks_recycled). A list whose released chunk was reused since its fenced submit is left out of that execute, the same way a list that is not closed is left out today. It is counted and logged (... were reused; refused, it is not executed) and stays refused until its Reset. The other lists of the call still run.note_submits, so no reservation can recycle a chunk in between.note_submitstherefore only sees intact chunks and fences them again. The recycled chunk is never read, so nothing is left unprotected.gate-ring-keep-release: the target is now read back after A's second submit. The check asserts the right half still holds payload 32 (A's last draw would put payload 31 there) and that the refusal was logged.gate_ring_keep{,_release}_{warp,hardware}+upload_reservation, releaseif (false && …))_release_warpand_release_hardwarefail on pixels:{'left': 32768, 'right': 32768} wrong pixels, found ['12e845ff', '23df7aff']; expected 03ff5aff left, 23df7aff right. The stale A ran: its payload 0 draw read the reused chunk and painted payload 32's colour (23df7aff) on the left, and its payload 31 (12e845ff) covers the rightupload_reservation,startup_list_resubmit.*,startup_address_console.*,startup_slot133_heap_cap.*,startup_null.*,startup_stream_draw.*), release + dev, switch unset and setstartup_table_alias_.*,startup_frame_copy_.*, …), release + dev, switch unset and setctest --preset <release|dev> --no-tests=error -j 1 -R '<filter>'withX2W_D3D12_RING_RELEASE_AT_SUBMITunset and=1.startup_list_resubmit_nodebug_hardware/_nodebug_untracked_hardware. They segfault identically on unmodifiedmainon this host (unrelated, not touched here).docs/startup-runtime.mdpassages now describe the refusal instead of the report. The switch row also states the commit cost (up to ~1 GiB at peak).Startup run repeated on
3fcd36fc(settings of the experiment note, 250 s, one build, only the switch differs):bufferupload ring reservation refusedloggedImported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T06:05:24Z.
Review: APPROVED
Independent integration review of
8c183700withmain6aa59440(e8e855c8locally). The recycled-generation check now runs beforeExecuteCommandLists, under both locks through submission and refencing. Only accepted lists reach queue execution and GPU-write bookkeeping. The pixel readback confirms that the rejected resubmission left both halves unchanged.ctest --preset <dev|release> --no-tests=error -V -R '^(upload_reservation|startup_address_console_gate_ring_keep(_release)?_(warp|hardware)|startup_stream_draw_warp|startup_table_alias_warp)$'passed 7/7 in Debug and 7/7 in Release/O2, with no skips. Windows 11 build 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, and WARP 10.0.26100.9818. The table-alias fixture used the debug layer and GPU-based validation and reported zero debug errors. The ring fixture ran with the debug layer off. The contributor’s broader matrix recorded two matching failures on its unchanged baseline.Hosted Windows, Linux Python and gfx1013 fixture checks are green. The hosted
/O2job was skipped and the local/O2run above passed. The matching issue is #2948.