GPU: make already-used pipeline lookups read-only #3003
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3005"
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 Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-26T03:09:07Z.
Change
Avoid an unconditional atomic exchange and a second readiness check on every draw or dispatch using a finished pipeline. An atomic exchange still chooses one thread to record first use. Unfinished pipelines still enter the existing queue and wait within the existing frame budget.
I checked the open queue for matching work. #275 changes the wait after a cache miss. #2986 changes how the warm-up key is formed.
Verification
victory-gpupipeline tests passed with default features (3) and diagnostics enabled (4).git diff --checkpassed.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T03:24:52Z.
Review: APPROVED
Code review on
f962bf02(static source inspection):crates/victory-gpu/src/pipeline/make.rs:193-212cleanly avoids atomic RMW traffic on the hot path by checkingp.used.load(Ordering::Relaxed)before falling back top.used.swap(true, Ordering::Relaxed)(preserving single-recorder election under contention) and returning early fromp.made.get()without re-callingstart/wait.first_use_of_a_finished_pipeline_is_recorded_without_queueingcleanly covers bothusedrecording and non-queueing on an already-completed pipeline.Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T03:34:54Z.
Confirmed the first-use race and the throughput gain through
pipeline::host_pipeline, the entry point used by draws and dispatches. Each worker held the same valid guest graphics pipeline. With 32 callers starting together, all obtained the same host object. I counted calls at the entry tolibrary::note_used, before its set deduplicates keys. It ran exactly once per guest object. Each of 16 fresh objects built once, and none of 16 prebuilt objects entered the queue. This passed on RTX 5080 and WARP at both63bcca43andf962bf0. Cold callers could retry after the frame wait budget expired.On a Ryzen 7 9850X3D, the completed-pipeline measurements below use aggregate wall ns per lookup.
SetPipelineStateevery 16 lookupsThere is a separate opportunity if recording threads bind the shared PSO frequently. With an actual
SetPipelineStateon each worker's own guest command list before every lookup, the PR measured 18.0 ns. Each bind still exchangesPipeline::bound. Adding the same relaxed load before that exchange in a local control reduced the median to 2.85 ns, with one first-bind event per guest object in the race. The parent varied from 14.55 to 38.15 ns between processes on this workload.The timing used WARP to create the finished D3D12 PSOs, with one recording worker pinned per physical core. The table gives the median of four fresh-process medians, seven batches per process and 320,000 lookups per worker in the multithreaded batches. The timings cover CPU lookup and the indicated binding calls. To reproduce, set
VICTORY_PROBE_DXCto the SDK compiler andPROBE_CORESto eight comma-separated affinity masks, then runcargo test --release -p victory-gpu --features diagnostics --lib actual_guest_pipeline_lookups -- --ignored --nocapture. Standalone review fixtureImported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T04:37:35Z.
Review: APPROVED
LGTM — read-then-swap preserves the single note_used winner under races; the made.get() early return is equivalent to the old is_none() gate (made pipelines skipped start/wait before too) while staying read-only. Test asserts queued stays clear for finished lookups.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:49:37Z.
Automated triage for the maintainers.
Merge candidate (small). In
pipeline::make::ready, a relaxedloadofusednow comes before theswap, so a pipeline already recorded no longer does an atomic exchange on every draw. Theswapstill makes sure only one thread callslibrary::note_used. A finished pipeline returns frommade.get()straight away. The not-yet-made path (start(p, true),wait, thenmade.get()) is unchanged. I checked that this is equivalent to the old code. The new testfirst_use_of_a_finished_pipeline_is_recorded_without_queueingcovers first-use recording and that a finished pipeline isn't queued again.The gain is small per lookup (a tester measured about 13 → 0.6 ns with 4 threads sharing one pipeline, and confirmed
note_usedstill runs exactly once per object under a 32-caller race on RTX 5080 and WARP), but the change is simple and safe.CI: passing.
Recommending a look, not approving.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:09:55Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:p.used.swap(true, Relaxed)behind!p.used.load(Relaxed)and returning early onp.made.get()avoids dirtying the shared cache line on every hot-path lookup after first use while still recording first use exactly once.cargo test -p victory-gpu --features diagnostics pipeline::make::tests: 4 passed, 0 failed (includingfirst_use_of_a_finished_pipeline_is_recorded_without_queueing).cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.