victory-gpu: the 5-second long frame: memory line off the presenting thread, process-memory line once a minute #4872

Closed
Kenzim wants to merge 2 commits from upstream-pr/4872 into main
Kenzim commented 2026-12-01 12:17:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Kenzim on 2026-12-01T12:17:37Z.


Two periodic log lines were holding up a frame every few seconds.

What changes

  • copystat (diagnostics builds only): the memory line and the "copied from" range lines are written on a thread of their own (victory-memory-line, one at a time; a line still being written when the next is due is skipped and says so). resource::unmapped_holders walks the textures' table 512 at a time instead of holding its lock for the whole walk, and walk_textures sleeps 0.5 ms between two holds instead of yielding (the lock is not fair; a yield took it back before a waiter woke).
  • procmem (every build): the "process memory:" line's address-space walk (1.1-1.3 s of VirtualQuery over ~130,000 regions, on its own thread) runs once a minute instead of every 5 s.

Why / measurements (RTX 3090, native 2560x1440, DLSS off; street scene, last 62 s of each run, frames longer than twice the median within 0.6 s of a report)

  • Diagnostics builds had a frame of 62-70 ms every 5 s among frames of 36-38 ms. A timeline put it on the presenting thread: about 20 ms of the walk for what holds unmapped copies, under the textures' lock, with the list-translating threads waiting at that lock, plus one VirtualQuery of 11 ms.
  • The procmem walk, in every build, held up a frame of 67-104 ms in about one report in five to eight.
  • Long frames near a report: 3/12 per run before vs 0/12 after (3, 3, 3 and 0 of 12-13 in runs with the line every 5 s; 0 of 12 with this change).
  • 99.9th percentile frame time: 142-149 ms before, 108.5-111.3 ms after (109 with VICTORY_PROCESS_MEMORY=0). Mean frame unchanged (36.4-37.6 ms; the scene is card-bound).

Not measured

  • A release build was not run. The procmem change is the same code there.
  • Why a submission waits behind the procmem walk is not known: the other threads' write-watch queries and protection changes were no slower beside it.

Restoring the old behaviour

  • VICTORY_PROCESS_MEMORY_S=5: the process-memory line every 5 s again.
  • VICTORY_PROCESS_MEMORY=0: no process-memory line at all.
  • The memory line's thread and chunked walk have no switch (diagnostics builds only).

Related
#2783 and #2877 also address the 5 s VirtualQuery spike (and #4835's 4ba45d36 turns the process-memory line off by default). This one keeps the line, once a minute, and also moves the diagnostics memory line off the presenting thread; whichever is preferred, the measurements above may help choose.

Translator key / shader cache: not affected.

Checks

  • cargo clippy -p victory-gpu --all-targets (default and --all-features) shows only main's existing 5 errors (font.rs, menu.rs, panel.rs, #4152).
  • cargo xtask policy ok.
  • victory-gpu tests could not run to the end on the test PC (Windows 10, no Shader Model 6.6; main aborts the same way). The procmem and copystat tests that ran passed.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5585517232 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872). Originally posted by [Kenzim](https://github.com/Kenzim) on 2026-12-01T12:17:37Z. --- Two periodic log lines were holding up a frame every few seconds. **What changes** - `copystat` (diagnostics builds only): the memory line and the "copied from" range lines are written on a thread of their own (`victory-memory-line`, one at a time; a line still being written when the next is due is skipped and says so). `resource::unmapped_holders` walks the textures' table 512 at a time instead of holding its lock for the whole walk, and `walk_textures` sleeps 0.5 ms between two holds instead of yielding (the lock is not fair; a yield took it back before a waiter woke). - `procmem` (every build): the "process memory:" line's address-space walk (1.1-1.3 s of VirtualQuery over ~130,000 regions, on its own thread) runs once a minute instead of every 5 s. **Why / measurements** (RTX 3090, native 2560x1440, DLSS off; street scene, last 62 s of each run, frames longer than twice the median within 0.6 s of a report) - Diagnostics builds had a frame of 62-70 ms every 5 s among frames of 36-38 ms. A timeline put it on the presenting thread: about 20 ms of the walk for what holds unmapped copies, under the textures' lock, with the list-translating threads waiting at that lock, plus one VirtualQuery of 11 ms. - The procmem walk, in every build, held up a frame of 67-104 ms in about one report in five to eight. - Long frames near a report: 3/12 per run before vs 0/12 after (3, 3, 3 and 0 of 12-13 in runs with the line every 5 s; 0 of 12 with this change). - 99.9th percentile frame time: 142-149 ms before, 108.5-111.3 ms after (109 with `VICTORY_PROCESS_MEMORY=0`). Mean frame unchanged (36.4-37.6 ms; the scene is card-bound). **Not measured** - A release build was not run. The procmem change is the same code there. - Why a submission waits behind the procmem walk is not known: the other threads' write-watch queries and protection changes were no slower beside it. **Restoring the old behaviour** - `VICTORY_PROCESS_MEMORY_S=5`: the process-memory line every 5 s again. - `VICTORY_PROCESS_MEMORY=0`: no process-memory line at all. - The memory line's thread and chunked walk have no switch (diagnostics builds only). **Related** #2783 and #2877 also address the 5 s VirtualQuery spike (and #4835's 4ba45d36 turns the process-memory line off by default). This one keeps the line, once a minute, and also moves the diagnostics memory line off the presenting thread; whichever is preferred, the measurements above may help choose. Translator key / shader cache: not affected. **Checks** - `cargo clippy -p victory-gpu --all-targets` (default and `--all-features`) shows only main's existing 5 errors (font.rs, menu.rs, panel.rs, #4152). - `cargo xtask policy` ok. - victory-gpu tests could not run to the end on the test PC (Windows 10, no Shader Model 6.6; main aborts the same way). The procmem and copystat tests that ran passed.
andrewpozdnakov7-jpg commented 2026-12-01 12:46:46 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T12:46:46Z.


There is a retry gap in 0a44cee9. The scheduler advances STARTED before spawning the worker, so a transient spawn failure can suppress the memory line for another minute even though no sample was started.

a32c1dae saves the previous timestamp and restores it on spawn failure, before clearing the worker flag. The next regular frame report can try again. A successful start still counts toward the configured interval.

In one Windows Rust fixture I ran the exact scheduler with a stub clock and worker builder. A sample at 5 s succeeded and an injected spawn failure at 65 s prevented the author version from trying again at 70 s. The patch retried successfully at 70 s and kept the normal interval for the new sample. The staged asset policy passed for the one file.

Please keep the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change in.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7311633947 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7311633947). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-12-01T12:46:46Z. --- There is a retry gap in `0a44cee9`. The scheduler advances `STARTED` before spawning the worker, so a transient spawn failure can suppress the memory line for another minute even though no sample was started. [a32c1dae](https://github.com/andrewpozdnakov7-jpg/VIctory-NVIDIA/commit/a32c1dae73d57ee28bb0d5c998e0602c95485d89) saves the previous timestamp and restores it on spawn failure, before clearing the worker flag. The next regular frame report can try again. A successful start still counts toward the configured interval. In one Windows Rust fixture I ran the exact scheduler with a stub clock and worker builder. A sample at 5 s succeeded and an injected spawn failure at 65 s prevented the author version from trying again at 70 s. The patch retried successfully at 70 s and kept the normal interval for the new sample. The staged asset policy passed for the one file. Please keep the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change in. AI-assisted with OpenAI Codex.
tikD1337 commented 2026-12-01 13:28:03 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tikD1337 on 2026-12-01T13:28:03Z.


Tested on origin/main (5fabb46e) in --release stacked with #4877, #4885 (VICTORY_THIN_PEEPHOLE=1), and #3556 01/03/04 (VICTORY_PORT_CONSTANTS=0, Ryzen 5 7600 + RTX 4070 Ti SUPER, Driver 621.1.0, Win11 26300, DLSS Quality, 105 s steady 3D runs):

  • Clean apply/build (#4877 + #4872 together lifted our stack from 27.41 -> 27.93 FPS, 36.48 -> 35.80 ms, submit_prep 32.7 -> 31.6 ms).
  • 0 crashes across all 105 s runs (including with DLSS FG 2x).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7312670343 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7312670343). Originally posted by [tikD1337](https://github.com/tikD1337) on 2026-12-01T13:28:03Z. --- Tested on `origin/main` (`5fabb46e`) in `--release` stacked with `#4877`, `#4885` (`VICTORY_THIN_PEEPHOLE=1`), and `#3556` `01/03/04` (`VICTORY_PORT_CONSTANTS=0`, Ryzen 5 7600 + RTX 4070 Ti SUPER, Driver `621.1.0`, Win11 `26300`, DLSS Quality, `105 s` steady 3D runs): - Clean apply/build (`#4877` + `#4872` together lifted our stack from **`27.41 -> 27.93 FPS`**, `36.48 -> 35.80 ms`, `submit_prep 32.7 -> 31.6 ms`). - **0 crashes** across all `105 s` runs (including with DLSS FG 2x).
Freeman022026 commented 2026-12-01 14:04:29 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Freeman022026 on 2026-12-01T14:04:29Z.


Tested on an RTX 4090 24 GB (driver 621.14), Ryzen 7 7800X3D, 64 GB RAM, Windows 11, Series X profile at 2560x1440, DLSS Performance, 2x DLSS Frame Generation, ray tracing off. Local MSVC release build on v2026.11.30.02 (84bd61e2) with #4872 composed alongside #4558 (VICTORY_SWEEP_OFF_THREAD=1) and a local PR stack.

In a 6-hour session before adding #4872, process memory: logged 4,292 times on its 5-second cadence, and the VirtualQuery walk grew from 42,300 regions (306 ms) at startup to 130,126 regions (1,501 ms, peaking at 2,504 ms).

With #4872 applied, process memory: ran 14 times over a 13-minute session at 60-second intervals (199 ms at 42,138 regions up to 1,055 ms at 104,750 regions), cutting those 1 to 2.5 s walks by 12x. Unit tests for procmem and unmapped_holders passed on MSVC rustc 1.99.1.

Not tested: isolated clean main, a diagnostics build (copystat memory line on victory-memory-line), or a multi-hour run with #4872 enabled.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7313650637 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7313650637). Originally posted by [Freeman022026](https://github.com/Freeman022026) on 2026-12-01T14:04:29Z. --- Tested on an RTX 4090 24 GB (driver 621.14), Ryzen 7 7800X3D, 64 GB RAM, Windows 11, Series X profile at 2560x1440, DLSS Performance, 2x DLSS Frame Generation, ray tracing off. Local MSVC release build on `v2026.11.30.02` (`84bd61e2`) with #4872 composed alongside #4558 (`VICTORY_SWEEP_OFF_THREAD=1`) and a local PR stack. In a 6-hour session before adding #4872, `process memory:` logged 4,292 times on its 5-second cadence, and the `VirtualQuery` walk grew from 42,300 regions (306 ms) at startup to 130,126 regions (1,501 ms, peaking at 2,504 ms). With #4872 applied, `process memory:` ran 14 times over a 13-minute session at 60-second intervals (199 ms at 42,138 regions up to 1,055 ms at 104,750 regions), cutting those 1 to 2.5 s walks by 12x. Unit tests for `procmem` and `unmapped_holders` passed on MSVC `rustc 1.99.1`. Not tested: isolated clean `main`, a diagnostics build (`copystat` memory line on `victory-memory-line`), or a multi-hour run with #4872 enabled.
botto854 commented 2026-12-01 14:43:11 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by botto854 on 2026-12-01T14:43:11Z.


A data point for the procmem part, from a 14900K / 4090 / 32 GB (Series X profile, DLAA, frame generation off,
diag build of v2026.11.30.02 + #2585). Same exe, VICTORY_PROCESS_MEMORY=0 against the default, five runs each,
order alternated per round, 30 s settle + 240 s scripted route on a balcony:

default PROCESS_MEMORY=0
frame median, ms 39.0 39.4
p99, ms (range) 83.0 (82-85) 76.5 (75-78)
frames over 100 ms per minute (range) 7.49 (7.2-7.7) 1.99 (1.3-2.0)
longest frame, ms 163-191 128-148

p99 was lower in all five pairs. Here the walk reports about 98,500 regions in ~530 ms, and every second that held a
frame over 100 ms ended less than a second before a "process memory:" line. In a free 27-minute drive through the city
the same lines explain only about a fifth of the long frames, so streaming dominates there; on a quiet scene it is most
of them. Once a minute, as here, looks right to me.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7314714018 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7314714018). Originally posted by [botto854](https://github.com/botto854) on 2026-12-01T14:43:11Z. --- A data point for the procmem part, from a 14900K / 4090 / 32 GB (Series X profile, DLAA, frame generation off, diag build of v2026.11.30.02 + #2585). Same exe, `VICTORY_PROCESS_MEMORY=0` against the default, five runs each, order alternated per round, 30 s settle + 240 s scripted route on a balcony: | | default | `PROCESS_MEMORY=0` | |---|---:|---:| | frame median, ms | 39.0 | 39.4 | | p99, ms (range) | 83.0 (82-85) | 76.5 (75-78) | | frames over 100 ms per minute (range) | 7.49 (7.2-7.7) | 1.99 (1.3-2.0) | | longest frame, ms | 163-191 | 128-148 | p99 was lower in all five pairs. Here the walk reports about 98,500 regions in ~530 ms, and every second that held a frame over 100 ms ended less than a second before a "process memory:" line. In a free 27-minute drive through the city the same lines explain only about a fifth of the long frames, so streaming dominates there; on a quiet scene it is most of them. Once a minute, as here, looks right to me.
CLHelper commented 2026-12-01 16:34:07 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CLHelper on 2026-12-01T16:34:07Z.


On the "Not measured" point (why a submission waits behind the procmem walk): on this machine the write-watch query does wait for it.

RTX 4060 Laptop GPU (8 GB), 16 logical CPUs, 32 GB, Windows 11; Series S, DLSS performance; a local diagnostics build on c71899d9e; VICTORY_TIMELINE over 24 frames, player standing still. (The timeline itself adds about 6 ms a frame.)

  • In one frame of 63.8 ms, victory-ask sat in GetWriteWatch for 19.97 ms and then 8.83 ms. The two calls returned 0.02 ms and 0.00 ms after the victory-process-memory thread's VirtualQuery calls of 26.09 ms and 8.84 ms returned. The same walk also had one VirtualQuery of 122 ms. In a second 24-frame window without a walk there was no long GetWriteWatch.
  • The walk here: about 85,000 regions, about 1 s, every 5 s.
  • The diagnostics memory line, in another frame: a 41.1 ms span on the submitting thread, of which VirtualQuery calls of 5.4, 8.6 and 6.9 ms from copystat (one per top copied range). Moving that line off the presenting thread, as this PR does, covers it.

Over a whole run the walk costs little here: one 200 s run with VICTORY_PROCESS_MEMORY=0 against one with the walk, standing still, gave p95 frame 60.7 against 62.2 ms, frames over 50 ms 16.1 % against 17.5 %, and 25.5 against 25.6 fps. One run each, without this PR's code.

AI-assisted.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7317821491 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7317821491). Originally posted by [CLHelper](https://github.com/CLHelper) on 2026-12-01T16:34:07Z. --- On the "Not measured" point (why a submission waits behind the procmem walk): on this machine the write-watch query does wait for it. RTX 4060 Laptop GPU (8 GB), 16 logical CPUs, 32 GB, Windows 11; Series S, DLSS performance; a local diagnostics build on c71899d9e; `VICTORY_TIMELINE` over 24 frames, player standing still. (The timeline itself adds about 6 ms a frame.) - In one frame of 63.8 ms, `victory-ask` sat in `GetWriteWatch` for 19.97 ms and then 8.83 ms. The two calls returned 0.02 ms and 0.00 ms after the `victory-process-memory` thread's `VirtualQuery` calls of 26.09 ms and 8.84 ms returned. The same walk also had one `VirtualQuery` of 122 ms. In a second 24-frame window without a walk there was no long `GetWriteWatch`. - The walk here: about 85,000 regions, about 1 s, every 5 s. - The diagnostics memory line, in another frame: a 41.1 ms span on the submitting thread, of which `VirtualQuery` calls of 5.4, 8.6 and 6.9 ms from `copystat` (one per top copied range). Moving that line off the presenting thread, as this PR does, covers it. Over a whole run the walk costs little here: one 200 s run with `VICTORY_PROCESS_MEMORY=0` against one with the walk, standing still, gave p95 frame 60.7 against 62.2 ms, frames over 50 ms 16.1 % against 17.5 %, and 25.5 against 25.6 fps. One run each, without this PR's code. AI-assisted.
mstrmoos commented 2026-12-01 16:53:07 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mstrmoos on 2026-12-01T16:53:07Z.


Picked this onto my play branch (#4835's code). Here's what it did on an RTX 5080.

That branch already has the process-memory line off by default, so the half that mattered here is the memory line moved off the presenting thread. The procmem doc conflicted with that; I merged it as "once a minute, off unless VICTORY_PROCESS_MEMORY=1".

Before: a 30-minute run standing on the pier (Series X, DLSS Balanced, frame generation 4x with Reflex low latency off and frameLimitUs 6,500, diagnostics build, about 5,000 draws a frame) had 5 frames over 100 ms out of 68,710: 110, 133, 147, 323 and 364 ms. Every one sat right beside a memory now: line. In the two longest, the presenting thread logged nothing for 316 and 348 ms, and the next line was the memory line.

After, same build plus this, same scene and switches, 10 minutes:

frames frame (median) p99 over 50 ms over 100 ms longest
before (30 min) 68,710 26.1 ms 29.9 10 5 364 ms
with this (10 min) 23,009 26.0 ms 27.2 0 0 48.2 ms

The frame time is capped by the limiter here, so this only speaks to the tail. On that, it's clean.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7318396846 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7318396846). Originally posted by [mstrmoos](https://github.com/mstrmoos) on 2026-12-01T16:53:07Z. --- Picked this onto my play branch (#4835's code). Here's what it did on an RTX 5080. That branch already has the process-memory line off by default, so the half that mattered here is the memory line moved off the presenting thread. The procmem doc conflicted with that; I merged it as "once a minute, off unless `VICTORY_PROCESS_MEMORY=1`". **Before:** a 30-minute run standing on the pier (Series X, DLSS Balanced, frame generation 4x with Reflex low latency off and `frameLimitUs` 6,500, diagnostics build, about 5,000 draws a frame) had 5 frames over 100 ms out of 68,710: 110, 133, 147, 323 and 364 ms. **Every one sat right beside a `memory now:` line.** In the two longest, the presenting thread logged nothing for 316 and 348 ms, and the next line was the memory line. **After**, same build plus this, same scene and switches, 10 minutes: | | frames | frame (median) | p99 | over 50 ms | over 100 ms | longest | | --- | --- | --- | --- | --- | --- | --- | | before (30 min) | 68,710 | 26.1 ms | 29.9 | 10 | 5 | 364 ms | | with this (10 min) | 23,009 | 26.0 ms | 27.2 | **0** | **0** | **48.2 ms** | The frame time is capped by the limiter here, so this only speaks to the tail. On that, it's clean.
trustno1-coder commented 2026-12-01 18:29:59 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:29:59Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321043039 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7321043039). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:29:59Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

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