Sweeps: the pressed interval as a switch (VICTORY_SWEEP_PRESSED_MS), and a submission with nothing in the air sweeps only when the sweep is due #4226

Closed
Denkiyaa wants to merge 12 commits from upstream-pr/4226 into main
Denkiyaa commented 2026-11-30 17:35:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Denkiyaa on 2026-11-30T17:35:56Z.


Fixes #

What it changes

Two changes in crates/victory-gpu/src/host.rs, one commit each, about the long frames the sweep makes on a card whose texture budget is always full.

1. VICTORY_SWEEP_PRESSED_MS=<n>, the interval of the sweep while the card counts as pressed (default 1500: nothing changes unless it is set). While the card is pressed, Host::sweep_every_ms gives 1.5 s, and the sweep behind flights settles every flight first. On the card measured here the budget is full the whole time in the world, so that is every 1.5 s, and the sweep's frame took 107-110 ms instead of ~42: about 40 ms of settle plus a ~23 ms texture pass. The constant becomes a switch read once; the "sweeps behind flights" line names the interval in use. The default is not changed in this PR: 8000 is what was measured here (below), on one PC.

2. A submission that finds nothing in the air sweeps only when the sweep is due. With the present sent ahead (late_free_present), nothing is in the air at a submission only when the title was slow to give it, which is the frame after a sudden camera turn. Host::submit ran sweep() there every time, on the submitting thread and ahead of the frame's submissions. While the card is full the texture pass asks for an idle reclaim every 250 ms (draw::request_idle_reclaim), so that sweep ran resource::let_go_idle for 39-75 ms under the texture table's lock, on exactly the frames that were already late. The long-frame line of #3703 does not show it: its SWEEP timer covers only the once-a-second part. Now such a submission sweeps only when the sweep is due by its interval (VICTORY_SWEEP_PRESSED_MS / VICTORY_SWEEP_EVERY_MS), as behind flights. Without the present sent ahead it sweeps as before. VICTORY_SWEEP_AT_REST=1 sweeps at every such moment, as before (read with asked_for!).

What it costs: idle textures are let go less often (see the counters below). On this card that did not show as more textures waiting or held back, but this card is the only one measured.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Linux under Proton (GE-Proton11-15), Series S profile, DLSS Quality, texture budget ~8.2 GB and always full. Scripted bench: 30 s standing, then 60 s with a sudden 800 px camera turn every 2.5 s. Measured on a branch of this repository carrying other ports besides this change, under Proton; not measured on Windows, on a card with room to spare, or in cutscenes and fast travel with a longer pressed interval (where new textures may wait longer).
  • Before / after, change 1 (VICTORY_SWEEP_PRESSED_MS=8000 against the default, 3 runs each by turns, frame generation off):
    • frames over 100 ms standing: 9.0 -> 1.7 per 30 s (ranges 5-12 and 1-2);
    • in the turn phase: 27.7 -> 13.7 per 60 s (ranges 18-39 and 13-15);
    • with DLSS frame generation 3X, one run each: 21 -> 4 standing, 42 -> 13 turning;
    • textures waiting, uploaded and held back for room unchanged: waiting at end/max 2454/4406 -> 2834/3505, held back 44.9k -> 44.7k.
    • Other candidates on the same bench: 4000 did little (7.0 and 23.3). VICTORY_SWEEP_PRESS_BY_ROOM=0 helped with frame generation off (2.0 / 15.7) but did nothing with it on. #3858 (the sweep in bounded steps) had the fewest long frames (1.0 / 7.7), but on this full card let about half as many idle copies go: textures held back for room 6.4x, the card over its budget.
  • Before / after, change 2 (3 runs against 2, by turns, frame generation off; only this change differed between the two sides):
    • long frames caused by turns: 14.0 -> 5.7 per 60 s (ranges 11-17 and 5-6);
    • longest frame per turn: 107 -> 92 ms;
    • frames over 50 ms standing: 48 -> 25 per 30 s;
    • rendered fps unchanged (23.7/22.5 -> 23.7/22.9, standing/turning);
    • textures waiting 2497/3762 -> 2661/3813 (end/max), held back for room 43.3k -> 44.0k, idle textures let go 34.3k -> 29.2k (made again after being let go 9.0k -> 6.7k).
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): no shader change.
  • cargo test passed for the crates it touches: no, not run. victory-gpu's tests need Windows, and this was prepared on Linux. What was run: cargo xwin clippy -p victory-gpu --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings on this branch (cut from main 84bd61e2): it builds; the only two findings are main's own and in lines this PR does not touch (method ranged is never used in shadow.rs:7197, manual implementation of .is_multiple_of() in host.rs:5099), and with those two lints allowed it passes with no other warning. cargo xtask policy --staged passed for both commits.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3858 (sweep in bounded steps: compared above; fewer long frames, far fewer idle copies let go on a full card), #4138 (moves the periodic sweep and the idle-reclaim sweep to a background thread: if it lands, change 2 matters only with VICTORY_ASYNC_SWEEP=0, while change 1 still decides how often the settle runs with VICTORY_SWEEP_AHEAD=0), #3502 and #3578 (make let_go_idle itself cheaper: complementary), #3951 (releases trimmed spares off the submitting thread: complementary), #3475 (changes how often sweeps run behind flights: conflicts in sweep_every_ms), #3703 (the long-frame line whose SWEEP timer does not cover change 2's sweep). No open PR makes the pressed interval a switch or skips the sweep at rest.

Written with Claude Code (Claude Opus 5.5): the measurements were run by me on my PC; the code and this text were prepared with it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5570451926 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4226). Originally posted by [Denkiyaa](https://github.com/Denkiyaa) on 2026-11-30T17:35:56Z. --- <!-- Thanks for the pull request. Please label it (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests, plus the area labels), or put the label in the title, like [pr-fix]. --> Fixes # ## What it changes Two changes in `crates/victory-gpu/src/host.rs`, one commit each, about the long frames the sweep makes on a card whose texture budget is always full. **1. `VICTORY_SWEEP_PRESSED_MS=<n>`, the interval of the sweep while the card counts as pressed (default 1500: nothing changes unless it is set).** While the card is pressed, `Host::sweep_every_ms` gives 1.5 s, and the sweep behind flights settles every flight first. On the card measured here the budget is full the whole time in the world, so that is every 1.5 s, and the sweep's frame took 107-110 ms instead of ~42: about 40 ms of settle plus a ~23 ms texture pass. The constant becomes a switch read once; the "sweeps behind flights" line names the interval in use. The default is not changed in this PR: 8000 is what was measured here (below), on one PC. **2. A submission that finds nothing in the air sweeps only when the sweep is due.** With the present sent ahead (`late_free_present`), nothing is in the air at a submission only when the title was slow to give it, which is the frame after a sudden camera turn. `Host::submit` ran `sweep()` there every time, on the submitting thread and ahead of the frame's submissions. While the card is full the texture pass asks for an idle reclaim every 250 ms (`draw::request_idle_reclaim`), so that sweep ran `resource::let_go_idle` for 39-75 ms under the texture table's lock, on exactly the frames that were already late. The long-frame line of #3703 does not show it: its SWEEP timer covers only the once-a-second part. Now such a submission sweeps only when the sweep is due by its interval (`VICTORY_SWEEP_PRESSED_MS` / `VICTORY_SWEEP_EVERY_MS`), as behind flights. Without the present sent ahead it sweeps as before. `VICTORY_SWEEP_AT_REST=1` sweeps at every such moment, as before (read with `asked_for!`). What it costs: idle textures are let go less often (see the counters below). On this card that did not show as more textures waiting or held back, but this card is the only one measured. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Linux under Proton (GE-Proton11-15), Series S profile, DLSS Quality, texture budget ~8.2 GB and always full. Scripted bench: 30 s standing, then 60 s with a sudden 800 px camera turn every 2.5 s. Measured on a branch of this repository carrying other ports besides this change, under Proton; **not measured on Windows, on a card with room to spare, or in cutscenes and fast travel with a longer pressed interval** (where new textures may wait longer). - Before / after, change 1 (`VICTORY_SWEEP_PRESSED_MS=8000` against the default, 3 runs each by turns, frame generation off): - frames over 100 ms standing: 9.0 -> 1.7 per 30 s (ranges 5-12 and 1-2); - in the turn phase: 27.7 -> 13.7 per 60 s (ranges 18-39 and 13-15); - with DLSS frame generation 3X, one run each: 21 -> 4 standing, 42 -> 13 turning; - textures waiting, uploaded and held back for room unchanged: waiting at end/max 2454/4406 -> 2834/3505, held back 44.9k -> 44.7k. - Other candidates on the same bench: 4000 did little (7.0 and 23.3). `VICTORY_SWEEP_PRESS_BY_ROOM=0` helped with frame generation off (2.0 / 15.7) but did nothing with it on. #3858 (the sweep in bounded steps) had the fewest long frames (1.0 / 7.7), but on this full card let about half as many idle copies go: textures held back for room 6.4x, the card over its budget. - Before / after, change 2 (3 runs against 2, by turns, frame generation off; only this change differed between the two sides): - long frames caused by turns: 14.0 -> 5.7 per 60 s (ranges 11-17 and 5-6); - longest frame per turn: 107 -> 92 ms; - frames over 50 ms standing: 48 -> 25 per 30 s; - rendered fps unchanged (23.7/22.5 -> 23.7/22.9, standing/turning); - textures waiting 2497/3762 -> 2661/3813 (end/max), held back for room 43.3k -> 44.0k, idle textures let go 34.3k -> 29.2k (made again after being let go 9.0k -> 6.7k). - For shader changes, the wave sizes tested (32 and/or 64 lanes): no shader change. - `cargo test` passed for the crates it touches: no, not run. `victory-gpu`'s tests need Windows, and this was prepared on Linux. What was run: `cargo xwin clippy -p victory-gpu --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings` on this branch (cut from main 84bd61e2): it builds; the only two findings are main's own and in lines this PR does not touch (`method ranged is never used` in `shadow.rs:7197`, `manual implementation of .is_multiple_of()` in `host.rs:5099`), and with those two lints allowed it passes with no other warning. `cargo xtask policy --staged` passed for both commits. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3858 (sweep in bounded steps: compared above; fewer long frames, far fewer idle copies let go on a full card), #4138 (moves the periodic sweep and the idle-reclaim sweep to a background thread: if it lands, change 2 matters only with `VICTORY_ASYNC_SWEEP=0`, while change 1 still decides how often the settle runs with `VICTORY_SWEEP_AHEAD=0`), #3502 and #3578 (make `let_go_idle` itself cheaper: complementary), #3951 (releases trimmed spares off the submitting thread: complementary), #3475 (changes how often sweeps run behind flights: conflicts in `sweep_every_ms`), #3703 (the long-frame line whose SWEEP timer does not cover change 2's sweep). No open PR makes the pressed interval a switch or skips the sweep at rest. --- Written with Claude Code (Claude Opus 5.5): the measurements were run by me on my PC; the code and this text were prepared with it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
IRennie74 commented 2026-11-30 18:23:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by IRennie74 on 2026-11-30T18:23:04Z.


A data point for change 2 from another rig: Ryzen 5 5600X, RTX 3060 12 GB, 32 GB, Windows 11, Series S at 960x540 with DLSS Performance, diagnostics build. Our build is based on 41adb551, so it predates main's VICTORY_SLOT_EVICT_ASIDE.

Walking through the cell, defaults gave 13-14 fps and about 63 pauses a minute (present gaps over 150 ms). The once-a-second sweep() inline in Host::submit:

  • cost 56-67 ms (up to 242 ms), with nothing in flight, so the card idled through it;
  • was followed by a pause within 3 frames after 40-78 % of sweeps, which is 14-26 of the 63 a minute, in release builds too.

On our build about 85 % of that sweep was slot eviction, which already runs aside on current main (VICTORY_SLOT_EVICT_ASIDE). What stays inline on main is the 1 Hz part and the idle-reclaim resource::let_go_idle that this PR gates. So our numbers support not sweeping at every moment with nothing in the air when the present is sent ahead.

One thing to keep an eye on with change 2: each sweep() call also carries out resource::slot_evict_ready(). With the present sent ahead and the card not pressed, sweep_every_ms is 15 s, so evictions chosen aside are carried out at most every 15 s instead of at every such moment. While pressed it is 1.5 s (or VICTORY_SWEEP_PRESSED_MS), which is where eviction matters, so this may be fine. A sentence at the due check would make it explicit.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7287769947 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4226#issuecomment-7287769947). Originally posted by [IRennie74](https://github.com/IRennie74) on 2026-11-30T18:23:04Z. --- A data point for change 2 from another rig: Ryzen 5 5600X, RTX 3060 12 GB, 32 GB, Windows 11, Series S at 960x540 with DLSS Performance, diagnostics build. Our build is based on 41adb551, so it predates main's `VICTORY_SLOT_EVICT_ASIDE`. Walking through the cell, defaults gave 13-14 fps and about 63 pauses a minute (present gaps over 150 ms). The once-a-second `sweep()` inline in `Host::submit`: - cost 56-67 ms (up to 242 ms), with nothing in flight, so the card idled through it; - was followed by a pause within 3 frames after 40-78 % of sweeps, which is 14-26 of the 63 a minute, in release builds too. On our build about 85 % of that sweep was slot eviction, which already runs aside on current main (`VICTORY_SLOT_EVICT_ASIDE`). What stays inline on main is the 1 Hz part and the idle-reclaim `resource::let_go_idle` that this PR gates. So our numbers support not sweeping at every moment with nothing in the air when the present is sent ahead. One thing to keep an eye on with change 2: each `sweep()` call also carries out `resource::slot_evict_ready()`. With the present sent ahead and the card not pressed, `sweep_every_ms` is 15 s, so evictions chosen aside are carried out at most every 15 s instead of at every such moment. While pressed it is 1.5 s (or `VICTORY_SWEEP_PRESSED_MS`), which is where eviction matters, so this may be fine. A sentence at the `due` check would make it explicit.
trustno1-coder commented 2026-12-01 18:45:25 +00:00 (Migrated from github.com)

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


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:7321482333 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4226#issuecomment-7321482333). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:45:25Z. --- 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!4226
No description provided.