Builder on: the 3 s frames are CPU work in memory::ready (1,023 copies, 4.3 GB refreshed and declared written per list); taking the dirty-page mask #284

Open
opened 2026-11-26 03:39:53 +00:00 by github-bot · 2 comments
Owner

@⁠ghost on GitHub · 2026-11-24 23:14 UTC · original

AI-assisted (Claude Code). Numbers and log lines only; no game data. I am taking the fix described at the end unless someone already has it.

Setup: RTX 5080 16 GB (32-lane waves), Windows 11. Fork main (4e17478 base) + #156 at ebc2c91, diag build, Series X profile, VICTORY_SHADER_LOOP_LIMIT=256, warm caches, scripted Enter, 300 s runs. Builder runs use VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1.

What I measured

#156 reports that with the builder on "the frame time went from about 0.3 s to about 4 s". Same here: 0.45 s to 3.2-3.4 s per frame, no device loss, no title crash in 300 s. The card is not where the time goes:

per frame builder off builder on
frame time 449 ms 3,180-3,440 ms
on the GPU 224 ms 274-345 ms
preparing 113 ms 1,410-1,560 ms
copying back 57 ms (63 MB) 1,250-1,435 ms (69-87 MB)
submitting thread inside its submissions 98 ms user + 82 ms kernel 1,383-1,586 ms user + 1,203-1,234 ms kernel
ranges compared after submissions 662 1,453

(From the fps and copystat lines of each run's last report.)

Why

memory::ready (crates/victory-gpu/src/memory.rs) brings every numbered copy up to date on a list's first dispatch of a shader that uses title memory by address, and for a shader that can store declares every numbered copy written, so all of those bytes are compared on the CPU after the submission. The module's own comment calls this a shortcut.

A local counter in ready (one log line per 8 frames, builder on):

frame=1968 copies=1023 mb=4285 calls=4967 lists_reading=13 lists_writing=9
frame=1976 copies=1023 mb=4285 calls=3422 lists_reading=40 lists_writing=32
frame=2000 copies=1023 mb=4285 calls=4809 lists_reading=32 lists_writing=24
frame=2040 copies=1023 mb=4285 calls=3121 lists_reading=37 lists_writing=29

So in the prologue:

  • 1,023 copies are numbered, which is the limit (COPIES), holding 4,285 MB. The limit is already reached at the first line logged.
  • About 4 to 5 lists a frame refresh all 4,285 MB, and 3 to 4 lists a frame declare all 4,285 MB written: roughly 17-21 GB checked for refresh and 13-17 GB declared written, every frame.
  • title memory by address: no number left for another copy; its pages read zeros is logged in the same run. So besides the cost, some pages the builder or the trace programs ask for have no copy at all and read zero. I have not measured how many accesses that affects, nor whether it has to do with the washed-out picture #156 describes (I see that picture too).

What I plan to do

The remedy the module's comment names: a dirty-page mask written by the shader, so that a list refreshes and the host compares only the 64 KiB pages a dispatch touched. As a first step: a bit per directory page set by Lower::memory on each store (and, if it measures well, on each load), read back with the faults once the submission has run, with gpu_writes limited to the pages set.

I will build it on top of #156 and keep clear of the per-list watermarks #205 adds to the same function. If either author would rather fold this in themselves, say so and I will send the measurements instead.

Not covered by this: the limit of 1,023 copies itself, the washed-out picture, and the box-bounds crash in #16.

**@⁠ghost** on GitHub · 2026-11-24 23:14 UTC · [original](https://github.com/fxceless/victory-fork/issues/284) *AI-assisted (Claude Code). Numbers and log lines only; no game data. I am taking the fix described at the end unless someone already has it.* **Setup:** RTX 5080 16 GB (32-lane waves), Windows 11. Fork `main` (`4e17478` base) + #156 at `ebc2c91`, diag build, Series X profile, `VICTORY_SHADER_LOOP_LIMIT=256`, warm caches, scripted Enter, 300 s runs. Builder runs use `VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1`. ## What I measured #156 reports that with the builder on "the frame time went from about 0.3 s to about 4 s". Same here: 0.45 s to 3.2-3.4 s per frame, no device loss, no title crash in 300 s. The card is not where the time goes: | per frame | builder off | builder on | |---|---|---| | frame time | 449 ms | 3,180-3,440 ms | | on the GPU | 224 ms | 274-345 ms | | preparing | 113 ms | 1,410-1,560 ms | | copying back | 57 ms (63 MB) | 1,250-1,435 ms (69-87 MB) | | submitting thread inside its submissions | 98 ms user + 82 ms kernel | 1,383-1,586 ms user + 1,203-1,234 ms kernel | | ranges compared after submissions | 662 | 1,453 | (From the `fps` and `copystat` lines of each run's last report.) ## Why `memory::ready` (`crates/victory-gpu/src/memory.rs`) brings every numbered copy up to date on a list's first dispatch of a shader that uses title memory by address, and for a shader that can store declares every numbered copy written, so all of those bytes are compared on the CPU after the submission. The module's own comment calls this a shortcut. A local counter in `ready` (one log line per 8 frames, builder on): ``` frame=1968 copies=1023 mb=4285 calls=4967 lists_reading=13 lists_writing=9 frame=1976 copies=1023 mb=4285 calls=3422 lists_reading=40 lists_writing=32 frame=2000 copies=1023 mb=4285 calls=4809 lists_reading=32 lists_writing=24 frame=2040 copies=1023 mb=4285 calls=3121 lists_reading=37 lists_writing=29 ``` So in the prologue: - **1,023 copies are numbered, which is the limit (`COPIES`), holding 4,285 MB.** The limit is already reached at the first line logged. - About 4 to 5 lists a frame refresh all 4,285 MB, and 3 to 4 lists a frame declare all 4,285 MB written: roughly 17-21 GB checked for refresh and 13-17 GB declared written, every frame. - `title memory by address: no number left for another copy; its pages read zeros` is logged in the same run. So besides the cost, some pages the builder or the trace programs ask for have no copy at all and read zero. I have not measured how many accesses that affects, nor whether it has to do with the washed-out picture #156 describes (I see that picture too). ## What I plan to do The remedy the module's comment names: **a dirty-page mask written by the shader**, so that a list refreshes and the host compares only the 64 KiB pages a dispatch touched. As a first step: a bit per directory page set by `Lower::memory` on each store (and, if it measures well, on each load), read back with the faults once the submission has run, with `gpu_writes` limited to the pages set. I will build it on top of #156 and keep clear of the per-list watermarks #205 adds to the same function. If either author would rather fold this in themselves, say so and I will send the measurements instead. Not covered by this: the limit of 1,023 copies itself, the washed-out picture, and the box-bounds crash in #16.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:39:53 +00:00
Author
Owner

@⁠ghost on GitHub · 2026-11-25 00:31 UTC · original

AI-assisted (Claude Code). Counts only; no game data.

Follow-up on the copy limit: with the builder on, shaders ask for far more than 1,023 copies, and the requests are spread over most of the title's memory. Same card and setup as above (RTX 5080, #156 merged, VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1, 300 s runs). Measured with a local build in which loads mark their copy as stores do in #346, plus counters in memory.rs; none of that is in #346.

How many copies are used

count
copies numbered 1,023 (the limit; 1,010 of them 4 MiB windows)
numbered copies a load ever reached 742-807 (3.2-3.6 GB), about 270 in any one frame
numbered copies a store ever reached 53-55
map calls refused for want of a number 1,000-5,000 a frame
distinct copies refused, asked for by a fault note (a shader's own access) at least 1,408 (5.7-5.9 GB), still growing when the run ended
distinct copies refused in all (fault notes and what dispatches name) at least 2,560 (10.3 GB)

So the limit is not being used up by constants that only look like addresses: about three quarters of the numbered copies are read, and most of the refusals come from shaders' own accesses.

With the builder off, nothing uses this path. Same build, defaults: 0 copies numbered, 0 loads, 0 stores, 0 refusals for the whole run.

Where the requests lie, in copies per GiB of title address space (a GiB holds 256 windows):

  • numbered: GiB 28, 44-61, 64-65;
  • refused, asked for by a fault note: GiB 0, 4-8, 20-32, 44-65;
  • in GiB 49-53, numbered plus refused comes to 150-207 of the 256 windows.

That is most of the title's big pool being walked, 9 GB and more in all, for one room and a yard. I would expect a traversal to stay inside the structures its rays cross. This looks to me like a traversal that follows bad links or enters every box, which would fit the unfilled box bounds reported in #16; I have not shown that, and it could also be that the structures are simply laid out across the pool.

If it is the builder's output, raising COPIES would mostly make room for reads that should not happen, so I am not proposing that. The picture with the builder on is wrong here as well (quarantined): the cell window is covered by a mesh pattern and the room is missing.

What would settle it, if someone has the means before I do: the same counts on a 64-lane card, where the builder's programs run in their native form.

**@⁠ghost** on GitHub · 2026-11-25 00:31 UTC · [original](https://github.com/fxceless/victory-fork/issues/284#issuecomment-7148601939) *AI-assisted (Claude Code). Counts only; no game data.* **Follow-up on the copy limit: with the builder on, shaders ask for far more than 1,023 copies, and the requests are spread over most of the title's memory.** Same card and setup as above (RTX 5080, #156 merged, `VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1`, 300 s runs). Measured with a local build in which loads mark their copy as stores do in #346, plus counters in `memory.rs`; none of that is in #346. **How many copies are used** | | count | |---|---| | copies numbered | 1,023 (the limit; 1,010 of them 4 MiB windows) | | numbered copies a load ever reached | 742-807 (3.2-3.6 GB), about 270 in any one frame | | numbered copies a store ever reached | 53-55 | | `map` calls refused for want of a number | 1,000-5,000 a frame | | distinct copies refused, asked for by a fault note (a shader's own access) | at least 1,408 (5.7-5.9 GB), still growing when the run ended | | distinct copies refused in all (fault notes and what dispatches name) | at least 2,560 (10.3 GB) | So the limit is not being used up by constants that only look like addresses: about three quarters of the numbered copies are read, and most of the refusals come from shaders' own accesses. **With the builder off, nothing uses this path.** Same build, defaults: 0 copies numbered, 0 loads, 0 stores, 0 refusals for the whole run. **Where the requests lie**, in copies per GiB of title address space (a GiB holds 256 windows): - numbered: GiB 28, 44-61, 64-65; - refused, asked for by a fault note: GiB 0, 4-8, 20-32, 44-65; - in GiB 49-53, numbered plus refused comes to 150-207 of the 256 windows. That is most of the title's big pool being walked, 9 GB and more in all, for one room and a yard. I would expect a traversal to stay inside the structures its rays cross. This looks to me like a traversal that follows bad links or enters every box, which would fit the unfilled box bounds reported in #16; I have not shown that, and it could also be that the structures are simply laid out across the pool. If it is the builder's output, raising `COPIES` would mostly make room for reads that should not happen, so I am not proposing that. The picture with the builder on is wrong here as well (quarantined): the cell window is covered by a mesh pattern and the room is missing. What would settle it, if someone has the means before I do: the same counts on a 64-lane card, where the builder's programs run in their native form.
Author
Owner

@⁠Speartone on GitHub · 2026-11-25 04:34 UTC · original

Research only, not for merging: an experiment on 2119b0e that gives numbered copies back when nothing uses them. Synthetic data only; actual GTA VI gameplay has not been tested.

  • A mark per looked-up copy cost an RTX 5080 7.1 -> 11.6 ms for 8.4 million lookups. Arming directory entries only at times brought it back to 7.1 ms.
  • A copy without use for 10 s and 4 frames is released: 353 -> 109 numbered copies in a synthetic moving working set, host copies 1,412 -> 436 MB.
  • Open defect: a released page reached only through a pointer reads zeros for one frame. For the structure builder that can be a dropped stage, so it must not be used as is.
  • Counting covered copies by number (#205) misses numbers that are reused; generations per list do not.
  • It uses the same slots as the store marks in #346. That layout should win if both go on.
  • 14 targeted tests pass on RTX 5080, AMD RDNA2 and WARP.

AI-assisted: design, code, tests and text by Claude Code (Claude Opus 5.5). No game data.

**@⁠Speartone** on GitHub · 2026-11-25 04:34 UTC · [original](https://github.com/fxceless/victory-fork/issues/284#issuecomment-7152967587) Research only, not for merging: an experiment on 2119b0e that gives numbered copies back when nothing uses them. Synthetic data only; actual GTA VI gameplay has not been tested. - A mark per looked-up copy cost an RTX 5080 7.1 -> 11.6 ms for 8.4 million lookups. Arming directory entries only at times brought it back to 7.1 ms. - A copy without use for 10 s and 4 frames is released: 353 -> 109 numbered copies in a synthetic moving working set, host copies 1,412 -> 436 MB. - Open defect: a released page reached only through a pointer reads zeros for one frame. For the structure builder that can be a dropped stage, so it must not be used as is. - Counting covered copies by number (#205) misses numbers that are reused; generations per list do not. - It uses the same slots as the store marks in #346. That layout should win if both go on. - 14 targeted tests pass on RTX 5080, AMD RDNA2 and WARP. AI-assisted: design, code, tests and text by Claude Code (Claude Opus 5.5). No game data.
This discussion has been locked. Commenting is limited to contributors.
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/fxceless--victory-fork#284
No description provided.