Cut the 17 s world frames with asynchronous submission and a copy queue #2960
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2960
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2960"
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?
@ynnmuraii on GitHub · 2026-11-26 01:33 UTC · original
ynnmuraii:perf-async-submit→main· +2953 −46 · 18 files · 10 commits · openThe world stalls for 17 s a frame here (RTX 4060 8 GB): the render thread waits inside submit and inside the fetch of what shaders wrote, so the intro cutscene never draws. With the three things below the same frames take 0.3-2 s and the prologue card renders.
Ported from
fxceless/victory-fork, where they sit behind switches:VICTORY_ASYNC_SUBMIT=1: submissions are prepared and sent by a thread of the layer. A profile in that fork had the render thread inside submit for 257 of 292 ms a frame.VICTORY_QUEUE2=1: fetches of what shaders wrote go to a copy queue; the copy-back thread's wait fell from about 125 to 7 ms a frame there. Itsqueue2.rscomes over with the fix for a piece fetched beside a later flight: textures count their state moves so a fetch recorded before a later use is told from one recorded after it.VICTORY_PIPELINE_WAIT_MSandVICTORY_PIPELINE_WORKERSalready exist upstream; the numbers below use 24 and 4.Measured on one machine (Ryzen 7 5700X, RTX 4060 8 GB, Windows 11 26200, Series X, 1080p, warm shader cache), same build, from the first-run screens into the intro cutscene:
No device removal in any of the runs with the device layer's debug output on; the runs above are 10-15 minutes each. Above about 2 900 draws the frame still goes back to 8-17 s, so this does not make the title playable, it makes the cutscene visible. Halving neither the worker count nor doubling it (4 against 8 workers) moves those heavy frames; they are not worker-bound.
The three are opt-in; the last row was run as
VICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_PIPELINE_WAIT_MS=24 VICTORY_PIPELINE_WORKERS=4.Two caveats from the fork's own notes: the async path assumes the title leaves its memory alone between submit and preparation (it does there, but nothing enforces it), and the copy queue brings reads back with an up-lane bit this port does not add.
@ynnmuraii on GitHub · 2026-11-26 02:18 UTC · original
Fixed 1 and 2 in
2e72cc94: the SAFETY comment moved inside theif, andLists::newcloses the listCreateCommandListhands back open, so the firstresetcan run;cargo clippy --locked -p victory-gpu --tests -- -D warningsis clean here now.On 3 and 4: both are real and I have no fix yet. For 3 the simplest reading is that the deferred copy is only safe while nothing later in the same batch writes the source; a version that records the copy inline when the texture is written again later in the batch would need the list to know what it has already written. For 4 the reports are consistent with what the reviewer says — the ordering contract is not enforced, so the numbers in the body come partly from a path that can race.
Measured after 1 and 2 on the RTX 4060: the reset path no longer breaks, no device removal in 12 minutes, but a frame at 3 135 draws still takes 16.7 s. The 0.5-2 s numbers are at 1 100-2 500 draws only.
@ynnmuraii on GitHub · 2026-11-26 02:23 UTC · original
3 addressed in the latest push:
Host::defer_fetchnow refuses a second read back of the same texture and subresource, so the duplicate is recorded in the list and only the first stays deferred. That covers the repeated fetch; the harder half of 3 remains — a later write to the source in the same batch still lands in the deferred copy, and the list would have to know what it has already written to catch it.4 is still open. Current state: clippy clean, reset path fixed, no device removal over 15 minutes, frame time unchanged at 16.7 s on a 2 941-draw frame.
@ynnmuraii on GitHub · 2026-11-26 02:28 UTC · original
4 addressed too:
presentnow callsqueue::before_sync()before it reads or moves any plane's state, so the submit thread has finished the lists that touch those textures before this thread mutatescopy.state. Nothing is drained from the submit thread itself, so no deadlock.That leaves the intentional part of 4 —
execute/signalreturning before the card has run — which is what the switch is for; the drain inpresentand the existing one inHost::executeare the fences around it.Frame time again unchanged at 16.7 s on 3 289 draws; no device removal in any of the runs after the four fixes.
@ynnmuraii on GitHub · 2026-11-26 03:26 UTC · original
Added the fork's relay on top (the flights thread, 1 406 lines), with the two crash fixes it needs to survive here at all:
redirect_null_writefor the title's null breadcrumb and theint3step-over. Without them the port dies in 2-3 minutes with0xC0000005on a write to 0, then0x80000003.With both: 10 minutes, no device removal, no exception. Frame time on the RTX 4060 is unchanged though — 16 s on 3 157 draws, one outlier at 33 s. So the relay is a working option here, not a gain; on this card the wall is the per-draw preparation, not the submit or the copy-back path.
@ynnmuraii on GitHub · 2026-11-26 03:55 UTC · original
Ported the fork's
framelogtoo (9cd2b104, diagnostics builds only,VICTORY_FRAME_LOG=0turns the lines off) so the long frames can be attributed instead of guessed at. First run with it on the RTX 4060:So the heavy frames are the card's own time, not our preparation and not pipeline creation: 0 pipelines made, 16.8 s of waiting for the card, 57 MB of copies. Lighter frames of the same scene settle at 1.3 s. My earlier "CPU preparation" guess in the comments above was wrong — that comes from the fork's own overlay on its own build.
The counters fx has that our tree cannot source (card clock, per-call list timings, remaps) are noted in the commit; the copy-back counter covers the relay landing path here.
@ynnmuraii on GitHub · 2026-11-26 04:01 UTC · original
Baseline with the same frame log and no switches, for comparison:
16904 ms | render thread: ran 297 ms; in submit calls 16871.5. With the switches the same 16 s sits inwaiting for the cardon our submit thread (16815) instead, so the title's thread is out of it. Total frame time is unchanged because the present then waits for the presented frame anyway — which is what both reviewers said in other words.@walterwallaceson on GitHub · 2026-11-26 05:01 UTC · original
RTX 3070 8 GB, Windows 10: with the switches on, the world runs at about half the speed it does with them off. That held on two heads,
a480378and9cd2b10, two runs each. This card never had the 17 s frames, so there was nothing for the switches to win here.Setup: RTX 3070 8 GB, driver 621.14, Windows 10 22H2 (19045).
main63bcca4+ #463 (Agility runtime, needed on Windows 10) + #2626, then + this PR. Diag build, Enter scripted at 17, 30 and 60 s, nothing skipped, 15-minute runs. "On" meansVICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_PIPELINE_WAIT_MS=24 VICTORY_PIPELINE_WORKERS=4, as in your table. "Off" is the same binary with none of them set.a480378ona480378off9cd2b10on9cd2b10offWithout this PR, the same stack ran at 1.8 fps, so with the switches off the PR costs nothing here. The switches also log as on (
VICTORY_ASYNC_SUBMIT=1,VICTORY_QUEUE2=1), and no run crashed or removed the device.Since all four settings were set together, I can't yet say which one costs the speed. A natural next split is the two switches without the workers and wait. Fewer indirect dispatches dropped with them on could be a side effect of fewer frames, not a fix.
One unrelated thing: the branch commits
victory.toml.off, which looks like a local config. It failsxtask'spolicy::tests::repository_passes_policy(file type not on the allowlist). I dropped it locally to test.Not tested: a second run of each cell; the frame log for the steady state (on this card it records almost no long frames after the first minutes).
No game data attached. I'm testing with Claude's help, and Claude drafted this comment.
@Marvisak on GitHub · 2026-11-26 05:32 UTC · original
Automated triage for the maintainers.
Proposed close. The PR adds about 2,900 lines of opt-in submission/copy-queue/relay code ported from another fork. By its own measurements in the comments, it does not help. The heavy frames stay at about 16.7 s with the switches on, and the frame log puts that time in waiting for the GPU, not in our submit path. An independent RTX 3070 run found the world at roughly half speed with the switches on (0.8 vs 1.8 fps). The deferred copy also has a known unfixed race: a later write to the source in the same batch lands in the deferred copy (
Host::defer_fetchinhost.rs).It also bundles unrelated, risky changes:
handlerinvictory-loader/src/crash.rsnow steps over everyint3in title code. That hides the title's own watchdog stops instead of explaining them, andbreakpoint_testsasserts nothing about it.frameloghooks invictory-hledstorage, and a committed localvictory.toml.offholding personal paths. That file is not on the policy allowlist and failsrepository_passes_policy.CI: failing.
What would change this: a small PR with one change that a frame log shows lowering frame time on
main, without the crash-handler, null-write and config changes. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes thetriage: proposed closelabel.Generated by Claude Code
@walterwallaceson on GitHub · 2026-11-26 06:20 UTC · original
Correction to my comment above: the "switches on halve the speed" result isn't solid. Since posting it, I found that frame rate on this RTX 3070 swings between roughly 0.7 and 1.8 fps from run to run of the same build. A control run of an earlier fast tree came out at 0.93 fps. My on/off runs alternated (on, off, on, off), and the "on" runs may simply have landed on slow turns. Please treat that table as not showing an effect either way until I can measure the run-to-run spread here. The stray
victory.toml.offnote still applies.I'm testing with Claude's help, and Claude drafted this comment.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.