Repository navigation
Sweep: the once-a-second sweep in bounded steps (texture sweep by window and time budget, slot eviction with a rest, parts in turn): frames over 100 ms from about 25 a run to 0-2 - #3858
Conversation
…n turn, the slot eviction's rest, each part timed The pure half of bounding the once-a-second sweep (crate::sweeping): `walk` looks at most 8,192 entries from where the last stopped and reads the clock every 64; `in_turn` runs the sweep's extra parts one after the other while time is left; `BackOff` is the slot eviction's rest after a pass that let nothing go, ended by its time, a 2 % rise of the card's use or room refused after there was some. The switches and numbers (VICTORY_SWEEP_BOUNDED, VICTORY_SLOT_EVICT_BOUNDED, VICTORY_SWEEP_SPREAD, VICTORY_SWEEP_BUDGET_MS, VICTORY_SLOT_EVICT_BACKOFF_MS) are read here; nothing uses them yet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nd a time budget, the slot eviction with a rest, the parts in turn, each part timed The once-a-second sweep runs on the submitting thread, and the frames of a scripted walk over 200 ms (22 of 22 in the first 75 s) fell in or right after one: over the card's line `resource::let_go_idle` walked and sorted every texture (46,000-77,000) under the table's lock and locked each idle one, letting little go (55-81 ms a sweep); the slot eviction walked them all again and let go of nothing in the whole run. - Texture sweep (VICTORY_SWEEP_BOUNDED, on; =0 as before): over the line, a window of at most 8,192 textures from where the last sweep stopped, looked at in half of VICTORY_SWEEP_BUDGET_MS (3), its idle copies let go the longest idle first in the rest of it; the next sweep begins at the first not reached. A copy found held is passed by for 5 s. The limit is the card's rule anew at each sweep, so what one could not let go the next asks for. The streamed-out part and the part of the table without a limit stop at the budget too and go on there; the dead render targets' pass every 5 s walks the table over several calls. - Slot eviction (VICTORY_SLOT_EVICT_BOUNDED, on; =0 as before): the same window and budget; after a whole pass that let nothing go it rests VICTORY_SLOT_EVICT_BACKOFF_MS (30,000; 0: no rest), less if the card's use rises 2 % of the budget or room is refused after there was some. - The sweep (VICTORY_SWEEP_SPREAD, on; =0 as before): the texture sweep at every sweep, then windows and staging buffers, dead render targets and slot eviction in turn while the budget from the sweep's start lasts, at least one; a part with nothing to do gives its turn on. A flush (F7/F8) runs all at once as before. The settle made for a sweep behind flights is left as it was (VICTORY_SWEEP_AHEAD), only timed. - The frame-rate report says, when a sweep ran since its last line, each part's calls, longest and summed milliseconds, and how many sweeps had a walk stopped at the budget. A texture is still let go only under the table's lock and its own, held by nothing but its title texture, as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reaching the end of the texture table does not mean the candidate loop reached every copy. Remember a deadline cut across windows and only enter backoff after a complete pass that released nothing. In the bounded path, count bytes actually released so a renewed candidate can give the next oldest its turn within the same budget.
|
A deadline cut can look like a complete empty pass and trigger the 30-second rest. The table cursor can wrap before the candidate loop runs. If the first candidate became active again and the deadline cuts the loop before the next one, Follow-up 063d3d9 records a cut across windows and only arms the rest when the attempts finished. The bounded path also counts bytes actually released. It can move past a renewed candidate to the next oldest while there is time, with the existing deadline and cap. The unbounded path still uses the preselected candidate set. A deterministic regression failed on the old pass accounting. It now covers both an earlier window cut and a final window cut, plus the complete empty-pass control. A second test exercises a failed first candidate, an expired deadline, and progress when the next attempt has time. The targeted sweeping and resource diagnostics suite passed on Windows (58 passed, 1 ignored), as did staged asset policy. Gameplay frame pacing remains to be measured. |
|
@tyr0nsur You're right, thank you. The rest was armed on "the walk wrapped, the pass began at the table's start, nothing went", and the letting-go loop stops at the deadline after its first candidate. So a window whose first candidate was in use again, cut before the second, read as a whole pass that let nothing go, and slot eviction rested for 30 s with candidates never tried. The same holds when an earlier window was cut, as you say. I read 063d3d9 and ran it on Windows on top of this branch: the sweeping tests (15, with your two), the resource tests, and both of CI's clippy runs, which add no warning over main. I've added it to this PR's branch as your commit, unchanged. Its move from the preselected oldest-covering set to "oldest first until the bytes actually released meet the need" on the bounded path is a behaviour change I agree with: a renewed candidate no longer uses up the allowance. Not measured in the game on my side yet either; I'll say here when it is. |
…3858 + trustno1-coder#3918 + trustno1-coder#3832 for 1% lows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open-World Walking Cross-Validation on RTX 5070 Ti (
|
Metric (victory_gpu::sweeping & frame_times) |
Before #3858 (4-min HWRT Walk) | With #3858 (VICTORY_SWEEP_BUDGET_MS=3) |
Delta |
|---|---|---|---|
| Max single sweep duration | 48.2 ms | 1.9 ms (steady walk) | -46.3 ms (-96%) |
Frames > 100 ms (4-min walk) |
38 | 7 (4 of 7 were first-time cold shader compiles) | -82% |
| P95 frame time (4-min walk) | 70.0 ms | 49.4 ms | -20.6 ms |
| 1% Low (P99) frame time (4-min walk) | - | 53.3 ms (18.8 fps) | Clean |
| 6-Scene Multi-Time Stress (Sunset / Noon / Vice City Noon / Misty Dawn) | - | >100 ms = 0 on all 4 steady scenes |
Zero sweep stalls |
Note on edge cases: Under very heavy VICTORY_CARD_METER_PIPELINES=1 + VICTORY_SUBMIT_FRAMES=2 telemetry runs, first / slot eviction parts still occasionally showed 5–19 ms sweeps while textures stayed strictly bounded at 1.7–2.1 ms (stopped at the budget), confirming the texture-sweep time budget works as designed and eliminates the dominant streaming hitch source. Strong LGTM!
…ed steps (texture sweep by window and time budget, slot eviction with a rest, parts in turn): frames over 100 ms from about 25 a run to 0-2
Preserve EXEC masks across loop joins, including the light atlas used in 24/7 interiors. Include the shader regression cases from trustno1-coder#2853 and trustno1-coder#3871. Enable split submission in the two Foxhound launchers (trustno1-coder#3809). Snapshot the hash buffers before the sender records work (trustno1-coder#3881), including allocation failures affecting declared and probed ranges. Port the incremental resource sweep and empty-pass backoff from trustno1-coder#3858. Preserve manual flush behavior and include coverage for sweep progression and eviction.
|
Same-binary A/B on a 32 GB machine, where the sweep's cost turns out to sit mostly outside the bounded parts. Setup: i9-14900K (8P+16E), RTX 4090 24 GB, 32 GB RAM (the layer treats it as limited host RAM), Windows 11 Insider 26300, driver 617.14. Series X profile, DLAA, FG off, RT as
(Medians of the per-run figures, range in brackets. A fifth "off" run was lost to the #2393 SSE4a fault while loading, unrelated.) Every "on" run had fewer >100 ms frames than every "off" run, so the gain is real here, but it is about −16 % of the >100 ms frames and −8 % p99, not the near-zero reported above. Why so much is left — the sweep's own timing lines (
The texture walk is held to its budget as designed ( I haven't profiled which call inside |
|
@botto854 Thank you, this is the measurement the description was missing. Agreed on all of it: what this PR puts under Your finer timing of This branch also needs a rebase onto current main (conflicts in |
|
Timed each step of Total per sweep: median 25 / 24 ms, p95 55 / 53 ms, max 147 / 77 ms (run 1 / run 2).
(ms, run 1 / run 2; So it's the trims, not refresh / room / memory_now. Within Two things I noticed reading them (not measured separately, so treat as hypotheses):
Happy to A/B a follow-up on this box. If you'd rather I write it, say so, but you know the sweeping |
What was wrong
The once-a-second
sweep()inhost.rsruns on the submitting thread, so its cost lands in a frame. A scripted walk put the worst frames on it. Every frame over 200 ms in the first 75 s (22 of 22) fell in a sweep or right after one, and so did 18 of the 22 frames over 100 ms after that.resource::let_go_idleover the card's line. Each sweep walked and sorted every texture in the table (46,000-77,000 in that run) under the table's lock, then locked each idle one. It let little go (about 76 MB a sweep) and took 55-81 ms a sweep, 7-10 ms once settled. The title's own texture creation waits on that lock meanwhile.VICTORY_SLOT_EVICT=1, which the launcher sets) walked the whole table again at every sweep. It let go of nothing in the whole run, at 93 % of the budget.What it changes
New module
crates/victory-gpu/src/sweeping.rsholds the pure parts, which need no device and have unit tests:walk: walks a table from where the last walk stopped, under a count (8,192 entries) and a clock (read every 64 entries).in_turn: runs the sweep's extra parts one after the other while time is left.BackOff: the slot eviction's rest.In
resource.rsandhost.rs:VICTORY_SWEEP_BOUNDED, on).VICTORY_SWEEP_BUDGET_MS.held_untilstamp onHosted). Only the look is put off: the copy is not let go any sooner or later than the rules say.let_go_dead_targets). Bounded, it walks the table over several calls under the same count and budget. Its rules are unchanged.VICTORY_SLOT_EVICT_BOUNDED, on).VICTORY_SLOT_EVICT_BACKOFF_MS(30,000).resource::room) is refused after there was some.VICTORY_SWEEP_SPREAD, on).VICTORY_SWEEP_AHEADoff) is unchanged. It is only timed.A texture is still let go only under the table's lock and its own lock, and only when nothing but its title texture holds it, as before.
VICTORY_SWEEP_BOUNDED=0: off)=0is the code path as before.VICTORY_SLOT_EVICT_BOUNDED=0: off)=0walks everything at every sweep, as before.VICTORY_SWEEP_SPREAD=0: off)=0runs all of them at every sweep, as before.VICTORY_SWEEP_BUDGET_MSVICTORY_SLOT_EVICT_BACKOFF_MS0: no rest)The three on/off switches are
toggled!switches, soVICTORY_ABcan flip them while the title runs in diagnostics andabbuilds.How it was tested
cargo testpassed for the crates it touches: no failure that main does not have on this machine (the 13 sweep tests pass; victory-gpu's suite was run five times on main and on this branch). Both of CI's clippy runs add no warning over main.Limits:
made.take()as main does (the measured branch had Check the whole backing before idle texture eviction and preserve eviction totals #2724'stake_unmapped_hostthere).Not tested
Checked for overlap
I searched the open pull requests for the same issue and for the files this touches. I read each PR's diff against main. "Conflicts" means
git merge-treeagainst this branch.victory-gpu: bound let_go_idle sweep and back off empty slot_evict pa… #2549 (KleiinMoretti): bound let_go_idle sweep and back off empty slot_evict passes. The same goal and the closest idea: the limited path's candidate scan is cut to an 8,192-entry slice, the let-go loop gets a 4 ms cap, and slot eviction rests between passes (15 s after an empty one, 5 s or 2 s otherwise). It is smaller than ours. Conflicts in
resource.rs.idle_ms < 60_000 && !unmapped_onlyrule that walks the whole table without a limit, which changes which copies go. Ours keeps that rule.Slot eviction: look for victims off the submitting thread (VICTORY_SLOT_EVICT_ASIDE) #3750 (Mikey970): slot eviction looks for victims off the submitting thread (
VICTORY_SLOT_EVICT_ASIDE). It moves the whole look to a thread of its own, includingdescriptor::evictable_slots(the heap scan), and holds the table 4,096 entries at a time.evictable_slotson the submitting thread: it bounds only the texture walk and the letting go.resource.rs.GPU: the look for idle textures in slices, the longest refreshes first #3578 (BaRian29): the look for idle textures in slices. A 1 ms slice (
VICTORY_SWEEP_SLICE_US) on the streamed-out part and the no-limit part, which goes on at the next submission rather than the next second.resource.rsandhost.rs. If it lands first, our two streamed-out and no-limit cut-offs could give way to its slices.victory-gpu: eliminate 60 ms let_go_idle sweep stutter, lock-free watch/pending hot paths & recording contention fixes #3502 (Rulemore): eliminate 60 ms let_go_idle sweep stutter, lock-free hot paths. A large multi-topic PR. Its sweep part adds a lock-free
has_mademirror so every walk skips textures without a copy, apinned_untilskip for slot-pinned copies (the same idea as ourheld_until), and a 2 ms cap on the limited let-go loop.has_madeis complementary and good: it makes each entry of our window cheaper. Conflicts inresource.rs.Texture sweep: the card's rule frees idle textures under RAM pressure too, backs off instead of churning, and keeps textures shown through slots #3475 (nyxctura): texture sweep policy. It changes what the card's rule lets go and how often sweeps run behind flights. It does not bound a sweep's cost. Complementary, but a large textual conflict in
resource.rsandhost.rs.gpu: reclaim idle superseded and slot-pinned dead render targets #2361 (nidea1): reclaim idle superseded and slot-pinned dead render targets. It moves the dead render targets' pass into its own function, as ours does, and widens what it reclaims; it still walks the whole table. Complementary (its rules, our bounded walk). Conflicts in the same block.
Check the whole backing before idle texture eviction and preserve eviction totals #2724 (Tristan1019-user): check the whole backing before idle texture eviction. If it lands, its
take_unmapped_hostbelongs inlet_go_dead_targets. Conflicts inresource.rs.perf(gpu): reclaim idle textures on submit thread #2511 (wrq2007): reclaim idle textures from the submission thread. It runs
let_go_idleagain, up to four times a second, when a texture pass finds no room, with its old signature. With ours, those extra calls would be bounded too. Conflicts inhost.rs.Slot eviction: its own time is in its line (#1644) #2075 (kalberts0089-hash): slot eviction's own time in its line. Its timing overlaps our sweep line. Conflicts in
resource.rs.resource: check unmapped_only instead of host_idle.is_some() in let_go_idle #3272, victory-gpu: start slot eviction when the card is over its budget #3454, GPU: report slot eviction totals and whole texture blocks let go #3766 merge cleanly with this branch; Host texture sweep: keep copies the title wants back soon after a host-pressure let-go (#3512) #3681, Slot eviction: hang probe and stack dump, compute protection, opt-in guards, memory by holder #2372 conflict textually, with no disagreement in behaviour.
gpu, scripts: fix 5s VirtualQuery frame-pacing spikes, glass reflection specks, and 6-core thread sizing #2783 (wilderr24): 5 s VirtualQuery frame-pacing spikes. Another periodic hitch, with no code overlap; complementary.
🤖 Generated with Claude Code