Camera-turn stutter: frames over 60 ms in a turn 28 % → 20 % (4.2 % → 2.2 % with #4635): DirectStorage workers a quarter of the cores at normal priority where they share the frame's #4639

Open
thatblend wants to merge 1 commit from upstream-pr/4639 into main
thatblend commented 2026-12-01 00:26:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by thatblend on 2026-12-01T00:26:51Z.


What it changes

When the camera turns, the frame rate drops and long frames pile up; part of that is our own DirectStorage workers getting in the frame's way on processors with one cache for all cores.

Driving in traffic, camera swung round six times for 10 s, RTX 4090 + Ryzen 7 9800X3D, no frame generation main: 16 workers, priority -1 this: 4 workers, priority 0
On e1251c31 as it is, in the swings: frames over 60 ms 31.2 % and 25.9 % 19.5 % and 21.3 %
in the swings: slowest 1 % of frames 7.3 and 7.9 fps 9.0 and 8.7 fps
With the present pace of #4635 in the build, in the swings: frames over 60 ms 4.7 % and 3.6 % 2.1, 2.2, 2.0 and 2.6 %
in the swings: slowest 1 % of frames 9.6 and 9.5 fps 11.4, 10.7, 10.3 and 10.6 fps
in the swings: mean frame 42.6 and 42.5 ms 40.9, 40.6, 40.9 and 40.6 ms
camera still: mean frame 32.6 and 31.4 ms 33.2, 32.6, 33.4 and 33.3 ms (the same within the runs' scatter)

Each number is one run of 240 s; the columns are every valid run made, not a selection.

What was wrong. The workers are as many as processors, kept on the half the frame is not on where the process was placed (keep_off_the_frames_cores), and below normal priority so that they "take the processors nobody of the frame wants". Where the process is not placed on a half (one cache for all cores, as on a Ryzen 7 9800X3D), there is no such half and no such processors: 16 workers sit on the frame's own 16. When the camera turns the title asks for the textures of what comes into view, some hundreds of requests a second, and all of them unpack at once. Each takes the guards' lock (watch.rs) for the pages it writes, as the threads a frame waits for do for every refresh, and a worker below normal priority loses its processor with the lock held. In three timelines of camera swings the workers stood 1.0 to 1.6 s of 7 s waiting for that lock among themselves, and the long frames' chains held 10.5 ms more of a streaming request and 4.5 ms more of "woken, not running yet" than the other frames'.

What this does. Where the workers share the frame's processors (off_the_frames_cores() is all of them), there are a quarter as many (2 at least, 8 at most: 4 on 16 threads), at normal priority. Where the process is placed on a half, nothing changes. VICTORY_DSTORAGE_WORKERS and VICTORY_DSTORAGE_PRIORITY say otherwise as before. One function, shared_workers, with a unit test; 54 lines, most of them the comment with the numbers.

What it costs. Throughput while the camera turns: 6.7 against 9.8 MB of textures made ready for the card a frame in the mean of the runs above, so what comes into view takes that much longer to sharpen. Fewer is worse (2 workers: 1.8 MB a frame) and more buys nothing (8 workers: the frames as with 4), both seen on a tree of two days ago.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4090, Ryzen 7 9800X3D (8 cores, 16 threads), 96 GB; Series X profile, 2560x1440, DLSS Quality, frame generation off, ray tracing off.
  • Game runs: a scripted drive through traffic from one save, the camera swung round six times for 10 s, 240 s measured after 80 s of warm-up, warm caches, release builds. "In the swings" is the frames of those six windows; frame times are our presents to the host (the frame log).
    • On e1251c31 unchanged, the two settings chosen with the switches it has (nothing set against VICTORY_DSTORAGE_WORKERS=4 VICTORY_DSTORAGE_PRIORITY=0, which is what this makes the default here), in turn.
    • On e1251c31 with this, #4635 and six open pull requests of others applied (4500, 4294, 4247, 4206, 4509, 4493), VICTORY_DSTORAGE_WORKERS=16 VICTORY_DSTORAGE_PRIORITY=-1 against nothing set.
  • Before: see the table's middle column.
  • After: see the table's right column.
  • Not run on: a processor the process is placed on a half of (two caches, or fast and slow cores), where this changes nothing by construction; AMD or Intel cards; frame generation.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): no shader change.
  • cargo test passed for the crates it touches: at this branch's head on 7d93ee07, cargo test --locked -p victory-hle --lib: 469 passed, 1 failed, 13 ignored. The one that fails, modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it, fails the same way on 7d93ee07 without this change (three runs of three, 468 passed and that one failed) and passes when run alone; it is a timing test that this does not touch. cargo clippy --locked -p victory-hle --all-targets -- -D warnings: clean.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Closest: #4604, opened shortly before this one, sets VICTORY_DSTORAGE_PRIORITY=0 in the launcher on the same processor so that the world comes in sooner; it keeps the 16 workers and gives no frame times. This makes normal priority the default in the code where the workers share the frame's processors and cuts their number as well, with the numbers above; the two agree on the priority, and if #4604 is merged its launcher line simply says what this already does. Related by subject: #4206 takes the camera turn from the submitting thread's side (title writes among the steps) and #4247 takes the guards' lock from the refreshes' side; this is the workers' side of the same lock. Related by file (dstorage.rs), other matters: #2761, #3553, #3154.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5576355732 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4639). Originally posted by [thatblend](https://github.com/thatblend) on 2026-12-01T00:26:51Z. --- ## What it changes When the camera turns, the frame rate drops and long frames pile up; part of that is our own DirectStorage workers getting in the frame's way on processors with one cache for all cores. | Driving in traffic, camera swung round six times for 10 s, RTX 4090 + Ryzen 7 9800X3D, no frame generation | main: 16 workers, priority -1 | this: 4 workers, priority 0 | |---|---|---| | **On e1251c31 as it is**, in the swings: frames over 60 ms | 31.2 % and 25.9 % | **19.5 % and 21.3 %** | | in the swings: slowest 1 % of frames | 7.3 and 7.9 fps | **9.0 and 8.7 fps** | | **With the present pace of #4635 in the build**, in the swings: frames over 60 ms | 4.7 % and 3.6 % | **2.1, 2.2, 2.0 and 2.6 %** | | in the swings: slowest 1 % of frames | 9.6 and 9.5 fps | **11.4, 10.7, 10.3 and 10.6 fps** | | in the swings: mean frame | 42.6 and 42.5 ms | 40.9, 40.6, 40.9 and 40.6 ms | | camera still: mean frame | 32.6 and 31.4 ms | 33.2, 32.6, 33.4 and 33.3 ms (the same within the runs' scatter) | Each number is one run of 240 s; the columns are every valid run made, not a selection. **What was wrong.** The workers are as many as processors, kept on the half the frame is not on where the process was placed (`keep_off_the_frames_cores`), and below normal priority so that they "take the processors nobody of the frame wants". Where the process is not placed on a half (one cache for all cores, as on a Ryzen 7 9800X3D), there is no such half and no such processors: 16 workers sit on the frame's own 16. When the camera turns the title asks for the textures of what comes into view, some hundreds of requests a second, and all of them unpack at once. Each takes the guards' lock (`watch.rs`) for the pages it writes, as the threads a frame waits for do for every refresh, and a worker below normal priority loses its processor with the lock held. In three timelines of camera swings the workers stood 1.0 to 1.6 s of 7 s waiting for that lock among themselves, and the long frames' chains held 10.5 ms more of a streaming request and 4.5 ms more of "woken, not running yet" than the other frames'. **What this does.** Where the workers share the frame's processors (`off_the_frames_cores()` is all of them), there are a quarter as many (2 at least, 8 at most: 4 on 16 threads), at normal priority. Where the process is placed on a half, nothing changes. `VICTORY_DSTORAGE_WORKERS` and `VICTORY_DSTORAGE_PRIORITY` say otherwise as before. One function, `shared_workers`, with a unit test; 54 lines, most of them the comment with the numbers. **What it costs.** Throughput while the camera turns: 6.7 against 9.8 MB of textures made ready for the card a frame in the mean of the runs above, so what comes into view takes that much longer to sharpen. Fewer is worse (2 workers: 1.8 MB a frame) and more buys nothing (8 workers: the frames as with 4), both seen on a tree of two days ago. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4090, Ryzen 7 9800X3D (8 cores, 16 threads), 96 GB; Series X profile, 2560x1440, DLSS Quality, frame generation off, ray tracing off. - Game runs: a scripted drive through traffic from one save, the camera swung round six times for 10 s, 240 s measured after 80 s of warm-up, warm caches, release builds. "In the swings" is the frames of those six windows; frame times are our presents to the host (the frame log). - On e1251c31 unchanged, the two settings chosen with the switches it has (nothing set against `VICTORY_DSTORAGE_WORKERS=4 VICTORY_DSTORAGE_PRIORITY=0`, which is what this makes the default here), in turn. - On e1251c31 with this, #4635 and six open pull requests of others applied (4500, 4294, 4247, 4206, 4509, 4493), `VICTORY_DSTORAGE_WORKERS=16 VICTORY_DSTORAGE_PRIORITY=-1` against nothing set. - Before: see the table's middle column. - After: see the table's right column. - Not run on: a processor the process is placed on a half of (two caches, or fast and slow cores), where this changes nothing by construction; AMD or Intel cards; frame generation. - For shader changes, the wave sizes tested (32 and/or 64 lanes): no shader change. - `cargo test` passed for the crates it touches: at this branch's head on 7d93ee07, `cargo test --locked -p victory-hle --lib`: 469 passed, 1 failed, 13 ignored. The one that fails, `modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it`, fails the same way on 7d93ee07 without this change (three runs of three, 468 passed and that one failed) and passes when run alone; it is a timing test that this does not touch. `cargo clippy --locked -p victory-hle --all-targets -- -D warnings`: clean. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Closest: #4604, opened shortly before this one, sets `VICTORY_DSTORAGE_PRIORITY=0` in the launcher on the same processor so that the world comes in sooner; it keeps the 16 workers and gives no frame times. This makes normal priority the default in the code where the workers share the frame's processors and cuts their number as well, with the numbers above; the two agree on the priority, and if #4604 is merged its launcher line simply says what this already does. Related by subject: #4206 takes the camera turn from the submitting thread's side (title writes among the steps) and #4247 takes the guards' lock from the refreshes' side; this is the workers' side of the same lock. Related by file (`dstorage.rs`), other matters: #2761, #3553, #3154.
Kassadd commented 2026-12-01 01:23:16 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Kassadd on 2026-12-01T01:23:16Z.


Tested on a hybrid-core CPU under Proton on Linux: the automatic choice picks 8 with no
switch, the tail of the frame times improves, and it gets further before the driver gives up.

Environment: i9-14900K (8 P-cores + 16 E-cores, 32 logical), RTX 4080 SUPER 16 GiB,
62 GiB, CachyOS, NVIDIA 620.73.04, Proton Experimental …-w0be231-d1011dd-v71cae0,
Series X 1.0.2.1, 3440x1440 monitor. --res 1440 --aspect 21:9 --dlss off --no-framegen-ready --preload. main at 7d93ee0 with #3350 and this PR on top, both applied
with no conflict.

The automatic choice works with no switch, on a CPU of two core kinds — not the Ryzen
9800X3D the description measured:

dstorage: workers (VICTORY_DSTORAGE_PRIORITY) workers=8 priority=0

off_the_frames_cores() reports what it reports on 8 P-cores + 16 E-cores, shared_workers(32)
gives 8, and the priority default lands on 0. The branch the description argues for is the one
taken, unasked.

Frame times in the world, medians over frames with more than 1,000 draws, 41 samples from
about four minutes of play (the run ended on the fault described below):

median p90 worst
before (32 workers, priority −1, automatic) 85–113 ms ~200–250 ms 203 ms
with this PR (8 workers, priority 0, automatic) 69.6 ms 116.3 ms 208.5 ms

The "before" figures come from earlier runs on this machine on trees without this PR; the scene
and the draw counts differ, so treat the p90 as the comparable part — the tail is where the
change shows
, which is what the description predicts. I am not claiming the median.

What I did not expect, and the part worth your attention. With 32 workers — the automatic
count, with the priority already set to 0 by hand, so half of this PR's change and still the old
worker count — entering a shop ended the process inside a few minutes with an NVIDIA MMU fault:

NVRM: Xid (PCI:0000:01:00): 31, … intr 00000000. MMU Fault
VIctory: host GPU failure: relay: the device was lost before fence value …

With 8 workers and priority 0 the same shop is survivable: it takes a dip to about 8 fps and
stays up. But it does not remove the fault — about four minutes of world play later, the same
Xid 31 and the same device lost, with the last thing logged being the sweep letting host
copies go "under pressure". So this PR gets further and is smoother while it lasts, and the
driver still gives up. That is worth saying plainly rather than leaving as "fixed": I would not
want anyone reading this as a cure.

What I did not test: Windows, AMD cards, a 16-core CPU (where the clamp keeps the count at 4
and the priority at −1), and whether the fault is only postponed rather than made rarer — four
minutes is not enough to tell. If I learn more I will add it here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7297439802 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4639#issuecomment-7297439802). Originally posted by [Kassadd](https://github.com/Kassadd) on 2026-12-01T01:23:16Z. --- **Tested on a hybrid-core CPU under Proton on Linux: the automatic choice picks 8 with no switch, the tail of the frame times improves, and it gets further before the driver gives up.** **Environment:** i9-14900K (8 P-cores + 16 E-cores, 32 logical), RTX 4080 SUPER 16 GiB, 62 GiB, CachyOS, NVIDIA 620.73.04, Proton Experimental `…-w0be231-d1011dd-v71cae0`, Series X `1.0.2.1`, 3440x1440 monitor. `--res 1440 --aspect 21:9 --dlss off --no-framegen-ready --preload`. `main` at `7d93ee0` with #3350 and this PR on top, both applied with no conflict. **The automatic choice works with no switch, on a CPU of two core kinds** — not the Ryzen 9800X3D the description measured: ```text dstorage: workers (VICTORY_DSTORAGE_PRIORITY) workers=8 priority=0 ``` `off_the_frames_cores()` reports what it reports on 8 P-cores + 16 E-cores, `shared_workers(32)` gives 8, and the priority default lands on 0. The branch the description argues for is the one taken, unasked. **Frame times in the world**, medians over frames with more than 1,000 draws, 41 samples from about four minutes of play (the run ended on the fault described below): | | median | p90 | worst | |---|---:|---:|---:| | before (32 workers, priority −1, automatic) | 85–113 ms | ~200–250 ms | 203 ms | | **with this PR** (8 workers, priority 0, automatic) | **69.6 ms** | **116.3 ms** | 208.5 ms | The "before" figures come from earlier runs on this machine on trees without this PR; the scene and the draw counts differ, so treat the p90 as the comparable part — **the tail is where the change shows**, which is what the description predicts. **I am not claiming the median.** **What I did not expect, and the part worth your attention.** With 32 workers — the automatic count, with the priority already set to 0 by hand, so half of this PR's change and still the old worker count — entering a shop ended the process inside a few minutes with an NVIDIA MMU fault: ```text NVRM: Xid (PCI:0000:01:00): 31, … intr 00000000. MMU Fault VIctory: host GPU failure: relay: the device was lost before fence value … ``` With 8 workers and priority 0 the same shop is survivable: it takes a dip to about 8 fps and stays up. **But it does not remove the fault** — about four minutes of world play later, the same `Xid 31` and the same `device lost`, with the last thing logged being the sweep letting host copies go "under pressure". So this PR **gets further and is smoother while it lasts**, and the driver still gives up. That is worth saying plainly rather than leaving as "fixed": I would not want anyone reading this as a cure. **What I did not test:** Windows, AMD cards, a 16-core CPU (where the clamp keeps the count at 4 and the priority at −1), and whether the fault is only postponed rather than made rarer — four minutes is not enough to tell. If I learn more I will add it here.
isgti07-hub commented 2026-12-01 02:59:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by isgti07-hub on 2026-12-01T02:59:49Z.


A data point on the worker count, from the other side of the trade: texture streaming while driving fast.

RTX 5090 32 GB, Ryzen 7 9800X3D, 64 GB RAM, Windows 11, game files on an NVMe SSD; Series X, 3840x2160 output, DLSS Quality, no frame generation. Three sessions of driving through the city in my own build (main 7d93ee07 with #4635 and changes of my own; the middle one also with this PR). The textures picked by index, the queue line, averaged over each session:

session workers, priority textures waiting for their memory (mean) the oldest due, 90th percentile
10 min, before this PR 16, 0 101 41 frames
16 min, with this PR 4, 0 268 86 frames
15 min, this PR with VICTORY_DSTORAGE_WORKERS=16 16, 0 165 (one long outlier)

In play with 4 workers, textures came in late and blurry all the time at speed; with 16 back, I saw it about three times in 15 minutes.

Caveats: these are separate sessions, not an in-run A/B (the worker count is read once at the start), and they did not cover the same streets, so the scene is not controlled; I didn't measure the frame-time side, which is what your numbers are about. So this doesn't contradict your camera-turn result, but on this CPU 4 workers seem too few for fast driving. Something between 4 and 16, or a count that grows while the queue is long, might keep both.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7299209949 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4639#issuecomment-7299209949). Originally posted by [isgti07-hub](https://github.com/isgti07-hub) on 2026-12-01T02:59:49Z. --- A data point on the worker count, from the other side of the trade: texture streaming while driving fast. RTX 5090 32 GB, Ryzen 7 9800X3D, 64 GB RAM, Windows 11, game files on an NVMe SSD; Series X, 3840x2160 output, DLSS Quality, no frame generation. Three sessions of driving through the city in my own build (main 7d93ee07 with #4635 and changes of my own; the middle one also with this PR). The `textures picked by index, the queue` line, averaged over each session: | session | workers, priority | textures waiting for their memory (mean) | the oldest due, 90th percentile | |---|---|---|---| | 10 min, before this PR | 16, 0 | 101 | 41 frames | | 16 min, with this PR | 4, 0 | **268** | 86 frames | | 15 min, this PR with `VICTORY_DSTORAGE_WORKERS=16` | 16, 0 | 165 | (one long outlier) | In play with 4 workers, textures came in late and blurry all the time at speed; with 16 back, I saw it about three times in 15 minutes. Caveats: these are separate sessions, not an in-run A/B (the worker count is read once at the start), and they did not cover the same streets, so the scene is not controlled; I didn't measure the frame-time side, which is what your numbers are about. So this doesn't contradict your camera-turn result, but on this CPU 4 workers seem too few for fast driving. Something between 4 and 16, or a count that grows while the queue is long, might keep both. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
IRennie74 commented 2026-12-01 06:28:27 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by IRennie74 on 2026-12-01T06:28:27Z.


What this does on a 6-core. A Ryzen 5 5600X (6 cores, 12 threads, one CCD) is not placed on a half, so off_the_frames_cores() returns all 12 and this takes the shared branch: shared_workers(12) = 3 workers at priority 0. That is one fewer than the 4 that isgti07-hub found too few for fast driving on a 9800X3D, and this CPU has less to spare.

On the same 5600X with an RTX 3060 (Series S, DLSS Performance) we went the other way. The pool stays below normal, and part of it goes up to normal only while the title is waiting for a read: two IsComplete polls of a still-pending entry within 4 ms (its Sleep(1) loop), or a request that has sat 4 ms since its submit. It drops back after 16 ms with neither. Before that, requests on the frame's chain came to 14 ms a frame on average in a loading stretch and 45 ms at worst. That change went in with six other launcher defaults, and the set together brought streaming requests on the frame's chain from 13.9 to 2.3 ms a frame and the walking p99 frame from 268 to 202 ms. We did not measure it on its own, so I can't give its share.

Raising workers only while the title waits might keep your camera-turn gain and avoid the slow textures when driving. Both changes edit the same workers/priority lines in scheduler(), so they can't both land as they are. We haven't run this PR on the 5600X. VICTORY_DSTORAGE_WORKERS=3 VICTORY_DSTORAGE_PRIORITY=0 against unset is the A/B we'd use.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7302913702 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4639#issuecomment-7302913702). Originally posted by [IRennie74](https://github.com/IRennie74) on 2026-12-01T06:28:27Z. --- What this does on a 6-core. A Ryzen 5 5600X (6 cores, 12 threads, one CCD) is not placed on a half, so `off_the_frames_cores()` returns all 12 and this takes the shared branch: `shared_workers(12)` = 3 workers at priority 0. That is one fewer than the 4 that isgti07-hub found too few for fast driving on a 9800X3D, and this CPU has less to spare. On the same 5600X with an RTX 3060 (Series S, DLSS Performance) we went the other way. The pool stays below normal, and part of it goes up to normal only while the title is waiting for a read: two `IsComplete` polls of a still-pending entry within 4 ms (its `Sleep(1)` loop), or a request that has sat 4 ms since its submit. It drops back after 16 ms with neither. Before that, requests on the frame's chain came to 14 ms a frame on average in a loading stretch and 45 ms at worst. That change went in with six other launcher defaults, and the set together brought streaming requests on the frame's chain from 13.9 to 2.3 ms a frame and the walking p99 frame from 268 to 202 ms. We did not measure it on its own, so I can't give its share. Raising workers only while the title waits might keep your camera-turn gain and avoid the slow textures when driving. Both changes edit the same `workers`/`priority` lines in `scheduler()`, so they can't both land as they are. We haven't run this PR on the 5600X. `VICTORY_DSTORAGE_WORKERS=3 VICTORY_DSTORAGE_PRIORITY=0` against unset is the A/B we'd use.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4639:upstream-pr/4639'
git switch 'upstream-pr/4639'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4639'
git switch 'upstream-pr/4639'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4639'
git switch 'upstream-pr/4639'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4639'
git switch 'main'
git merge --squash 'upstream-pr/4639'
git switch 'main'
git merge --ff-only 'upstream-pr/4639'
git switch 'main'
git merge 'upstream-pr/4639'
git push origin 'main'
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!4639
No description provided.