Memory line: take the texture census on a thread of its own, in chunks, every 60 s #3267
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CuteBooty on 2026-11-29T21:09:54Z.
What 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
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ErRusso on 2026-11-29T21:25:05Z.
Review: COMMENTED
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.