Memory line: take the texture census on a thread of its own, in chunks, every 60 s #3267
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3267
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3267"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@CuteBooty on GitHub · 2026-11-29 21:09 UTC · original
CuteBooty:pr-census-thread→main· +143 −17 · 2 files · 1 commits · merged 2026-11-30 14:12 UTCWhat was wrong
With
diagnostics,copystat::logwrites the memory line every 5 s on the thread that presents frames.log_memorycallsresource::census()andresource::targets_census(), and each of them walks every title texture alive (450-560k in a long session) while holding the global textures' lock for the whole walk. A pass took 22-146 ms in our logs. The presenting thread stalls for that long, and so does every other thread that makes or frees a texture in that time, because it waits for the same lock. In one play run on an 8 GB card, at least 12 of 41 hitches a minute lined up with these passes.What changes
VICTORY_CENSUS_Sseconds, 60 by default, on a thread of its own namedvictory-census. Only one census runs at a time.copystat.rsandresource.rsinvictory-gpuchange, and only code underdiagnostics.censusandtargets_censustake achunk: Option<usize>. A new helperwalk_texturesdoes the walk: whole under one lock withNone, as before, or in chunks.Switches
VICTORY_CENSUS_S600= never take itVICTORY_CENSUS_INLINE1= take the census on the logging thread with the lock held for the whole walk. WithVICTORY_CENSUS_S=5this is the old behaviourHow it was tested
On this branch (main
829188e96+ this one commit):cargo build -p victory --release: builds. Withoutdiagnosticsthe compiled code is the same as main's, because everything changed is underdiagnostics.cargo test -p victory-gpu: passes. One run hadhost::card_steps::tests::places_written_after_sending_are_learnedfail; it passed three times on its own and in the full run on main. It looks flaky under parallel tests and is not related to this change.cargo clippy -p victory-gpu: no warnings in the changed code.829188e96the diagnostics build does not compile without the open PR #2386; the errors are the shadowedtimingand the missingmb, none in this change. This PR does not include #2386. With #2386 applied on top for the check only:cargo build -p victory --release --features diagnosticsbuilds.cargo clippy -p victory-gpu --features diagnosticsgives 30 warnings, the same count as main + #2386, and none in the changed lines.cargo test -p victory-gpu --features diagnostics:compose::tests::bgrx_plane_selects_a_typed_viewfails (DXGI_FORMAT(88)vs93). It fails the same way on main + #2386 without this change. The rest pass, apart from the occasional flaky test named above andwatch::many_askers_tests::no_mapping_is_lost_between_askersonce.In play:
Hardware: RTX 3070 8 GB, Ryzen 7 5800X3D, 32 GB RAM, Windows 11 build 26200, NVIDIA driver 621.24.
Related: #791 (VRAM growth on 8 GB cards; the memory line this census feeds is the main tool for watching it).
🤖 Generated with Claude Code
The diagnostics memory line runs every 5 s on the presenting thread and walked every title texture twice (census, targets_census), 450-560k of them, holding the textures' lock for the whole walk. Each pass took 22-146 ms, and every texture made or freed in that time waited for the lock: at least 12 of 41 hitches a minute in one play run on an 8 GB card. Now the census is taken every VICTORY_CENSUS_S seconds (60 by default, 0 = never) on a thread of its own ("victory-census") that holds the lock for 4096 textures at a time. The memory line prints the last census and one line saying how old it is and how long it took; its other numbers are still every 5 s. VICTORY_CENSUS_INLINE=1 with VICTORY_CENSUS_S=5 gives back the old behaviour (inline, the whole walk under the lock). Related: #791. (cherry picked from commit a4ceae1f3a2cf9edcfe52b3595f616007901d757) Co-Authored-By: Claude Opus 5.5 <[email protected]>@ErRusso on GitHub · 2026-11-29 21:25 UTC · original · reviewed
Reviewed against main (
fbe3dc20). The code is sound:walk_texturesholds the lock for the whole of each chunk whileeachruns, so theResourcedereference stays covered by the same argument aslet_go_idle; resuming fromExcluded(last address)on theBTreeSetis correct, and the walk stops once a chunk comes back short.RUNNING), reset when the spawn fails; the memory line says how old the census is.Notes:
checkjob is not this PR: clippy stops on an unusedunwind_copyincrates/victory-loader/src/crash.rs:804, which the PR does not touch. A rebase after that is fixed on main should turn it green.diagnosticsbuilds, so release players see no change. In particular it does not address #3279 (the ~700 msprocmemwalk), which is a different walk. On main that one already runs on its own thread (procmem.rs:203), so my guess, not measured, is that its 93kVirtualQuerycalls hold the process's address-space lock and stall the other threads'VirtualAlloc/VirtualProtect. The chunking approach from this PR could be applied there too.