gpu: two opt-in refresh changes — read textures without the mapping lock, and share one read across eight (Series X 2.25 -> 4.06 fps) #59
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/trustno1-coder--VIctory-NVIDIA!59
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-59"
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?
@superboynick on GitHub · 2026-11-27 15:28 UTC · original
superboynick:pr/refresh-locks→main· +24 −0 · 1 files · 1 commits · openRewritten to the shape asked for in #10, and narrowed to one switch — the batching half is withdrawn because #18 (Kemerd) does the same thing more completely with
VICTORY_REFRESH_SET, and I would rather not race it on the same line.What I tested
RTX 5070 Ti Laptop (12 GB, 32-lane waves), i9-14900HX, 32 GB, Windows 11 26100, release build,
--console series-x(the console-matched preset), the 36-item play set, frame generation off. Same deck save and independently warmed caches for each arm. Windows were paired on scene progress and draw count, and only windows after 300 frames in the scene were kept; 8-23 pairs per comparison, draws within 5%.VICTORY_REFRESH_LOCKLESS=1: reads a texture under an epoch check instead of holding theMAPPINGread lock, and falls back to the original path when the epoch moves.What happened
With the switch unset, eight startup frames are byte-identical to the build before it.
And the part that matters more than my numbers: heklokate tested an RTX 3070 Laptop, Series S, DLSS Quality, about 6,000 draws a frame, and found this switch neutral to slightly negative there — refresh median 25.05-26.20 ms without it against 25.10-25.75 ms with it, median FPS 9.09-10.10 against 9.64-9.84, P99 worse in both runs. That is consistent with what the switch does: it removes waiting on a lock, and on that build the whole refresh stage is 25 ms, so there is almost no waiting to remove. It should not be described as a general win, and I am not describing it as one.
What would make it mergeable
If it is not worth it on your card, say so and I will close it —
docs/findings.md:68"measured and not worth it" is a perfectly good outcome and I would rather have that recorded than a switch nobody should turn on.Written with an AI assistant.
One more thing I checked after the 3070 numbers came in, because it changes how this should be read.
Upstream's
playpreset turns onSOFT_VIEWS=copies, and in that view this switch falls back to a batch of one — the eight-texture sharing only exists when the view is shared rather than copied. So on the default preset the batching half of this PR is inert by construction, which is consistent with heklokate measuring it as neutral: there was nothing there to measure. That is also why I withdrew the batching half and left #18 to do it properly.The epoch-check half is not inert, but its cost is small: on this machine the epoch moved during a copy 0.067 times a frame, and the failed attempts added up to 0.032 ms a frame. So if the 3070 lost a tail somewhere, it is not the epoch check, and I would rather say that than leave the suspicion hanging.
@exotiquee on GitHub · 2026-11-27 16:15 UTC · original
A measurement from the writer side of the same lock, in case it helps decide how far to take this.
On an RTX 5080 with a Ryzen 7 9800X3D, we looked at slow cutscene shot-change frames, where the title streams heavily:
MAPPING(watch.rs) exclusively, for any address.The two switches here avoid the lock on the reader side. An alternative that also helps every other reader is to stop making the lock global: stripe it by address range. A mapping call would lock only the stripes its range covers, and a read only the stripes it touches. Mapping calls for different addresses would then stop serializing against each other and against unrelated texture reads. A fuller version has each in-place read claim its range, with a mapping call waiting only for claims that overlap it.
We haven't built either version yet, so I have no after-numbers. The 34-44 ms per slow frame is the size of the wait that is there to remove.
@superboynick on GitHub · 2026-11-27 16:17 UTC · original
That data is exactly what I was missing, thank you — the writer side is where the cost really is, and 1,200-1,300 mapping calls a frame at 28-59 µs each explains why our reader-side numbers moved so much even though we only touched the reader.
Two things from our side that fit yours:
Our two switches are deliberately the cheap half:
VICTORY_REFRESH_LOCKLESSreads under an epoch check and falls back when the epoch moves, andVICTORY_REFRESH_BATCHtakes one mapping read for up to eight due textures and releases it before write boundaries, so the writer is never held off longer than it is today. Neither touchesMAPPINGitself.Striping is the better shape, and it helps every reader rather than just the refresh. I am prototyping it as a follow-up rather than growing this PR:
VICTORY_MAPPING_STRIPES=<n>(unset or 1 = today's single lock, byte-identical path): aMAPPINGsplit into n stripes over address ranges, a mapping call locking only the stripes its range covers, a read locking only the stripes it touches.I will report the same protocol we used here —
--console series-x, the 36-item play set, paired windows on the same scene with draw counts matched within 5%, startup frames byte-identical with the switch unset — including the slow cutscene shot-change frames you measured, since that is where the wait actually shows up.If you have the 1,200-1,300 calls figure as a log line or a script you can share, I would rather reproduce your measurement than invent a second one.
@heklokate on GitHub · 2026-11-27 17:25 UTC · original
Test results on an RTX 3070 Laptop GPU
The combined refresh switches left the median submit-thread refresh time close to main in this Series S scene. P99 frame time increased in both runs. This sample did not reproduce the large increase reported for the stressed Series X workload.
Hardware and setup. Intel Core i9-12900H, RTX 3070 Laptop GPU (8 GB, driver
32.0.16.1742), 32 GB DDR5-4800, Windows 11 build 26100. Release build, Series S, DLSS Quality, frame generation off. The same deck save and independently warmed caches were used throughout.Samples. Two valid runs per build, one 30-second PresentMon window per run starting at 180–181 seconds after launch. The table lists each run separately. Warm-ups and an earlier main capture affected by background compilation were excluded.
Revisions. Main
d12eb1band PR0c6a636. The PR runs usedVICTORY_REFRESH_LOCKLESS=1andVICTORY_REFRESH_BATCH=1together.The refresh and preparation figures are medians of the game's periodic timing lines in each capture. Median draw counts were within 2% of the corresponding main run. One additional PR attempt ended during load with the same guest access violation seen on a main warm-up, and was replaced.
Tested and documented by Codex.
@superboynick on GitHub · 2026-11-27 17:45 UTC · original
Thank you for running this — that is exactly the comparison this PR was missing, and it changes my conclusion for your configuration.
Your numbers say the two switches are neutral-to-slightly-negative on a 3070 Laptop at Series S with DLSS: refresh median 25.05-26.20 ms on main against 25.10-25.75 ms with them on, median FPS 9.09-10.10 against 9.64-9.84, and P99 worse in both runs. I measured on Series X, where the refresh stage was 191-336 ms of the frame and the lock wait was 974 ms in median across threads; on your build the whole refresh stage is 25 ms, so there is almost nothing for the switches to remove, and the batching holds a read lock across up to eight textures where a single read was held before. On a frame that is GPU-bound and short on VRAM, that is a plausible way to lose a little latency rather than gain any.
What I intend to do about it, rather than argue with your sample:
If you have the raw per-frame log lines from your two PR runs, the refresh figures alone would let me tell whether the loss is in the batching hold or somewhere in the epoch check.
Written with an AI assistant.
0c6a63641bto9d7eda84389d7eda8438to002aca7126002aca7126to59c16944a459c16944a4toead3e99ce3ead3e99ce3to85eed08ade85eed08adetof45f9e9e2aView 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.