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

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

@⁠Kenzim on GitHub · 2026-12-01 12:17 UTC · original
Kenzim:memory-line → main · +115 −32 · 3 files · 2 commits · closed without merging

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 #4836'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.
**@⁠Kenzim** on GitHub · 2026-12-01 12:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872) `Kenzim:memory-line` → `main` · +115 −32 · 3 files · 2 commits · closed without merging 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 #4836'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.
A diagnostics build had one frame of 62-70 ms every five seconds among
frames of 36-38 (street scene, runs cp-base1, cp-base2, cp-thin16: the
longest frame of the second after each memory line; 68-106 ms in run
ab-default-1). The timeline of that scene (tl-base, 40 frames) has one:
a present of 36.5 ms on the serving thread, 35.8 of it the frame meter,
and beside it every thread that translates lists, the landing's jobs and
the heaps' records standing 17-20 ms at the same instant.

Three things, all in copystat::log, which only a diagnostics build calls:

- resource::unmapped_holders walked every texture under the textures'
  lock, asking about title memory for every fourth placed one (30,000
  textures, 20 ms). It walks in chunks now, as the census beside it has
  since it made the same hitch, and walk_textures sleeps half a
  millisecond between two holds instead of yielding: with processors to
  spare a yield comes back and takes the lock again before a waiter has
  woken (run cp-v1-a, the walk in chunks on its own thread and yielding:
  still 3 of 12 memory lines with a frame of 63-141 ms behind them).
- the memory line itself and the "copied from" lines run on a thread of
  their own (victory-memory-line), one at a time. They only read counts.
  One of the range lines' VirtualQuery calls took 11.0 ms on the serving
  thread in that timeline.

Measured, street scene, last 62 s of each run, frames over twice the
median within 0.6 s of a memory line: cp-v1-a 3 and cp-v1-b 2 of 12 lines
(threads and chunks, yielding), cp-v2-a 0 of 12 (this commit). The base
has no such count: there it is the second-by-second longest frame, 62-72
ms median over 11-17 such seconds a run in four runs.

The memory map's walk and procmem's (every build) were looked at and are
not a cause: beside their VirtualQuery calls of up to 138 ms the other
threads' write-watch askings and protection changes took 0.3 ms at most.

Not verified: a release build was not run (none of this is in one).

(Ported from our branch without the frame-stage diagnostics that went in
beside it: those are a subject of their own.)
procmem's walk of the address space (every build, every 5 s, 1.1-1.3 s
of VirtualQuery over ~130,000 regions on a thread of its own) holds a
frame up now and then: about one report in five to eight had a frame of
67-104 ms behind it, among frames of 36-38, all of it the serving
thread's work in one submission.

Street scene, -CaptureEvery 0 from v3 on, the last 62 s of each run,
frames over twice the median within 0.6 s of a report:
- the line every 5 s: 3 of 12, 3 of 12, 3 of 13, 0 of 12 (cp-v4-b,
  cp-v3-a, cp-v2-b, cp-v2-a); with a report every second
  (VICTORY_REPORT_EVERY_S=1): 8, 8, 7 of 61 (cp-v4-r1, cp-v3-r1,
  cp-v2-r1);
- VICTORY_PROCESS_MEMORY=0: 0 of 12 and 0 of 61 (cp-v4-pm0,
  cp-v4-pm0-r1);
- this commit, the line every 60 s: 0 of 12 (cp-v5-a) and 3 of 61
  (cp-v5-r1; with a report every second any long frame that is not at a
  bake's settle counts here).
The 99.9th percentile of the frame times: 142-149 ms before (cp-v3-a,
cp-v3-r1, cp-v4-r1), 109 with the line off, 108.5 and 111.3 with this.
Mean frame 36.4-37.6 ms throughout: the scene is the card's.

VICTORY_PROCESS_MEMORY_S=<seconds> sets the interval (5: as before);
VICTORY_PROCESS_MEMORY=0 still leaves the line out.

Not known: what of a submission waits behind the walk's questions (the
write-watch askings and protection changes beside them are no slower,
timeline tl-base). Not verified: a release build was not run; the walk
and its switch are the same code there.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 12:21:35 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-12-01 12:46 UTC · original

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-12-01 12:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7311633947) 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.
Author
Owner

@⁠tikD1337 on GitHub · 2026-12-01 13:28 UTC · original

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).
**@⁠tikD1337** on GitHub · 2026-12-01 13:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7312670343) 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).
Author
Owner

@⁠Freeman022026 on GitHub · 2026-12-01 14:04 UTC · original

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 #4873 composed alongside #4559 (VICTORY_SWEEP_OFF_THREAD=1) and a local PR stack.

In a 6-hour session before adding #4873, 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 #4873 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 #4873 enabled.

**@⁠Freeman022026** on GitHub · 2026-12-01 14:04 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7313650637) 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 #4873 composed alongside #4559 (`VICTORY_SWEEP_OFF_THREAD=1`) and a local PR stack. In a 6-hour session before adding #4873, `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 #4873 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 #4873 enabled.
Author
Owner

@⁠botto854 on GitHub · 2026-12-01 14:43 UTC · original

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.

**@⁠botto854** on GitHub · 2026-12-01 14:43 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7314714018) 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.
Author
Owner

@⁠CLHelper on GitHub · 2026-12-01 16:34 UTC · original

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.

**@⁠CLHelper** on GitHub · 2026-12-01 16:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7317821491) 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.
Author
Owner

@⁠mstrmoos on GitHub · 2026-12-01 16:53 UTC · original

Picked this onto my play branch (#4836'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.

**@⁠mstrmoos** on GitHub · 2026-12-01 16:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7318396846) Picked this onto my play branch (#4836'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.
github-bot closed this pull request 2026-12-01 18:30:44 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:29 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:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4872#issuecomment-7321043039) 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!4873
No description provided.