Descriptors: a view heap's strides table stays in upload memory unless VICTORY_STRIDES_WB=1 (on an RTX 5090 shaders read it slowly from write-back memory: 23 ms of the card a frame instead of 15) #4501

Closed
github-bot wants to merge 13 commits from github-bot/gh-4500 into main AGit
Owner

@⁠HQasper on GitHub · 2026-11-30 21:25 UTC · original
HQasper:pr/strides-upload-memory → main · +9 −12 · 1 files · 13 commits · closed without merging

Follows #2174 (merged as 26d1d102), whose default for the strides table this changes.

What it changes

#2174 (26d1d102) made each view heap's table of strides and guest addresses with upload_buffer_maybe_wb(bytes, scratch_wb(host)): in CPU write-back (L0) memory wherever the lists' scratch is, which is by itself on a discrete NVIDIA card (VICTORY_SCRATCH_WB). That made the CPU's updates of the table cheap (the heaps' records pass).

The card reads the same table. Every shader that picks buffers from the view heap by an index it computes binds it as a root view (t255, t252 or t250 of space 1) and reads a dword of it for each such buffer. On an RTX 5090 those reads are slow from write-back memory: the programs that read the table take several times as long on the card, with the same dispatches and the same translation.

With this change the table is made in upload memory again, as before #2174, unless VICTORY_STRIDES_WB=1. The lists' scratch chunks are not touched, and the rest of #2174 (the lock-free address lookup, the direct record read) stays.

What is in it: crates/victory-gpu/src/descriptor/host.rs (strides_wb, strides_wb_of, used where the heap makes the table), and one test in the same file.

How it was found

Our branch on c71899d9 (v2026.11.30.01, our local commits rebased onto it) had more slow frames than the same commits on 41adb551: the card meter gave the title's lists 22-23 ms a frame against 15 ms, in the same scene, at the same frame rate.

  • By command (VICTORY_GPU_TIMING, diagnostics builds, steady part of the opening): dispatches 5.6-5.7 ms a frame on 41adb551 and 11.3 ms on c71899d9, in the same 3,414 commands a frame; indirect commands 6.2-6.3 against 8.0 ms. About 30 compute programs went from 0.01-0.07 ms to 0.13-0.57 ms a frame each: skinning (512416d975ace48b, 3a79195f06d3ed85, 12eae112b559091c), the compute graph (2666062bd7f4c95d, 7a38ed7f5205f384, a06ef09446bd6e70), hair (4a05640ec16718ad, 269b802f878c24e1), meshlet culling (764ca63daec9c616, 87bf9e3f2bf2f052, 3b471c122be79b3e).
  • Not the translator: 30 of these programs were translated by both builds with the runs' switches and disassembled. They differ in address masks (844200e9) and in the type of a few selects; no loop, cap or atomic differs.
  • What they share: of the 30, 26 read the strides table (t255 or t252) and all 26 grew. Of the four that do not read it, three cost the same on both builds; one (7b2c3c1db2298f44, one dispatch) is 1.1 ms slower on c71899d9 for another reason, not settled, with or without this change.
  • The card waits, it does not compute: at the same frame rate and the same power (205-210 W) the card is 96-97 % busy on c71899d9 against 68-69 % on 41adb551.
  • The switch settles it: VICTORY_SCRATCH_WB=0 on the c71899d9 build (the table and the scratch chunks in upload memory) brings the card's time by command from 21.7 ms a frame to 14.5 ms, and the 26 programs from 6.9 ms to 0.9 ms.
  • Also tried, without effect: VICTORY_WINDOWS_BAR_MB=0 (#2313's windows in card memory the CPU maps): 22.2 ms.

How it was tested

  • New test descriptor::host::strides_wb_tests::the_strides_table_is_in_upload_memory_unless_asked_for: unset, 0 and an empty value give upload memory whatever the scratch's kind; 1 gives write-back memory only where the scratch is write-back. cargo test --locked -p victory-gpu --lib strides_wb on this branch (9d50534b on 84bd61e2): 1 passed, 1199 filtered out.

  • In game (the opening from one save, RTX 5090, driver 621.24, 2560x1440 with DLSS Quality, ray tracing off, 170 s runs, 2026-11-30; our branch on c71899d9 without and with this commit, interleaved b r r b after one uncounted run; steady = seconds 60 to 120 of the world):

    card meter, the title's lists steady fps p99 1 % low frames over 50 ms card busy power
    without 22.8, 24.6 ms 38.4, 36.4 48.1, 53.7 ms 19.4, 17.2 13, 50 97 % 207-210 W
    with 15.1, 15.4 ms 39.9, 40.4 35.2, 33.0 ms 26.5, 26.8 0, 0 72-74 % 205-208 W
  • What it costs the CPU (the same four runs): the heaps' records pass takes 5.3-5.5 ms a frame with this against 3.9-4.4 ms without (6.7 ms on 41adb551, before #2174), and the submitting thread's submissions 22.6-22.8 ms against 19.8-20.3 ms. The frame is still shorter with it (median 24.6 against 25.9 ms), because the card no longer falls behind.

  • With ray tracing on (the same scene and settings, our branch on 84bd61e2 with this commit, one exe; the switch set against unset):

    card meter, the title's lists steady fps frames over 50 ms runs
    VICTORY_STRIDES_WB=1 (the table as before this change) 34.1, 36.7 ms 25.4, 27.1 95, 176 2
    unset (this change) 24.0-29.2 ms (mean 26.7) 31.1-35.6 (mean 33.0) 7-111 9

    The two runs with the switch were interleaved with two unset runs (e f f e, between two runs of an older build): one of those gave 28.7 ms and 32.0 fps, the other fell into a ray-tracing slowdown we also see on older builds (in about one run in four to ten, on this build and the one before it alike; the card's time per frame doubles or more at about 100 s and stays, whatever the table's memory) and is left out. The other eight unset runs are from two later series of the same evening on the same exe, so they are not interleaved with the runs that set the switch.

  • Not measured: other cards (the cost of the card's reads from write-back memory may differ on AMD or on an NVIDIA card of another generation, which is why the switch stays).

A possible follow-up

#2174's saving and this one need not exclude each other: the CPU could keep its own copy of the table in ordinary memory for the compare that skips unchanged entries, and write only the changed ones into the upload-memory table the card reads. Not in this PR.

Checked for overlap

  • I searched the pull requests and issues for strides table, SCRATCH_WB, write-back strides, 26d1d102 and STRIDES_WB (2026-11-30): #2174 is the change this follows; open #3501 (by its title, GVN and LICM of the SLOT_STRIDES reads in the translator, which would lower the number of reads) is related, not a duplicate; #3833 and #3807 are about raw twins. Searched again at 22:30 the same day: open #4333 (the lists' scratch in card memory the CPU maps, off by default) and #4320 (the lists' memory made ahead) are about the scratch chunks, not this table; open #4484 changes descriptor/host.rs elsewhere. No report of the card's time or of this default.

Written with Claude Code (Claude Fable 5.2); measured on my PC; reviewed by me.

🤖 Generated with Claude Code

**@⁠HQasper** on GitHub · 2026-11-30 21:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4500) `HQasper:pr/strides-upload-memory` → `main` · +9 −12 · 1 files · 13 commits · closed without merging Follows #2174 (merged as 26d1d102), whose default for the strides table this changes. ## What it changes #2174 (26d1d102) made each view heap's table of strides and guest addresses with `upload_buffer_maybe_wb(bytes, scratch_wb(host))`: in CPU write-back (`L0`) memory wherever the lists' scratch is, which is by itself on a discrete NVIDIA card (`VICTORY_SCRATCH_WB`). That made the CPU's updates of the table cheap (the heaps' records pass). The card reads the same table. Every shader that picks buffers from the view heap by an index it computes binds it as a root view (`t255`, `t252` or `t250` of space 1) and reads a dword of it for each such buffer. On an RTX 5090 those reads are slow from write-back memory: the programs that read the table take several times as long on the card, with the same dispatches and the same translation. With this change the table is made in upload memory again, as before #2174, unless `VICTORY_STRIDES_WB=1`. The lists' scratch chunks are not touched, and the rest of #2174 (the lock-free address lookup, the direct record read) stays. **What is in it:** `crates/victory-gpu/src/descriptor/host.rs` (`strides_wb`, `strides_wb_of`, used where the heap makes the table), and one test in the same file. ## How it was found Our branch on c71899d9 (v2026.11.30.01, our local commits rebased onto it) had more slow frames than the same commits on 41adb551: the card meter gave the title's lists 22-23 ms a frame against 15 ms, in the same scene, at the same frame rate. - **By command** (`VICTORY_GPU_TIMING`, diagnostics builds, steady part of the opening): dispatches 5.6-5.7 ms a frame on 41adb551 and 11.3 ms on c71899d9, in the same 3,414 commands a frame; indirect commands 6.2-6.3 against 8.0 ms. About 30 compute programs went from 0.01-0.07 ms to 0.13-0.57 ms a frame each: skinning (`512416d975ace48b`, `3a79195f06d3ed85`, `12eae112b559091c`), the compute graph (`2666062bd7f4c95d`, `7a38ed7f5205f384`, `a06ef09446bd6e70`), hair (`4a05640ec16718ad`, `269b802f878c24e1`), meshlet culling (`764ca63daec9c616`, `87bf9e3f2bf2f052`, `3b471c122be79b3e`). - **Not the translator:** 30 of these programs were translated by both builds with the runs' switches and disassembled. They differ in address masks (844200e9) and in the type of a few selects; no loop, cap or atomic differs. - **What they share:** of the 30, 26 read the strides table (`t255` or `t252`) and all 26 grew. Of the four that do not read it, three cost the same on both builds; one (`7b2c3c1db2298f44`, one dispatch) is 1.1 ms slower on c71899d9 for another reason, not settled, with or without this change. - **The card waits, it does not compute:** at the same frame rate and the same power (205-210 W) the card is 96-97 % busy on c71899d9 against 68-69 % on 41adb551. - **The switch settles it:** `VICTORY_SCRATCH_WB=0` on the c71899d9 build (the table and the scratch chunks in upload memory) brings the card's time by command from 21.7 ms a frame to 14.5 ms, and the 26 programs from 6.9 ms to 0.9 ms. - Also tried, without effect: `VICTORY_WINDOWS_BAR_MB=0` (#2313's windows in card memory the CPU maps): 22.2 ms. ## How it was tested - **New test** `descriptor::host::strides_wb_tests::the_strides_table_is_in_upload_memory_unless_asked_for`: unset, `0` and an empty value give upload memory whatever the scratch's kind; `1` gives write-back memory only where the scratch is write-back. `cargo test --locked -p victory-gpu --lib strides_wb` on this branch (9d50534b on 84bd61e2): 1 passed, 1199 filtered out. - **In game** (the opening from one save, RTX 5090, driver 621.24, 2560x1440 with DLSS Quality, ray tracing off, 170 s runs, 2026-11-30; our branch on c71899d9 without and with this commit, interleaved b r r b after one uncounted run; steady = seconds 60 to 120 of the world): | | card meter, the title's lists | steady fps | p99 | 1 % low | frames over 50 ms | card busy | power | |---|---|---|---|---|---|---|---| | without | 22.8, 24.6 ms | 38.4, 36.4 | 48.1, 53.7 ms | 19.4, 17.2 | 13, 50 | 97 % | 207-210 W | | with | 15.1, 15.4 ms | 39.9, 40.4 | 35.2, 33.0 ms | 26.5, 26.8 | 0, 0 | 72-74 % | 205-208 W | - **What it costs the CPU** (the same four runs): the heaps' records pass takes 5.3-5.5 ms a frame with this against 3.9-4.4 ms without (6.7 ms on 41adb551, before #2174), and the submitting thread's submissions 22.6-22.8 ms against 19.8-20.3 ms. The frame is still shorter with it (median 24.6 against 25.9 ms), because the card no longer falls behind. - **With ray tracing on** (the same scene and settings, our branch on 84bd61e2 with this commit, one exe; the switch set against unset): | | card meter, the title's lists | steady fps | frames over 50 ms | runs | |---|---|---|---|---| | `VICTORY_STRIDES_WB=1` (the table as before this change) | 34.1, 36.7 ms | 25.4, 27.1 | 95, 176 | 2 | | unset (this change) | 24.0-29.2 ms (mean 26.7) | 31.1-35.6 (mean 33.0) | 7-111 | 9 | The two runs with the switch were interleaved with two unset runs (e f f e, between two runs of an older build): one of those gave 28.7 ms and 32.0 fps, the other fell into a ray-tracing slowdown we also see on older builds (in about one run in four to ten, on this build and the one before it alike; the card's time per frame doubles or more at about 100 s and stays, whatever the table's memory) and is left out. The other eight unset runs are from two later series of the same evening on the same exe, so they are not interleaved with the runs that set the switch. - **Not measured:** other cards (the cost of the card's reads from write-back memory may differ on AMD or on an NVIDIA card of another generation, which is why the switch stays). ## A possible follow-up #2174's saving and this one need not exclude each other: the CPU could keep its own copy of the table in ordinary memory for the compare that skips unchanged entries, and write only the changed ones into the upload-memory table the card reads. Not in this PR. ## Checked for overlap - [x] I searched the pull requests and issues for `strides table`, `SCRATCH_WB`, `write-back strides`, `26d1d102` and `STRIDES_WB` (2026-11-30): #2174 is the change this follows; open #3501 (by its title, GVN and LICM of the `SLOT_STRIDES` reads in the translator, which would lower the number of reads) is related, not a duplicate; #3833 and #3807 are about raw twins. Searched again at 22:30 the same day: open #4333 (the lists' scratch in card memory the CPU maps, off by default) and #4320 (the lists' memory made ahead) are about the scratch chunks, not this table; open #4484 changes `descriptor/host.rs` elsewhere. No report of the card's time or of this default. --- Written with Claude Code (Claude Fable 5.2); measured on my PC; reviewed by me. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
26d1d102 made the table of strides and guest addresses of a view heap in CPU
write-back memory wherever the lists' scratch is (VICTORY_SCRATCH_WB, on by
itself on a discrete NVIDIA card), so that the CPU reads it back cheaply.
Every shader that picks buffers from the heap by an index it computes reads
that table on the card (the root views t255, t252 and t250 of space 1), and
on an RTX 5090 those reads are slow from write-back memory.

Opening of the game from one save, RTX 5090, ray tracing off, DLSS Quality:
- timed runs (VICTORY_GPU_TIMING): the card's time by command 21.7 ms a
  frame, 14.5 ms with VICTORY_SCRATCH_WB=0, 13.9-14.5 ms on the base before
  26d1d102; the 26 compute programs timed that read the table 6.9 ms against
  0.9-1.0 ms, the same dispatches;
- normal runs, interleaved, two each: the card meter's time of the title's
  lists 22.8 and 24.6 ms without this, 15.1 and 15.4 ms with it; steady
  frame rate 38.4 and 36.4 against 39.9 and 40.4 fps, p99 48.1 and 53.7
  against 35.2 and 33.0 ms, frames over 50 ms 13 and 50 against 0 and 0; the
  card 97 % busy against 72-74 % at the same 205-210 W.

VICTORY_STRIDES_WB=1 puts the table where the scratch is, as before this.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 21:29:42 +00:00
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:39 UTC · original

One thing to weigh for PCs where the submitting thread, not the card, is the limit: here the records pass costs 1.1-1.4 ms more a frame (5.3-5.5 against 3.9-4.4 ms) and submissions 2.5-3 ms more. On a Ryzen 5 5600X with an RTX 3060 (Series S, DLSS Performance) our submitting thread is busy 44-54 ms of a 55-58 ms frame and the card idles 14-21 ms of it waiting for that thread, so CPU time added there tends to show directly in the frame, while card time saved shows only in the busiest frames. We have not measured VICTORY_STRIDES_WB on the 3060 yet and will A/B it. Until then, the follow-up in the description (a CPU-side copy for the compare, only changed entries written into the upload table) looks like the version that suits both kinds of PC.

Small thing: strides_wb (descriptor/host.rs:32-34) reads the variable by hand; crate::asked_for!("VICTORY_STRIDES_WB") is the repo's helper for an on-only-when-1 switch (switch.rs).

**@⁠IRennie74** on GitHub · 2026-11-30 22:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4500#issuecomment-7294124916) One thing to weigh for PCs where the submitting thread, not the card, is the limit: here the records pass costs 1.1-1.4 ms more a frame (5.3-5.5 against 3.9-4.4 ms) and submissions 2.5-3 ms more. On a Ryzen 5 5600X with an RTX 3060 (Series S, DLSS Performance) our submitting thread is busy 44-54 ms of a 55-58 ms frame and the card idles 14-21 ms of it waiting for that thread, so CPU time added there tends to show directly in the frame, while card time saved shows only in the busiest frames. We have not measured `VICTORY_STRIDES_WB` on the 3060 yet and will A/B it. Until then, the follow-up in the description (a CPU-side copy for the compare, only changed entries written into the upload table) looks like the version that suits both kinds of PC. Small thing: `strides_wb` (`descriptor/host.rs:32-34`) reads the variable by hand; `crate::asked_for!("VICTORY_STRIDES_WB")` is the repo's helper for an on-only-when-`1` switch (`switch.rs`).
Author
Owner

@⁠HQasper on GitHub · 2026-12-01 05:40 UTC · original

Thanks, both points taken.

  • asked_for!: done in d7ed1464. strides_wb now reads VICTORY_STRIDES_WB through crate::asked_for!, and the test covers the combination with the scratch's kind. The same push merges upstream main in (it was force-updated, so the branch had conflicted); the PR is back to the one file.
  • The submitting-thread cost: agreed, that is the trade here. With VICTORY_STRIDES_WB unset the table stays in upload memory, which is the card-bound win on the RTX 5090, and the records pass pays the 1.1-1.4 ms you quote. We have not measured it on a CPU-bound PC like your 5600X + 3060, so an A/B from you would be welcome. The CPU-side copy for the compare, writing only changed entries into the upload table, is the follow-up we want to try; it would be a separate change from this one.
**@⁠HQasper** on GitHub · 2026-12-01 05:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4500#issuecomment-7302014460) Thanks, both points taken. - `asked_for!`: done in d7ed1464. `strides_wb` now reads `VICTORY_STRIDES_WB` through `crate::asked_for!`, and the test covers the combination with the scratch's kind. The same push merges upstream main in (it was force-updated, so the branch had conflicted); the PR is back to the one file. - The submitting-thread cost: agreed, that is the trade here. With `VICTORY_STRIDES_WB` unset the table stays in upload memory, which is the card-bound win on the RTX 5090, and the records pass pays the 1.1-1.4 ms you quote. We have not measured it on a CPU-bound PC like your 5600X + 3060, so an A/B from you would be welcome. The CPU-side copy for the compare, writing only changed entries into the upload table, is the follow-up we want to try; it would be a separate change from this one.
github-bot closed this pull request 2026-12-01 18:43:22 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:39 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4500#issuecomment-7321298932) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4501
No description provided.