test(vk): a diagnostic build for Skip Upscaler Wait and the late pages (not for merge) #3178
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3178
Loading…
Reference in a new issue
No description provided.
Delete branch "Veix/Longshot:diag/late-pages"
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?
Summary
A diagnostic build, not for merge: it logs who waits for the GPU and why, with Skip Upscaler Wait on and off, and tries one change to the late pages, so that one log from a tester (AMD most of all) answers what #3135 and #2366 do on their card.
Why: Skip Upscaler Wait (#3135) gains a lot on some PCs and nothing on others, and the logs
mainwrites cannot say why. On the RTX 4070 SUPER it was found that most of the pages the renderer treats as "late" (a page the CPU wrote that a GPU write-back is still pending on) are judged late by their whole submission, while the part of it that wrote them is already done; the repairs and waits that follow cost the row part of its gain. Whether that, or something else, is what happens on other cards is what this build is for.What the build does on its own, with nothing to set:
It goes through four states, two windows of 600 gameplay frames each, and starts over:
main(Skip Upscaler Wait off)The row is switched inside the renderer; the menu's row is not followed while the states run. The stamp table is emptied at each state's start. A window counts as gameplay when it has 300 or more draws a frame, so menus and loads do not count toward a state.
The late rule under test: a captured page is late only while the part that last wrote it back is still running on the GPU (its own part, looked up on the recordings' timeline), not while that part's whole submission is.
The reader fix under test: the renderer's own reads of a page that is being repaired no longer wait for the repair when the repair cannot change the bytes read: no word of them is stamped as changed by a pending write-back, or (a page written back whole) its snapshot holds what the repair will copy. For that the stamps and the snapshots are in host memory, in every state.
Every 600 presents it writes
vk: TEST window ...lines intolongshot_log.txt: the state; FPS and the frame trace's columns as means, with the GPU's own time; the frame limiter's outcomes (by the part before the upscale, or the whole frame and why); every wait on a fence or a timeline by its code line, its thread and what it is for; the game's reads of GPU results by how they waited, and how many #2366's rule spared; the late pages (how many, how many the rule spared, waits, the stamp table); the GPU's idle time between recordings and the window's copy; the reader fix's counts; the render thread's present by step, and the overlay's part of it (a menu, the FPS counter, a mod's screen) as building, waiting for the recorder thread and recording.For testers: pick one upscaler and do not change settings while it runs; run a small loop in one area for four or five minutes (or stand at one spot for three), then send
longshot_log.txt. The frame time steps every ten to fifteen seconds while it runs: that is the states changing, not a bug. Please say if the picture shows anything odd (flashes, flicker), and roughly when.Switches, for whoever wants them:
RX_VK_TEST_AUTO=0no states (the menu's row, the late rule on;RX_VK_TEST_READ_STAMPS=1adds the reader fix,=0keeps the stamps in device memory asmain);RX_VK_TEST_LATE_BY_PART=0or1pins the late rule;RX_VK_TEST_LATE_DIAG=0turns the counting off;RX_VK_FRAME_TRACE=0turns the frame trace off (it is on by default here).Read first, if at all: the
TESTblocks ingpu/vk/vk_memory.cppandgpu/vk/vk_replay.cpp, and the two wait macros ingpu/vk/vk_work.h. All of it is markedTESTand none of it is meant to stay. Written with AI assistance (Claude); the commit carries aCo-Authored-By:trailer.Testing
Tested: Windows 11, RTX 4070 SUPER, driver 621.24, NVIDIA DLSS at 67 %, on
main3b3ea2cb3merged in. The walking Castle Town route (Market, castle, Market) headless and in a window, and some minutes of play at 2560x1440: the four states cycle, every line is written, no fatal error. The counters checked against each other in those logs: the GPU's time in recordings + uploads + idle is the frame's time (12.33 of 12.34 ms, 12.70 of 12.70 ms in a window); the reader fix answers no read in the states where it is off and every read of a page under repair in its own (about 10,000 a state, none falling back to the wait); in its check mode (RX_VK_TEST_READ_STAMPS=2: the wait as before, then the bytes compared) 2,490 reads over the route, none different. A run with the validation layer on, the pass timer switched on and off in it: no message from that.Still to test:
Measurements
Nothing to measure for a merge: this is a diagnostic build. Its own counting costs a little, the same in all four states, so its FPS is for comparing its states with each other only.
Risks
main's included.longshot_log.txt;longshot_frames.csvwritten beside it.Tested in game: Windows 11, RTX 4070 SUPER, driver 621.24, 4K output, NVIDIA DLSS at 67 %: the walking Castle Town route (Market, castle, Market), headless, three runs. The four states cycle, every TEST window line is written, no fatal error.
WIP: test(vk): a diagnostic build for Skip Upscaler Wait and the late pages (not for merge)to test(vk): a diagnostic build for Skip Upscaler Wait and the late pages (not for merge)Recommendation: Request changes. The diagnostic adds state-dependent waits to the path it measures, so its comparisons can attribute the diagnostic’s own cost to the renderer. The new switches also lack the required switch-table entries and measured defaults.
The build cycles through combinations of Skip Upscaler Wait and a late-page rule while logging waits and frame statistics. It can help investigate those paths, but it changes gameplay behavior and adds work to the renderer; it is explicitly described as a diagnostic build, not a merge candidate.
Blocking (2): must change before merging.
gpu/vk/vk_memory.cpp:3735: The diagnostic introduces an additional blocking wait in the path whose timing it is intended to compare. (more on the line) Do: Record the existing repair wait without inserting another wait into the gameplay path, or run the extra attribution wait in a separately labeled mode excluded from state comparisons.gpu/vk/vk_replay.cpp:5783: The new renderer switches have no rows in the required switch table, and the changed frame-trace default contradicts its existing row. (more on the line) Do: Add rows for every new switch and update the frame-trace row, or remove the diagnostic switches and restore the existing default before merge. Choose any shipped defaults using the required measurements.Should fix (2): not blocking, but worth doing before merging.
gpu/vk/vk_memory.cpp:3206: The description omits several switches that change the repair and stamp-table behavior. (more on the line) Do: Document these switches and their defaults, or remove the unrelated experimental controls from this build.gpu/vk/vk_replay.cpp:5883: State duration is counted in qualifying windows, not gameplay frames as described. (more on the line) Do: Count gameplay presents individually and form reports from those frames, or describe and label the mixed-window rule accurately.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:2678: The changed late-page rule and renderer timing need coverage on the other systems whose behavior they can change. (more on the line) Do: Run the diagnostic on the affected Tier 1 configurations, checking the picture and logs, and compare frame-time distributions with the base using matched scenes and settings. (@fixdoes its part first: Remove the experimental late-page rule and automatic state changes if this instrumentation is intended to ship without changing gameplay behavior.)@fixcan do L1, L2, L3, L4 and L5.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. Three Windows RTX 4070 SUPER runs reportedly produced the diagnostic lines, and a pinned late-rule run reported 0.00–0.01 ms per frame of capture waits versus 0.88 ms for the merged row in the Market. These are not interleaved measurements against the base, and the added diagnostic waits can affect the comparison.
Other systems: The changed capture, replay, wait and frame-trace paths can affect both Windows and Linux, all GPU vendors, the Steam Deck and configurations without an upscaler. The reported run covers Windows and one NVIDIA GPU; AMD, Linux and Steam Deck behavior remain unverified.
Switches: RX_VK_TEST_AUTO defaults on; RX_VK_TEST_LATE_BY_PART defaults to automatic, or on when automatic states are disabled; RX_VK_TEST_LATE_DIAG defaults on. RX_VK_TEST_FIX_READ_PART and RX_VK_TEST_STAMP_LRU default off, RX_VK_TEST_STAMP_IDLE and RX_VK_TEST_STAMP_AHEAD_MIN default to 0. RX_VK_FRAME_TRACE changes from off to on. The new switches lack switch-table rows, and the defaults have not been selected from measurements across supported systems.
Reviewed:
78cd53a4faagainstd6e819e084: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, commit and diff; traced changed capture, repair, reporting and present paths and their surrounding code. Skimmed the remaining portions of the large changed renderer files rather than reading all 34,708 lines in full. docs/review-checklist.md and ../Tooling/AGENTS.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run for this review, as requested. The author reports three diagnostic runs and one earlier short visual play session; the listed CI checks have not finished.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as Veix took it out of WIP. Nothing was run; a maintainer decides.
@ -2553,3 +2675,4 @@if (!wb_pages.empty())for (int64_t i = 0; i < n; i++) {const uint64_t pv = wb_pages.get(pages[i]);if (pv > done && c->test_done_part) { // TEST latebypart: its part is done, its words are in guest memoryL5 (should fix): The changed late-page rule and renderer timing need coverage on the other systems whose behavior they can change.
When: The reported run exercises one NVIDIA Windows configuration; AMD on Windows and Linux and the Steam Deck can have different write-back, memory and synchronization behavior, so a successful NVIDIA run does not show their output and pacing remain correct.
Do: Run the diagnostic on the affected Tier 1 configurations, checking the picture and logs, and compare frame-time distributions with the base using matched scenes and settings.
@ -3065,0 +3203,4 @@int64_t st_tl_read_part, st_tl_read_whole; // TEST readpart: earlier recordings' fixes read by part / by the whole recording// TEST lrufix_apply.py RX_VK_TEST_STAMP_LRU: the block needed least recently given back (not one made in this recording)bool test_stamp_lru_on() {static const bool on = [] { const char* e = getenv("RX_VK_TEST_STAMP_LRU"); const bool v = e && *e && *e != '0';L3 (should fix): The description omits several switches that change the repair and stamp-table behavior.
When: A tester with RX_VK_TEST_FIX_READ_PART, RX_VK_TEST_STAMP_LRU, RX_VK_TEST_STAMP_IDLE or RX_VK_TEST_STAMP_AHEAD_MIN already set can run a different experiment from the four states described, without the requested tester instructions identifying those controls.
Do: Document these switches and their defaults, or remove the unrelated experimental controls from this build.
@ -3383,0 +3732,4 @@if (!fixed && d.over && !d.wdone && wpart) { // (the writer's part first, timed apart, when the repair comes after it anyway)const uint64_t fseq = lp.fix_part ? test_part_seq(lp.fix_part) : 0;if (fseq && wseq && wseq <= fseq) {const auto t = std::chrono::steady_clock::now();L1 (blocking): The diagnostic introduces an additional blocking wait in the path whose timing it is intended to compare.
When: When a read encounters an unfinished repair whose writer is still pending, this waits for the writer’s part before the existing repair wait. The frequency of that path depends on the late rule and workload, so its added synchronization and scheduling cost is not the same in all four states and can change the reported frame times.
Do: Record the existing repair wait without inserting another wait into the gameplay path, or run the extra attribution wait in a separately labeled mode excluded from state comparisons.
@ -5699,0 +5780,4 @@static int64_t presents;static int64_t test_window_with; // TEST latediag4: the window's presents with the gameplay upscalestatic int test_state = -1, test_state_age = 0; // (-1: not begun)static const bool test_auto = !getenv("RX_VK_TEST_AUTO") || atoi(getenv("RX_VK_TEST_AUTO"));L2 (blocking): The new renderer switches have no rows in the required switch table, and the changed frame-trace default contradicts its existing row.
When: A build with the default environment enables automatic state changes and frame tracing, while switches.def still documents frame tracing as off and contains no entries for the new TEST switches. Developers and switch-table checks cannot discover the actual defaults.
Do: Add rows for every new switch and update the frame-trace row, or remove the diagnostic switches and restore the existing default before merge. Choose any shipped defaults using the required measurements.
@ -5699,0 +5880,4 @@test_rb_report();memory_test_window(false);if (test_auto) { // TEST latediag4: the next state after two windows of play (500 or more presents with the upscale each)if (test_window_with >= 500) test_state_age++;L4 (should fix): State duration is counted in qualifying windows, not gameplay frames as described.
When: A window containing 500 gameplay presents and 100 menu or load presents advances the state by a full 600-frame window. Two such windows change state after only 1,000 gameplay frames, and their reported averages include the other 200 presents.
Do: Count gameplay presents individually and form reports from those frames, or describe and label the mixed-window rule accurately.
On a GPU without cooperative matrices (RDNA 2 and older) the game's upscale network is left out and upscale_stub draws the scene into the picture with the temporal upscaler or FSR 3.1. That path returned before dispatch() noted the upscale's program, so the part before the upscale was never cut and the frame limiter waited for the whole frame on every frame ("no upscale"): an RX 6800 XT's log, 0 of 10,796 frames by the part. The stub's scene upscale is now noted as the dispatch's own is, and the diagnostic's "frame with an upscale" mark with it. Checked here with RX_VK_FORCE_UPSCALE_STUB=2 (4K DLSS 67 %, the walking route): 561-598 of 600 play frames by the part, 0-1 "no upscale". Co-Authored-By: Claude Opus 5.5 <[email protected]>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.