GPU diagnostics: DRED command notes call VirtualQuery per draw, world frames ~10x slower (fix on a fork) #913

Open
opened 2026-11-26 04:14:09 +00:00 by github-bot · 4 comments
Owner

@⁠Vaximous on GitHub · 2026-11-24 14:02 UTC · original

Diagnostics-only: this affects only --features diagnostics builds that run with device-removed data on.

Problem

With DRED command notes on, world frames took 9-12 s instead of under 1 s. Most of the recording threads' time went to VirtualQuery.

Cause: describe in crates/victory-gpu/src/draw.rs runs for every draw and dispatch (through op_text → reads). For a constant view, it first asks texture::committed, which uses VirtualQuery, before it reads 16 bytes. In the title's big pools each query walks the region's pages, about 1 ms per call, and a world frame makes thousands of them.

Fix

first_words reads the 16 bytes with host::read_into (ReadProcessMemory). That call fails on an unmapped page and does not walk the region. Output is unchanged. One file, crates/victory-gpu/src/draw.rs, +15/-3, all inside #[cfg(feature = "diagnostics")].

Branch

https://github.com/Vaximous/VIctory/compare/main...fix/dred-notes-readprocessmemory — commit f4b6a96, based on ffe310e.

Tested

  • cargo test -p victory-gpu --features diagnostics: 53 passed, 0 failed, 1 ignored. Clippy -D warnings is clean with and without diagnostics.
  • Runtime (RTX 4070 Ti, Windows 11): measured on our local integration build (main plus a set of open PRs), not on plain main. In that build, placed buffer views' notes also read title words through the same check. Five recording threads spent about 77% of their time in VirtualQuery, and frames took 9-12 s. With ReadProcessMemory instead, frames were back under 1 s. Main only has the constant-view path, so the gain there may be smaller.

texture::committed is also used on hot non-diagnostic paths (host.rs, list.rs), and #322, #388 and #119 remove region queries there. This issue is only about the DRED note.

AI use

Written with Claude Code (Claude Opus 5.5); tested locally.

**@⁠Vaximous** on GitHub · 2026-11-24 14:02 UTC · [original](https://github.com/Marvisak/VIctory/issues/913) Diagnostics-only: this affects only `--features diagnostics` builds that run with device-removed data on. ## Problem With DRED command notes on, world frames took 9-12 s instead of under 1 s. Most of the recording threads' time went to `VirtualQuery`. Cause: `describe` in `crates/victory-gpu/src/draw.rs` runs for every draw and dispatch (through `op_text` → `reads`). For a constant view, it first asks `texture::committed`, which uses `VirtualQuery`, before it reads 16 bytes. In the title's big pools each query walks the region's pages, about 1 ms per call, and a world frame makes thousands of them. ## Fix `first_words` reads the 16 bytes with `host::read_into` (ReadProcessMemory). That call fails on an unmapped page and does not walk the region. Output is unchanged. One file, `crates/victory-gpu/src/draw.rs`, +15/-3, all inside `#[cfg(feature = "diagnostics")]`. ## Branch https://github.com/Vaximous/VIctory/compare/main...fix/dred-notes-readprocessmemory — commit f4b6a96, based on ffe310e. ## Tested - `cargo test -p victory-gpu --features diagnostics`: 53 passed, 0 failed, 1 ignored. Clippy `-D warnings` is clean with and without `diagnostics`. - Runtime (RTX 4070 Ti, Windows 11): measured on our local integration build (main plus a set of open PRs), not on plain main. In that build, placed buffer views' notes also read title words through the same check. Five recording threads spent about 77% of their time in `VirtualQuery`, and frames took 9-12 s. With `ReadProcessMemory` instead, frames were back under 1 s. Main only has the constant-view path, so the gain there may be smaller. ## Related `texture::committed` is also used on hot non-diagnostic paths (`host.rs`, `list.rs`), and #322, #388 and #119 remove region queries there. This issue is only about the DRED note. ## AI use Written with Claude Code (Claude Opus 5.5); tested locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:09 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 14:05 UTC · original

On a #898-based integration, the Wine 11.22 formatter test passed with #913. A backed 16-byte constant view retained its exact four-float text, including negative zero. A 12-byte view kept the existing short description. The production diff also applies cleanly to all 16 source revisions used for our #898 comparison builds. Only the one integration ran the formatter test.

The 9–12 s to under 1 s frame-time result remains specific to your Windows integration, which also inspected placed buffer views. We have no local title timing for the constant-view-only change.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 14:05 UTC · [original](https://github.com/Marvisak/VIctory/issues/913#issuecomment-7133825117) On a #898-based integration, the Wine 11.22 formatter test passed with #913. A backed 16-byte constant view retained its exact four-float text, including negative zero. A 12-byte view kept the existing short description. The production diff also applies cleanly to all 16 source revisions used for our #898 comparison builds. Only the one integration ran the formatter test. The 9–12 s to under 1 s frame-time result remains specific to your Windows integration, which also inspected placed buffer views. We have no local title timing for the constant-view-only change.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:51 UTC · original

Automated triage for the maintainers.

Confirmed on current main: in crates/victory-gpu/src/draw.rs, the diagnostics description of a view (the small closure used for DRED command notes) calls crate::texture::committed before reading up to 64 bytes of title memory, once per described view on every draw and dispatch. How much that costs on plain main is not measured; the 9–12 s frames were on an integration build that also describes placed buffer views. I found no open pull request for f4b6a96; pull requests are open to everyone now, so please open one against current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:51 UTC · [original](https://github.com/Marvisak/VIctory/issues/913#issuecomment-7155225950) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T14:05:30Z at=2026-11-25T06:51:10Z --> Automated triage for the maintainers. Confirmed on current `main`: in `crates/victory-gpu/src/draw.rs`, the diagnostics description of a view (the `small` closure used for DRED command notes) calls `crate::texture::committed` before reading up to 64 bytes of title memory, once per described view on every draw and dispatch. How much that costs on plain `main` is not measured; the 9–12 s frames were on an integration build that also describes placed buffer views. I found no open pull request for `f4b6a96`; pull requests are open to everyone now, so please open one against current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-26 06:57 UTC · original

Three things on this, measured on main 63bcca4: the case this issue names is already fixed upstream, a sibling call still is not, and on this card device-removed data does not merely slow the run — it reliably hangs the device. The remaining VirtualQuery call is not the cause of that.

RTX 3080 (Ampere) / Windows 11, release build with --features diagnostics, keyless start-up, VICTORY_LOG=info.

1. The constant-view case is fixed on main

describe no longer asks VirtualQuery for a constant view's first 16 bytes; it reads them through the kernel, with a comment giving this issue's reasoning:

// The first four values, as a colour rectangle's constants are, read
// through the kernel (asking `VirtualQuery` first cost milliseconds
// per draw in the title's pools, with every draw noted).
Some(View::Constant(address, size)) if *size >= 16 => {
    let mut bytes = [0u8; 16];
    if crate::host::read_into(*address as *const u8, &mut bytes) {

git log -S puts that in 6d021fe ("GPU: world frame cost"). So the fork branch here (f4b6a96, based on ffe310e) now conflicts with main in exactly that hunk and is redundant for the case it targets.

2. A sibling call in the same function still goes through VirtualQuery

The small closure in the same describe, for buffers of 64 bytes or less (exposure, counters), still asks first:

Some((at, len)) if len <= 64 && crate::texture::committed(at as *const u8, len as usize) => {

That is crates/victory-gpu/src/draw.rs:1964 on 63bcca4, and it runs per draw like the other one, so the pattern this issue describes is not fully gone.

3. With device-removed data on, this card does not slow down — it hangs

This is the part I did not expect, and it is not in the issue:

configuration runs device removals frames reached peak commit
VICTORY_LOG=info only 13 0 4,096 17-18 GB
+ VICTORY_D3D12_DRED=1 3 3 1,299-1,529 21-24 GB

Every removal is 0x887A0006 ("the GPU will not respond to more commands"), with no E_OUTOFMEMORY anywhere in any log. Same build, same card, same keyless path; the only difference is the switch. Without it the run presents 4,096 frames in ~142 s; with it the device is gone inside ~75 s. Device-removed data also costs 4-6 GB of commit here, which on a 32 GB box is not nothing.

What is not the cause

I assumed the surviving call in (2) explained (3) and tested it rather than posting it: patching that small closure to read through the kernel too, exactly as the constant-view case now does, does not help — 2 runs out of 2 still hang, at frames 1,225 and 1,267, with commit 23.6-23.8 GB. So on this card the dominant cost of device-removed data is somewhere else: the remaining per-draw note building, or D3D12's own auto-breadcrumb and page-fault tracking. I have not identified it, and I would rather say so than name a culprit I have not shown.

Why it matters beyond performance

Hang reports in this project are routinely gathered with VICTORY_D3D12_DRED=1 on, because that is what names the stopped command. On this configuration that switch is the difference between a run that completes and a run whose device is removed, so a hang observed with it on may not be the hang a user hits without it. That does not make existing reports wrong — they are mostly in the world, far deeper than anything above, and many report the hang with DRED off as well. It does mean the switch belongs in the environment list of a hang report, and that a report where the hang appears only with DRED on is worth re-running without it.

Not claimed: no world run (keyless start-up reaches an early screen at about 13 draws a frame, nowhere near the world), no profiling of where the time actually goes, and one card and driver only.

Counts, timings and code references only; no game files, no program hashes or paths. AI-assisted (Claude Code); all runs as described on this host.

**@⁠BaggyALPHA** on GitHub · 2026-11-26 06:57 UTC · [original](https://github.com/Marvisak/VIctory/issues/913#issuecomment-7184946288) **Three things on this, measured on `main` `63bcca4`: the case this issue names is already fixed upstream, a sibling call still is not, and on this card device-removed data does not merely slow the run — it reliably hangs the device. The remaining `VirtualQuery` call is not the cause of that.** RTX 3080 (Ampere) / Windows 11, release build with `--features diagnostics`, keyless start-up, `VICTORY_LOG=info`. ### 1. The constant-view case is fixed on `main` `describe` no longer asks `VirtualQuery` for a constant view's first 16 bytes; it reads them through the kernel, with a comment giving this issue's reasoning: ```rust // The first four values, as a colour rectangle's constants are, read // through the kernel (asking `VirtualQuery` first cost milliseconds // per draw in the title's pools, with every draw noted). Some(View::Constant(address, size)) if *size >= 16 => { let mut bytes = [0u8; 16]; if crate::host::read_into(*address as *const u8, &mut bytes) { ``` `git log -S` puts that in **`6d021fe`** ("GPU: world frame cost"). So the fork branch here (`f4b6a96`, based on `ffe310e`) now conflicts with `main` in exactly that hunk and is redundant for the case it targets. ### 2. A sibling call in the same function still goes through `VirtualQuery` The `small` closure in the same `describe`, for buffers of 64 bytes or less (exposure, counters), still asks first: ```rust Some((at, len)) if len <= 64 && crate::texture::committed(at as *const u8, len as usize) => { ``` That is `crates/victory-gpu/src/draw.rs:1964` on `63bcca4`, and it runs per draw like the other one, so the pattern this issue describes is not fully gone. ### 3. With device-removed data on, this card does not slow down — it hangs This is the part I did not expect, and it is not in the issue: | configuration | runs | device removals | frames reached | peak commit | |---|---:|---:|---:|---:| | `VICTORY_LOG=info` only | **13** | **0** | 4,096 | 17-18 GB | | `+ VICTORY_D3D12_DRED=1` | **3** | **3** | 1,299-1,529 | 21-24 GB | Every removal is `0x887A0006` ("the GPU will not respond to more commands"), with no `E_OUTOFMEMORY` anywhere in any log. Same build, same card, same keyless path; the only difference is the switch. Without it the run presents 4,096 frames in ~142 s; with it the device is gone inside ~75 s. Device-removed data also costs **4-6 GB of commit** here, which on a 32 GB box is not nothing. ### What is *not* the cause I assumed the surviving call in (2) explained (3) and tested it rather than posting it: patching that `small` closure to read through the kernel too, exactly as the constant-view case now does, **does not help** — 2 runs out of 2 still hang, at frames 1,225 and 1,267, with commit 23.6-23.8 GB. So on this card the dominant cost of device-removed data is somewhere else: the remaining per-draw note building, or D3D12's own auto-breadcrumb and page-fault tracking. I have not identified it, and I would rather say so than name a culprit I have not shown. ### Why it matters beyond performance Hang reports in this project are routinely gathered with `VICTORY_D3D12_DRED=1` on, because that is what names the stopped command. On this configuration that switch is the difference between a run that completes and a run whose device is removed, so a hang observed with it on may not be the hang a user hits without it. That does not make existing reports wrong — they are mostly in the world, far deeper than anything above, and many report the hang with DRED off as well. It does mean the switch belongs in the environment list of a hang report, and that a report where the hang appears only with DRED on is worth re-running without it. Not claimed: no world run (keyless start-up reaches an early screen at about 13 draws a frame, nowhere near the world), no profiling of where the time actually goes, and one card and driver only. Counts, timings and code references only; no game files, no program hashes or paths. AI-assisted (Claude Code); all runs as described on this host.
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-26 07:04 UTC · original · edited 2026-11-26 07:28 UTC

Correcting my comment above within the hour: device-removed data is not what hangs this card. I wrote that "the only difference is the switch", and that was wrong — a run with it off hangs too, once host commit gets as high. The variable is memory, not the diagnostic.

What broke the claim: the next run I did was main 63bcca4 with VICTORY_D3D12_DRED=1 unset, and it was removed at a peak commit of 23,599 MB. So I went back over every run of the title I have on this host and tabulated peak process commit against the outcome.

peak process commit runs outcome
17,189 - 18,569 MB 20 all completed
18,722 - 23,861 MB 7 all removed (0x887A0006)

Separation is complete, with a 153 MB gap between the highest run that completed and the lowest that did not, and the switch sits on both sides of it: two of the seven removals had device-removed data off (18,722 MB and 23,599 MB), five had it on. Device-removed data does cost 4-6 GB of commit here, which is a real finding for this issue, but its role in the removals was to carry runs over that line, not to cause them.

So the useful part of my earlier comment is the memory cost; the causal claim about hangs should be struck. Apologies for the noise — I posted it on a 13-against-3 split without the one arm that would have tested it.

What the corrected picture does and does not support.

  • This is not commit exhaustion, and so not the same failure as #471. This box has 31.9 GB of RAM and a 46.9 GB commit limit (15 GB pagefile), so a 23.8 GB peak is nowhere near the limit — #471 reports dying at it (48.8 of 49.0 GB). What this looks like is paging pressure on a 32 GB box, with the removal downstream of it.
  • Causation is still not established, and there is a plausible confound I cannot rule out. The removed runs presented 1,170-2,218 frames while committing 21-24 GB; the runs that completed presented 1,024 frames (the 45 s ones) or 4,096 (the longer ones) at 17-18 GB, so at matched frame counts the removed runs committed several GB more. So the high-commit runs were doing load work rather than drawing, and "peak commit" may be standing in for "entered a heavy loading phase", which is also where a hang would be expected. A run that reached high commit without loading would separate those, and I do not have one.
  • Every removal reports all breadcrumbs complete (2/2, 3/3, 18/18) and no E_OUTOFMEMORY in any log, on either side of the line.

Still true from the earlier comment, and unaffected: the constant-view case this issue names is fixed on main in 6d021fe, so the fork branch conflicts there and is redundant for it; the small closure at draw.rs:1964 still asks VirtualQuery per draw; and patching that out does not stop the removals (2 runs of 2 still removed), so it is not the dominant cost on this card.

And the practical note I would still make to anyone diagnosing a hang, in a weaker form than I first put it: device-removed data costs several GB of commit, so on a memory-constrained host it can move a run across the line above. Worth recording the switch and the peak commit in a hang report, not because the switch causes hangs, but because it changes how close the run is to that boundary.

Counts and timings only; no game files, no program hashes or paths. AI-assisted (Claude Code); all 27 runs on this host, RTX 3080 / Windows 11.


Edit, later the same day — two fixes, both against me:

  1. The frame range above was wrong as first posted (I wrote 1,024-1,529; it is 1,170-2,218), and the comparison was sloppy because it set the removed runs against only the long runs that completed.
  2. The memory hypothesis in this comment is now disproven. With the title's menus driven past the splash by hand, the world load is reached and the removal reproduces there; the arms that progress furthest run at the lowest peak commit (21.9-22.0 GB against the control's 23.0-23.6 GB). So the removal is not a function of peak commit, and the clean 18.6 GB separation I reported across 27 runs was an artifact of which runs happened to enter loading at all. Six driven runs: #2220

What stands from this comment: device-removed data costs 4-6 GB of commit here, it is not what causes the removals, the constant-view case is fixed on main in 6d021fe, and the small closure at draw.rs:1964 still asks VirtualQuery per draw.

**@⁠BaggyALPHA** on GitHub · 2026-11-26 07:04 UTC · [original](https://github.com/Marvisak/VIctory/issues/913#issuecomment-7185076024) · edited 2026-11-26 07:28 UTC **Correcting my comment above within the hour: device-removed data is not what hangs this card. I wrote that "the only difference is the switch", and that was wrong — a run with it **off** hangs too, once host commit gets as high. The variable is memory, not the diagnostic.** What broke the claim: the next run I did was `main` `63bcca4` with `VICTORY_D3D12_DRED=1` **unset**, and it was removed at a peak commit of 23,599 MB. So I went back over every run of the title I have on this host and tabulated peak process commit against the outcome. | peak process commit | runs | outcome | |---|---:|---| | 17,189 - 18,569 MB | **20** | all completed | | 18,722 - 23,861 MB | **7** | all removed (`0x887A0006`) | Separation is complete, with a 153 MB gap between the highest run that completed and the lowest that did not, and the switch sits on both sides of it: two of the seven removals had device-removed data off (18,722 MB and 23,599 MB), five had it on. Device-removed data **does** cost 4-6 GB of commit here, which is a real finding for this issue, but its role in the removals was to carry runs over that line, not to cause them. So the useful part of my earlier comment is the memory cost; the causal claim about hangs should be struck. Apologies for the noise — I posted it on a 13-against-3 split without the one arm that would have tested it. **What the corrected picture does and does not support.** - This is not commit exhaustion, and so not the same failure as #471. This box has 31.9 GB of RAM and a 46.9 GB commit limit (15 GB pagefile), so a 23.8 GB peak is nowhere near the limit — #471 reports dying *at* it (48.8 of 49.0 GB). What this looks like is paging pressure on a 32 GB box, with the removal downstream of it. - **Causation is still not established, and there is a plausible confound I cannot rule out.** The removed runs presented 1,170-2,218 frames while committing 21-24 GB; the runs that completed presented 1,024 frames (the 45 s ones) or 4,096 (the longer ones) at 17-18 GB, so at matched frame counts the removed runs committed several GB more. So the high-commit runs were doing load work rather than drawing, and "peak commit" may be standing in for "entered a heavy loading phase", which is also where a hang would be expected. A run that reached high commit *without* loading would separate those, and I do not have one. - Every removal reports all breadcrumbs complete (`2/2`, `3/3`, `18/18`) and no `E_OUTOFMEMORY` in any log, on either side of the line. **Still true from the earlier comment, and unaffected:** the constant-view case this issue names is fixed on `main` in `6d021fe`, so the fork branch conflicts there and is redundant for it; the `small` closure at `draw.rs:1964` still asks `VirtualQuery` per draw; and patching that out does not stop the removals (2 runs of 2 still removed), so it is not the dominant cost on this card. **And the practical note I would still make to anyone diagnosing a hang**, in a weaker form than I first put it: device-removed data costs several GB of commit, so on a memory-constrained host it can move a run across the line above. Worth recording the switch and the peak commit in a hang report, not because the switch causes hangs, but because it changes how close the run is to that boundary. Counts and timings only; no game files, no program hashes or paths. AI-assisted (Claude Code); all 27 runs on this host, RTX 3080 / Windows 11. --- **Edit, later the same day — two fixes, both against me:** 1. The frame range above was wrong as first posted (I wrote 1,024-1,529; it is 1,170-2,218), and the comparison was sloppy because it set the removed runs against only the *long* runs that completed. 2. **The memory hypothesis in this comment is now disproven.** With the title's menus driven past the splash by hand, the world load is reached and the removal reproduces there; the arms that progress *furthest* run at the *lowest* peak commit (21.9-22.0 GB against the control's 23.0-23.6 GB). So the removal is not a function of peak commit, and the clean 18.6 GB separation I reported across 27 runs was an artifact of which runs happened to enter loading at all. Six driven runs: https://git.gtahub.st/github/Marvisak--VIctory/issues/2220 What stands from this comment: device-removed data costs 4-6 GB of commit here, it is not what causes the removals, the constant-view case is fixed on `main` in `6d021fe`, and the `small` closure at `draw.rs:1964` still asks `VirtualQuery` per draw.
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/Marvisak--VIctory#913
No description provided.