Repository navigation
D3D12.X: skip the memory refresh for submits of flush-only lists - #3605
raylitebull wants to merge 5 commits into
Conversation
A retail title submits its queue's cache-flush list alone in about a tenth of its 50-60 submits a frame (a list recorded once at start: a sync with wait flags 0x700000 and a cache operation 0xc3c0/0xc380, FlushShaderCacheRangeX / FlushGpuCacheRangeX here). Every title submit pays title_textures::refresh_for, 6.4-8.9 ms of the 8.8-11 ms a submit on amd-dev (look, sparse lock, textures, scan, upload), though such a list reads and writes no memory. ReVIctory folds that list into the neighbouring submit with a title patch (submit_merge.rs; median 27.8 -> 29.0 fps, submitting thread 32-33 -> 29-30 ms a frame). Do it for any title: the console list object keeps a byte that is set when the list is made or Reset and cleared by the forwarder of every slot outside an allowlist (object methods, markers, FlushPipelineX, FlushGpuCacheRangeX / FlushShaderCacheRangeX). With XCL_FLUSH_SUBMIT_SKIP=1 a submit whose every list kept it goes without the look and the sparse and texture uploads; the queue still waits for the page mappings and XCL's uploads made so far, and owes the refresh until its next one, which a title Signal or SignalX on it runs first. The submit cost line counts these submits whether the switch is on or not. Not measured yet: off by default until it is run on hardware. Assisted-by: Capy (Claude Opus 5.5) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Test report (not a merge-check: draft, AI-written and posted by Foniass without a human check of each point. |
Review of the flush-only submit skip (#3605): the refresh a skipped submit owes was paid only at Signal / SignalX, so PresentX and CopyPageMappingsBatchX on the owing queue ran without it; another queue's refresh could take the owed pages and upload the textures on that queue, which the owing queue never waits for; and the owed refresh went through refresh_for, so its time counted as submit cost. Pay it in queue_dispatch before Signal, SignalX, PresentX, CopyPageMappingsBatchX and methods not modelled, through the plain refresh, counted on its own in the submit cost line. Not at a Wait or a query: they publish nothing and the queue's next ExecuteCommandLists refreshes anyway, so paying there would run two refreshes for one. While a queue owes one, other queues' texture uploads go to XCL's own queue, which every queue's refresh waits for. Nothing is locked with the switch off. A GPU test covers the debt and the full refresh with the switch off. Assisted-by: Capy (Claude Opus 5.5) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Test report (not a merge-check: draft, AI-written and posted by Foniass without a human check of each point. |
…kip off Second review of #3605: a queue released while it owed a refresh stayed in OWED, so every later direct-queue upload went to XCL's own queue for the rest of the run; refresh_once took OWED's lock on every refresh and a Wait looked the fence up with XCL_FLUSH_SUBMIT_SKIP off; and the owed refresh's parts went into the submit cost stages without its own time, so "rest" could go negative. forget_queue drops the queue from OWED. An OWING flag mirrors OWED being non-empty and is read before its lock, never set with the switch off; queue_dispatch checks the switch first. The owed refresh counts in the refresh stage too. The GPU test now runs the skip branch itself (refresh_for_as) and the payment at a queue call. The doc says why the uploads go to XCL's own queue while one is owed: the owing queue cannot wait for the refreshing one, which may wait for its fence. Assisted-by: Capy (Claude Opus 5.5) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Test report (not a merge-check: draft, AI-written and posted by Foniass without a human check of each point. |
Third review of #3605: a queue released while it owed a refresh kept it when its retirement failed (forget_queue never runs for a pinned queue), so DIRECT uploads went to XCL's own queue for the rest of the run; the owed refresh checked the debt before the refresh lock, so a submit on the same queue on another thread could pay it in between and the refresh ran twice; and its time was in the refresh stage but not in the whole, so "in all" no longer added up. The debt goes when the title releases the queue (retire_released_queue). The owed refresh checks it again under the refresh lock and counts its lock wait, refresh and whole in the submit stages. Which queue methods pay is a function of its own with a test; the GPU test also checks the upload target while a queue owes and keeps nothing owed if it fails. The doc says that those uploads are not ordered after the refreshing queue's earlier work, as a compute queue's are not. Assisted-by: Capy (Claude Opus 5.5)
|
Test report (not a merge-check: draft, AI-written and posted by Foniass without a human check of each point. |
Fourth review of #3605: the owed refresh had left refresh() for refresh_once, so with the memory report on its look was no longer sampled; and the submit cost line said its time was in the refresh stage, though its lock wait is in the lock wait and the whole is in the total of the ExecuteCommandLists averages. Sample its look as refresh() does. The module doc says that a refresh a submit left out counts in the stages as the submit's own, and the line says the owed time is in the stages before it. Assisted-by: Capy (Claude Opus 5.5)
|
Follow-up review (head 75b71bf, since d6175c8, diff read, not a merge-check; draft):
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
On AMD, amd-dev is limited by the thread that submits the title's work: ~19-28 title submits a frame at 8.8-11 ms each, 6.4-8.9 ms of it in
title_textures::refresh_for(b54c6d9, 9f9a9bc). ReVIctory found that a retail title submits its queue's cache-flush list alone in about a tenth of its 50-60 submits a frame and folds it into the neighbouring submit with a title patch (median 27.8 -> 29.0 fps). This PR does the title-agnostic version: a submit whose lists only flushed and synced skips the parts of the refresh that bring memory up to date for the GPU. BehindXCL_FLUSH_SUBMIT_SKIP=1, off by default.The idea and evidence come from ReVIctory (https://github.com/ReTerryDavis/ReVIctory, GPL-3.0-or-later),
crates/victory-loader/src/submit_merge.rsanddocs/title-patch-candidates.md§2. No code was ported.What is in it
title_list: the console list object keepsF_ONLY_SYNCS, set when the list is made (wrap) or Reset and cleared by the forwarder of every slot outsideSYNC_SLOTS.SYNC_SLOTSis ID3D12Object's methods (XAudio2: real Opus decoder via Windows MSOpusDecoder MFT #3–Olympus: harden media and package ingestion #8), the markers (XAsync: a failing Begin fails the call, and E_PENDING does not complete #56–VFS: moves through MoveFileWithProgressW are redirected too #58), FlushPipelineX (Wave64 console programs on GPUs with 32-lane waves only (NVIDIA) #67) and FlushGpuCacheRangeX / FlushShaderCacheRangeX (#131 / Add synthetic Cargo benchmark suite #132): slots whose XCL handler records a UAV barrier at most. ResourceBarrier, Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146 and newer-layout Fix D3D12 frame and texture handling #69 are not on it.only_syncs(list)is false for anything that is not a console list object. The byte is kept with the switch off too (one byte store a forwarded list call), so the log can show how many submits would qualify before the skip is tried.title_textures::refresh_for: for a submit with at least one list and every listonly_syncs, with the switch on, there is no look and no sparse or texture uploads. The queue still waits for the texture page mappings (vram::before_execute) and XCL's own uploads, under the refresh lock as before, and owes the refresh. What the CPU wrote and committed goes up at the next refresh.real::queue_dispatch: Signal, SignalX, PresentX, CopyPageMappingsBatchX, and methods not modelled), as a full refresh (refresh_once, under the refresh lock, its look sampled for the memory report), and counted on its own in the submit cost line. It is not paid at a Wait or a query: they publish nothing, and the queue's next ExecuteCommandLists refreshes anyway, so paying there would run two refreshes where there was one. While a queue owes one, other queues' texture uploads go to XCL's own queue, which the owed refresh waits for, so work on other queues that waits for a fence the owing queue signals finds what the CPU wrote before the skipped submit. That is the path compute queues' uploads already take; they cannot stay on the refreshing queue, because the owing queue cannot wait for it: the refreshing queue may itself wait for the owing queue's fence. Like a compute queue's, those uploads are not ordered after the refreshing queue's earlier work still on the GPU, so with the switch on an upload can rewrite a texture that work still reads. A queue the title releases owes nothing more. The owed refresh checks the debt again under the refresh lock, so it runs once. XCL's own signals on the title's behalf (list_x::signal_write64_pairs) follow only submits whose lists wrote memory, which refreshed. With the switch off nothing of this is set and nothing new locks.submit_cost: the average line counts these submits ("N of them only flushed or synced: …") whether the switch is on or not, and the owed refreshes paid at a queue call with their time (also in the lock wait, refresh and whole: the per-ExecuteCommandLists averages include the refreshes the submits left to a later queue call).refresh_for_as): the queue owes the refresh, other queues' uploads go to XCL's own queue meanwhile, another queue's refresh does not pay it, a later queue call, the queue's release or its next full refresh does, and with the switch off the same submit has the full refresh; a test of which queue methods pay (real::pays_owed_refresh).Tested
cargo check --workspace --all-targets --target x86_64-pc-windows-gnu(the Setup'stypecheck), run again after each round of review fixes (deac669, 36d8b36, d6175c8, the latest commit): passes, no warnings in the changed code.cargo build --workspaceok;cargo test --workspace --no-fail-fast -- --test-threads=4: 2963 passed, 9 failed, 49 ignored, 28 SKIPPED, the 9 failures the same as on amd-dev alone on that card; a 60 s smoke run of a retail title with the switch off: 1671 -> 1664 frames shown, no device removal, no crash. That run predates deac669 and did not exerciseXCL_FLUSH_SUBMIT_SKIP=1.cargo build --workspaceok;cargo test --workspace --no-fail-fast -- --test-threads=4: 2964 passed, 9 failed, 49 ignored, 28 SKIPPED, the 9 failures the same as on amd-dev alone, the new GPU test passes; 60 s smoke runs of a retail title clean with the switch off (1671 -> 1657 frames shown) and withXCL_FLUSH_SUBMIT_SKIP=1(1673 frames), no device removal, no crash. That run predates 36d8b36, and its log did not show how many submits were skipped.Not tested
xcl.loggets the line "submit cost, average of 1024 ExecuteCommandLists: … (… submits/s, N of them only flushed or synced: …; M owed refreshes at a queue call, X ms in all, in the refresh)" at INFO, the default level, with no switch needed. It is written every 1,024 title ExecuteCommandLists, starting at the 2,048th (the first 1,024 only set the baseline), and each line covers only the last 1,024. At ~20-30 submits a frame and 2-4 fps on AMD that is the first line after roughly 20-50 s of submitting; run a minute or more and add up N over the lines. N is counted with the switch off too, so a run withoutXCL_FLUSH_SUBMIT_SKIP=1already shows whether the title has flush-only submits.XCL_FLUSH_SUBMIT_SKIP=1has been run only in Foniass's 60 s smoke runs on NVIDIA (clean), not on AMD, and no run has shown how many submits were skipped, so its effect on the submitting thread is unmeasured. The smoke blocks under Regression run follow after a Windows run.Regression run
(follows after a Windows run)
AI use
Capy (Claude Opus 5.5) read the submit path and the list hooks, wrote the change and the tests, and ran the typecheck.