Repository navigation
perf(gpu): compare big card copies only where written lately - #501
ballsimulation wants to merge 2 commits into
Conversation
…nly for that (VICTORY_LAZY_COMPARE_MB, VICTORY_LAZY_NARROW; off by default) The constants heap (174 MB) is declared written by the skinning passes in every submission, so it was compared whole after each of ~12 submissions a frame (2.2 GB of the card's reads to find ~2.6 MB written), and every constant fill from it counted as blocked by flights and was planned onto the card (`card_steps`, 7-12 ms a frame on the submitting thread). VICTORY_LAZY_COMPARE_MB=<MiB>: of a card copy at least this large, a submission compares only the pieces found written lately (VICTORY_LAZY_HOT compares, 64), the left-out pieces about to be sent up (their rehash is held back, so the compare still sees older shader writes), and the next VICTORY_LAZY_SWEEP (128) left-out pieces in turn. Those compares store their hashes (mode 2). The write-back itself is unchanged: what is found is fetched and merged as before. VICTORY_LAZY_NARROW=1 (with the above): where submission steps wait for flights or are done on the card in their order (late_blocked, card_steps, cut_for, the relay's wait), such a copy counts as written only on those pieces. Refreshes still see every declared write. Accepted: a piece written for the first time reaches title memory, and is read as the title has it, only once the sweep finds it (~2 frames). Series S, DLSS Performance, 30 fps cap, RTX 4070, same walk, one build: frame time by draws per frame, switches off -> on: 4-6k 53.7 -> 50.4 ms, 6-7k 56.8 -> 54.4, 7-8k 59.2 -> 57.1, 8-9.5k 62.7 -> 58.8; submitting thread 49.5 -> 45.8 ms, its planning of steps on the card 7.4 -> 1.7 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Testing feedback on RTX 5080 16 GB / AMD Ryzen 7 5700X (8C/16T) / 32 GB RAM, Windows 11, Series X 1440p + DLSS Quality + DLSS MFG 4×, based on Hit a guest access violation at 3m44s (
Full disclosure: this was tested on a custom branch with additional local GPU patches on top of |
|
Tested merged on top of main (RTX 3080 Ti, Ryzen 7 5700X, 1440p DLSS Quality, title ray tracing on). With the switch at its default (off) the run was fine. Review found one bug in It joins a hot piece onto Fix we use (callers already sort and join afterwards): - Some(last) if last.1 >= a => last.1 = last.1.max(b),
+ // `out` may already hold unrelated ranges; callers sort and join after.
+ Some(last) if last.0 <= a && last.1 >= a => last.1 = last.1.max(b),plus a test |
…for that (VICTORY_LAZY_COMPARE_MB, VICTORY_LAZY_NARROW; off, A/B-able) Port of trustno1-coder/VIctory-NVIDIA#501 (ballsimulation, f7cc776d), with the hot_within fix Machad3x gave in its review. The skinning passes declare the whole 174 MB constants heap written in every submission. Its card copy is then compared in full after each of ~12 submissions a frame (about 2.2 GB of reads to find ~2.6 MB that shaders wrote), and nearly every constant fill from it counts as blocked by flights, so it is planned onto the card (card_steps, 7-12 ms a frame on the submitting thread). Upstream measured frames 4-6 % faster on an RTX 4070 at 1440p, and the planning 7.4 -> 1.7 ms. - VICTORY_LAZY_COMPARE_MB=<MiB>: a copy at least that large is compared only on pieces found written in the last VICTORY_LAZY_HOT compares (64), pieces about to be sent up (their rehash held back), and the next VICTORY_LAZY_SWEEP pending pieces (128); those compares store their hashes (mode 2). Trade-off: a piece shaders write for the first time comes back when the sweep reaches it, about 2 frames later. - VICTORY_LAZY_NARROW=1 (with the above): late_blocked, card_steps, cut_for and the relay's wait count such a copy written only on its hot pieces (Line::narrow, via Line::blocking). Refreshes still see every declared write. A 0xc0000005 was reported on a 5080 with both on, on a modified branch. Fix (Machad3x): hot_within joined a hot piece onto out.last_mut() without checking last.0 <= a; out already holds unrelated ranges (texture read-backs), so a hot piece below one was swallowed and, with NARROW, its flight not waited for. Now push_joined, with a test. Adapted here: lazy ranges carry this tree's CardRange.left (crate::wc_skip) like declared ones; mod font is not ours. In-run A/B: VICTORY_AB can name VICTORY_LAZY_COMPARE_MB (64 MiB when the variable is unset) and VICTORY_LAZY_NARROW. Line::narrow is kept whenever the compare is set up, so NARROW can turn on with flights in the air; with the compare off, narrow takes the whole declared ranges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Follow-up test confirming @Machad3x's 1-line fix in Setup: Same hardware (AMD Ryzen 7 5700X 8C/16T, RTX 5080 16 GB, 32 GB RAM, Windows 11, Series X 1440p + DLSS Quality + DLSS MFG 4×, Result — 12-minute (720 s) 3D run
Thanks to @Machad3x — adding |
|
Update after a 3rd run with Hit the exact same 4-frame guest access violation ( So |
…default; notes on copies back and memory types Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SGw6DM2fQu3WKmCUhFxrrM
…by it (hot_within) hot_within joined a hot piece onto the last range of `out` whenever that range ended at or after the piece's start, without checking that it began at or before it. `out` already holds other ranges there (Line::joined seeds it with the texture read-backs, the line's rebuild with other flights' ranges), so a hot piece lying below one of them was dropped, and with VICTORY_LAZY_NARROW=1 steps that read it did not wait for the flight that writes it. Found and fixed in review by Machad3x on trustno1-coder#501. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A measurement of the two switches of #501 ( Setup: RTX 4070 SUPER, 32 GB, DLSS Quality, frame generation off. Main 8fc2254 plus a local patch stack (24 commits, not upstream). A stick-steered walk of 270 s through one district with 13 marks, the same path in both runs, about 3,500-10,900 draws per frame (median per leg). One run each. What it did to the work the PR targets: the planning of steps on the card by the submitting thread goes from 6.9 to 1.8 ms per frame (the PR text says 7.4 to 1.7). The submitting thread's total goes from 49.7 to 45.5 ms. What it did to the frames:
Nothing here is outside the noise: the base's own two runs differ by 0.55 fps (3.5 %) in fps and by 1.3 fps in the dense stretch. So on this card and route I cannot confirm the 4-6 % faster frames: the submitting thread got 4 ms cheaper and the frame did not get shorter. Likely (not checked) the frame here is limited by something other than the submitting thread's planning once #516 has removed the lock waits. Memory: process private peak 25.10 GB (A) and 25.17 GB (A + #501); dedicated VRAM peak 8.70 and 8.62 GB. Both runs reached the end of the route with no crash, hang or device error. Not measured: a second run of either build, a different route, a card or CPU other than this one. Unverified: that the local stack does not change these numbers. |
|
Thanks for testing this, all of you.
Marking this as a draft until the crash is understood. |
|
@POMXARK, thanks again for the crash reports. I can't reproduce it here yet: an 8-minute prologue run with both switches had no crash (RTX 4070, Ryzen 9 7950X, Series X 1440p, DLSS Performance, no frame generation, main Leads so far
What would help
To make runs repeatable, there's now an unattended runner, |
|
@ballsimulation Here are the exact details from both saved crashing runs ( 1. Card-copy addresses (
|
|
RTX 5080 + Core Ultra 9 285: no crash in 19 runs with both switches (no frame generation), and the figures together with Machine: Intel Core Ultra 9 285, 64 GB RAM, RTX 5080 16 GB, driver 621.40, Windows 11. Release build of
I haven't run the two splits you asked @POMXARK for ( |
|
@ballsimulation @x-nihil0 Follow-up data point on
Takeaway: Unlike on stock Also worth noting: porting the 3 small per-draw savings from |
Summary
Two opt-in switches, both off by default, that cut the cost of the title's 174 MB constants heap:
VICTORY_LAZY_COMPARE_MB=64: the GPU compares only the parts of the heap that shaders recently wrote, plus a rotating sweep of the rest.VICTORY_LAZY_NARROW=1: constant reads from the heap stop counting as blocked by in-flight work, except on those recently written parts.On main, with both on: frames 4–6% faster, and the submitting thread's planning of steps on the card drops from 7.4 to 1.7 ms.
Why
The skinning passes declare the whole heap written in every submission, through one view of it. That has two costs:
card_steps). That costs 7–12 ms per frame on the submitting thread.What changes
VICTORY_LAZY_COMPARE_MB=<MiB>For a card copy at least this large, a submission compares only:
VICTORY_LAZY_HOTcompares (default 64);VICTORY_LAZY_SWEEPskipped pieces in turn (default 128).These compares store their hashes (mode 2). Anything found is fetched and merged exactly as before. A log line every 5 s shows the counts.
VICTORY_LAZY_NARROW=1(needs the switch above)Where submission steps wait for flights, or are done on the card in flight order (
late_blocked,card_steps,cut_for, the relay's wait), such a copy counts as written only on its recently written pieces. Refreshes still see every declared write.Trade-off
A heap piece that shaders write for the first time reaches title memory only when the sweep finds it, about 2 frames later. Until then, CPU steps read the title's own bytes there.
Results
RTX 4070, Ryzen 9 7950X. Series X profile at native 2560x1440, no DLSS, frame rate uncapped. One build of main
64d4931bwith this change, the same save and walk, run with the switches off and then on. Median frame time by draws per frame:Caveats
🤖 Generated with Claude Code