Diagnostics: renderer port 2 trace watches a missed record's writers (VICTORY_PORT_DESCRIPTORS_TRACE=1) #385

Closed
github-bot wants to merge 2 commits from github-bot/gh-385 into main AGit
Owner

@⁠Sr-0w on GitHub · 2026-11-26 21:55 UTC · original
port2/descriptor-trace → main · +675 −29 · 4 files · 2 commits · closed without merging

Stacked on #359: it uses #359's place(), which names an address by module and offset. Until #359 is merged, this branch carries its commit 8436b3f. This PR's own change is the last commit, 5c1c9be.

Port 2's fallback (VICTORY_PORT_DESCRIPTORS=1) names the writer of a view record no mark told of by the last fault on the record's 64 KiB block. That is a hint only. The title's frame allocator puts descriptor records, constants, list nodes and vertex data in the same blocks, so any write to the block counts. For example, title+0x3368420 fills 24-byte vertices from the same allocator, and its stores show up as "writers" of descriptor slots. Finding the code that writes a missed record needs a watch on the record itself.

Change (diagnostics builds only, VICTORY_PORT_DESCRIPTORS_TRACE=1, off by default)

  • When the fallback finds a view record unmarked, that slot gets four hardware write watches (DR0-3, 8 bytes each, covering its 32 bytes) in every thread of the process. One slot is watched at a time.
  • Each write traps once. The log gets the instruction after the store, which 8 bytes of the record it wrote, the thread, and the code addresses on the writer's stack (by module and offset, through #359's place()).
  • The watch stands until the fallback finds the same slot unmarked again. The writes are then logged in order, the last one as CONFIRMED: a write the marks miss. If that does not happen within 20 s, the writes are logged as candidates.
  • Threads made after the arming are not watched. Nothing changes without the switch or in release builds.
  • README: the switch is listed under the port switches.

What it showed

RX 7800 XT, Series X, ray tracing on, renderer ports 1, 2, 5, 6, 7 on, #359 + #273, a retail game's boat scene, 300 s runs.

  • About 100 slots watched a run, 2-16 writes each. All writes to slots that held view records came from the stores #359 patches (stub code near the title) or from VCRUNTIME140!memcpy called through port 2's own wrapper. No other title code wrote them.
  • The wrapper's copies marked no record (#359's 0 records they marked), so the misses had to come from those copies. That led to #384: a copy that rewrites a record's later words marks nothing. With #384, misses fall from 101 to 6 a frame.
  • With #384 in, no write is confirmed in 300 s. The 6 misses a frame left are rare enough that a slot found missed is seldom missed again within 20 s.

Checks

  • cargo clippy -p victory-gpu --features diagnostics --all-targets --locked -- -D warnings: nothing in the changed code.
  • cargo test -p victory-gpu --locked --lib port_descriptors: passed.
  • In game: the runs above, no crash or device loss, about 1 fps lower while the trace is on.

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-26 21:55 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/385) `port2/descriptor-trace` → `main` · +675 −29 · 4 files · 2 commits · closed without merging **Stacked on #359**: it uses #359's `place()`, which names an address by module and offset. Until #359 is merged, this branch carries its commit 8436b3f. This PR's own change is the last commit, 5c1c9be. Port 2's fallback (`VICTORY_PORT_DESCRIPTORS=1`) names the writer of a view record no mark told of by the last fault on the record's 64 KiB block. That is a hint only. The title's frame allocator puts descriptor records, constants, list nodes and vertex data in the same blocks, so any write to the block counts. For example, `title+0x3368420` fills 24-byte vertices from the same allocator, and its stores show up as "writers" of descriptor slots. Finding the code that writes a missed record needs a watch on the record itself. ## Change (diagnostics builds only, `VICTORY_PORT_DESCRIPTORS_TRACE=1`, off by default) - When the fallback finds a view record unmarked, that slot gets four hardware write watches (DR0-3, 8 bytes each, covering its 32 bytes) in every thread of the process. One slot is watched at a time. - Each write traps once. The log gets the instruction after the store, which 8 bytes of the record it wrote, the thread, and the code addresses on the writer's stack (by module and offset, through #359's `place()`). - The watch stands until the fallback finds the same slot unmarked again. The writes are then logged in order, the last one as `CONFIRMED`: a write the marks miss. If that does not happen within 20 s, the writes are logged as candidates. - Threads made after the arming are not watched. Nothing changes without the switch or in release builds. - README: the switch is listed under the port switches. ## What it showed RX 7800 XT, Series X, ray tracing on, renderer ports 1, 2, 5, 6, 7 on, #359 + #273, a retail game's boat scene, 300 s runs. - About 100 slots watched a run, 2-16 writes each. All writes to slots that held view records came from the stores #359 patches (stub code near the title) or from `VCRUNTIME140!memcpy` called through port 2's own wrapper. No other title code wrote them. - The wrapper's copies marked no record (#359's `0 records they marked`), so the misses had to come from those copies. That led to #384: a copy that rewrites a record's later words marks nothing. With #384, misses fall from 101 to 6 a frame. - With #384 in, no write is confirmed in 300 s. The 6 misses a frame left are rare enough that a slot found missed is seldom missed again within 20 s. ## Checks - `cargo clippy -p victory-gpu --features diagnostics --all-targets --locked -- -D warnings`: nothing in the changed code. - `cargo test -p victory-gpu --locked --lib port_descriptors`: passed. - In game: the runs above, no crash or device loss, about 1 fps lower while the trace is on. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The fallback of VICTORY_PORT_DESCRIPTORS=1 found 290-410 view records a
frame that no mark told of. +0x4d9f200 copies a ready list of records into a
table of the frame allocator with four `vmovups [rbx+disp]` (128 bytes) or
the imported memcpy, and +0x4e51a90, +0x248d6d0 and +0x248d780 have a
callback fill one. Each is hooked where it goes on once the table is filled
(Kind::Range): every slot of [table, table+size) is marked. A moved
`mov eax, [rip+x]` is done from its address (Moved::LoadEax).

Diagnostics: port 2's line counts memcpy calls that begin half into a slot
and the view records they put there (run: ~3,300 calls a frame, 0 records),
and a writer outside the title is named by module, with the title code that
called it when the top of its stack is in the title.

RTX 2070, ports 1,2,5,6,7, 7 min: misses 1.44 per 1000 slots told on main,
0.67 with the first of the four sites.
Port 2's fallback names a missed record's writer by the last fault on its
64 KiB block, which the frame allocator shares with constants and vertex
data. With the switch, a slot the fallback found unmarked gets hardware
write watches on its 32 bytes in every thread; each write is logged with
the instruction, the part it wrote, the thread and its callers, and the
last write before the fallback finds the slot unmarked again is said as
CONFIRMED.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:56:22 +00:00
github-bot closed this pull request 2026-11-27 14:52:47 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.