GPU: parallelize host-copy refreshes on multicore systems #38
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!38
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-38"
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?
@space-de on GitHub · 2026-11-24 20:46 UTC · original
space-de:perf/adaptive-wide-refresh→main· +37 −3 · 2 files · 2 commits · openSummary
VICTORY_WIDE_REFRESH=0as an opt-out and=1as an override; flushes still need at least four independent copies before using the worker pool.Validation
cargo test --workspace --no-fail-fast --quiet— passed (497 passed, 7 ignored).cargo clippy --workspace -- -D warnings— passed.cargo clippy --workspace --all-features -- -D warnings— passed.host.rslines had no formatter diff.The existing setting was opt-in and no open PR was found changing its default.
@ryotdev on GitHub · 2026-11-24 21:05 UTC · original
I found a race in the copy timer this change enables by default. On
05ee438, each parallel refresh adds its worker time toPREPARING[0]. After joining, the submission reads the total and subtracts the excess over wall time. The presenter can reset the counter withswap(0)between that last read and subtraction. Subtracting 300 µs from the reset counter leaves18446744073709551316µs for the next sample. This affects the reported “copies” time used to judge the speedup. Batch::flush · Presenter counter resetI tested a small fix on Windows. Let
Batch::updatereturn its elapsed µs and keep recording bytes and per-range diagnostics there. The serial callers add the returned time as before. For the parallel path, add the wall time once afterwide_runjoins. This removes the read/subtract correction entirely.In a CPU-only test using the PR's
Batch::flushand four synthetic 4 KiB copies, a second thread sampled after three workers finished and before the batch joined. It saw 6,975 µs of worker time on this head and 0 µs with the fix. The fixed batch published 5,303 µs on return and counted all 16,384 bytes. The one-to-three-copy serial cases andflush_onealso passed. This was an AI-assisted accounting test, with no game data or FPS measurement.@rocobalt1 on GitHub · 2026-11-24 22:44 UTC · original
Measured on Windows with the same build this PR was measured on (this tree plus the shader PRs; the only difference between the two runs below is this merge).
Setup: RTX 4060 Ti 8 GB, Ryzen 9 5900X, Windows 11;
--console series-x,VICTORY_DISPLAY_MODE=1920x1080,VICTORY_SHADER_LOOP_LIMIT=256,VICTORY_NO_WATCHDOG=1, fresh data dir per run, 3 - 4 minutes each, frames with more than 800 draws only.TdrDelay=60, so both columns are upper bounds.The frame median moved too, but I would not claim it for this PR: the two runs saw different amounts of streaming (10 against 15 world frames), and the copy lane is the only thing measured identically in both. The part that is clean is the tail - the worst copies halve - which is what I would expect from refreshing across threads rather than one after another.
No game data; counts only.
@iurysf on GitHub · 2026-11-24 23:25 UTC · original
One more data point, on an RTX 4070 12 GB (Ryzen 7 5800X3D, 32 GB, Windows 11), same executable for both runs (
4e17478+ #63 + #71 + #147, the watchdog hooks of #28 and a local profiling commit that is off unless asked for), onlyVICTORY_WIDE_REFRESHdiffering.VICTORY_RELAY=2,VICTORY_PIPELINE_WAIT_MS=24,VICTORY_CARD_BUFFERS_MIN_MB=1,VICTORY_CARD_BUFFERS_MB=2048,VICTORY_CARD_REHASH_RUNS=1,VICTORY_WIDE_BACK=1,VICTORY_WIDE_MERGE=1,VICTORY_LATE_WAIT_LISTS=256, no DRED, warm shader cache and pipeline library.Measured over a settled window of the prologue's first scene: 12 statistics lines (about 60 s) starting at the first of three lines with the heap-buffer pass under 100 ms and at least 3,000 draws a frame, so the texture streaming of the first minute in the world is left out.
VICTORY_WIDE_REFRESH=1No device removal, and the world's picture is there in both. One run each, the second after the first (its cache one run warmer), so the ranges overlap (198.8–303.0 against 175.7–232.0); I did not run the reverse order. The frame time here comes from the frame line, not from the "copies" counter, so the timer race @ryotdev describes does not touch the first two rows; it may touch the "copies" row.
AI-assisted.
@iurysf on GitHub · 2026-11-24 23:53 UTC · original
A correction to my numbers above. Two runs with identical settings turned out to differ by 20–25 ms here (the driver is still compiling new pipelines in the "settled" window), so one run per setting could not resolve a gain of this size, and the −25.7 ms I reported was mostly that.
Measured again inside one run: once the world settles,
VICTORY_WIDE_REFRESHis switched off (A) and on (B) every 4 statistics lines (about 20 s), the first line of each block is dropped, and each B block is compared with the mean of its neighbouring A blocks. Same scene, cache and machine state for both arms. RTX 4070, same recipe as above, plus #154, #255 and #270 in the build.Paired B − A: median −7.0 ms over 4 pairs (+0.4, −6.2, −7.8, −13.1); the sign agrees in 3 of 4. Blocks in order: A176 B179 A182 B170 A171 B166 A177 B164.
So on this machine the change helps by roughly 7 ms a frame, not 26. Small, consistent in sign, 4 pairs in one run.
AI-assisted.
@YeokiNoewChi on GitHub · 2026-11-25 00:37 UTC · original
RTX 3070 Ti 8 GB, Ryzen 5 5600X (6 cores, 12 threads), Windows 11, Series X profile, fork
main4e17478plus several open PRs.VICTORY_WIDE_REFRESH=1(the switch this PR turns on by default) makes geometry go missing in the prologue: from the barracks doorway the yard's inmates and picnic tables are not drawn and a wall beside the door shows sky. Restarting the same build and warm cache with only that switch removed brings them all back (checked by eye, same camera position). Frame time is about the same either way on this 6-core CPU (Ryzen 5 5600X), so on this machine the parallel refresh costs picture and gains nothing measurable.AI-assisted (Claude Code).
@AimLogin on GitHub · 2026-11-25 04:31 UTC · original
I tested this PR independently using a synthetic buffer-refresh benchmark and also integrated it locally with #220.
Hardware:
Synthetic benchmark with 64 buffer copies and approximately 67 MB of data:
The combined build with #220 compiled successfully and passed all 516 tests.
One remaining concern is contention within the memory-management and write-watch paths under concurrent workloads. Our synthetic benchmark does not fully reproduce those conditions.
Nevertheless, the measured reduction in CPU-side refresh time is encouraging. No isolated end-to-end FPS improvement has been established yet.
@gmankab on GitHub · 2026-11-26 13:30 UTC · original
I tested a Linux native port of the worker approach on Fedora 45 and an RX 6800. Five interleaved process runs, each sampling 21 warm flushes of the same eight D3D12 mappings, measured 5.97 → 3.86 ms at 44 MiB and 69.90 → 31.92 µs at 512 KiB. The fixture checked all bytes and the gaps between disjoint refreshes, including across the title-write barrier.
The Linux native switch stays opt-in given the earlier geometry report here. These results measure the copy path. Gameplay and the picture still need a matched comparison. Linux native port and test
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.