Lowvram/evict guard #2657
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!2657
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2657"
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?
@dejvidkou on GitHub · 2026-11-29 15:38 UTC · original
dejvidkou:lowvram/evict-guard→main· +463 −26 · 7 files · 11 commits · openLow-RAM PCs: no crash a minute into the world (#1520): a guard, CPU mirrors out of the shared memory, a sweep fix
The problem
On a 16 GB PC (RTX 3060 Laptop 6 GB, i7-12650H, Series S, DLSS ultra performance), v2026.11.29.01 crashed about a minute after the world loaded in 2 of 3 runs, with
0x8007000Eon a host command list (issue #1520). A run with FSR frame generation died after 10 minutes with the device removed.At the crash, the PC memory the card may use (the DXGI non-local budget, about half the RAM) was 7,426 of 7,359 MB. In every run, the good one too, "host copies of title memory" grow from ~0.2 GB to 5.6-5.9 GB in the first ~75 s of world load, and their CPU sides are made in that memory (
shadow::buffer_sides). The run that lived peaked at 6,838 MB.The guards in
residency.rslook at RAM and commit only. Commit counts what the pagefile may still grow by (41 GB "left" at the crash), and nothing looks at the non-local budget.What this changes
On hosts with under 24 GiB of RAM (
residency::small_host_ram(), as #1520's other defaults), unset:VICTORY_CARD_CPU_HEAPis on (it was off everywhere);VICTORY_SHARED_GUARDis 85 %;VICTORY_CARD_SWEEP_WINSis on, with the 15 s rule (74174665).On every host, the launcher now warns about a small page file that Windows manages (
6fde7328,aa4ba51d).An explicit value decides on any host (
0off), and bigger hosts are as before.docs/bug-journal.mdhas a line about it.The parts:
VICTORY_SHARED_GUARD(1= 85 %, or a percent 50-98;0off). Once the non-local use passes that share:resource::room,room_for_first_upload);shadow::window_mapped_for), so they take none of the non-local memory;VICTORY_CARD_SWEEP_WINS=1: a fix tolet_go_idle.idle_sweep_policy(3246d252) lets the card's eviction win when both the card and the host are pressured, but the take still asked for wholly unmapped title memory whenever host pressure was on (host_idle.is_some(),0efd23e3). A 16 GB PC is under 8 GiB free in all of play, so a full card got almost nothing back (a few MB in 10 minutes, with 7.2 GB in use of a 5.2 GB budget). Behind a switch because of its first cost here; with the 15 s rule (5) it is on by default on small hosts (below).residency::refreshreads RAM pressure alone (PRESSURED), notpressured().VICTORY_CARD_CPU_HEAPon by default on small hosts (3634e25f's switch, unchanged otherwise). Its ignored measurement test now expects whatCardCpudecides. Set, or named byVICTORY_AB, it is still read throughasked_for!at each call, so A/B runs can flip it.VICTORY_CARD_SWEEP_IDLE_MS(withVICTORY_CARD_SWEEP_WINS=1; 15,000 unset, 1,500-600,000). Under host pressure, a copy whose title memory is still mapped goes only once idle this long; one wholly unmapped goes at the card's own time, as before. The card's rule is 1.5 s on a card past its line, which a 6 GB card is in all of play, so the first version of the fix freed copies that were made again soon after.Measured (same PC, same route, frame generation off, about 10 min each)
VICTORY_CARD_CPU_HEAP=1(existing switch), guard, sweep fixVICTORY_CARD_CPU_HEAP=1(3634e25f, off by default) moved 942 MiB of CPU mirrors out of the non-local memory and kept the run under the guard's line, at no fps cost we could see (10.8 fps with it, 11.3 without).Hence commit
c6fef4e2turns both on by default on small hosts. The sweep fix stayed off until it was cheaper (below).The sweep fix with the 15 s rule (
4c69d44b)One run of the diagnostics build with
VICTORY_AB=30,VICTORY_CARD_SWEEP_WINS, 16 phases of 30 s, the guard and CPU mirrors on in both:The 15 s rule cuts the fix's cost from about +80 % uploads and ~3 fps (the 1.5 s rule) to +13 % uploads and ~2 ms a frame, with 8 % fewer textures waiting. It has more hitches at p90. Played, it felt "a bit smoother", with models and textures coming in quicker at the same fps.
Then on by default on small hosts (
74174665)An 8-minute play run of the release build with it on, against the 1.5 s rule's run (15:06) and a run without it (18:17):
The player saw textures come in sooner, about a fifth less flicker and less stutter. So
74174665turns it on by default under 24 GiB of RAM, like the guard and the CPU mirrors (0off; bigger hosts as before). It also matters on 8 GB cards: a texture a draw, copy or transition uses is made on first use with no room test (resource::host_resource), so on a 16 GB PC only this sweep brings the card back down.The launcher's page file warning (
6fde7328,aa4ba51d)Every run here had ~145 host pipelines "failed" with
0x8007000E(144 mesh, 5 graphics), the same ~130 in each. They are the memory guard's own refusals (memguard::refusal()):compilememputs a driver compile off while it would leave commit underVICTORY_COMMIT_FLOOR_MB(4,096). Windows managed the page file, which stayed at 8.5 GB (a commit limit of 24.7 GB, with the title committing ~21 GB), so commit left was 0.3-2.5 GB all run. A managed page file grows only as commit reaches the limit, and the guard keeps 4 GB under it, so it never grew: 2,048+ put-offs, and none of the 149 was made later in the run.play.rsmemory_warningsays nothing for a managed page file.So a managed page file is now judged by the commit limit now (
ram_and_page_filesalso returnsullTotalPageFile), and the fix the warning names is a custom size: initial 52 GB less the RAM, maximum 12 GB more (36,864 / 49,152 MB on 16 GB), not the managed one.6fde7328did this under 24 GiB of RAM only.aa4ba51ddoes it on every host, after the 32 GB PC in this thread (RTX 5080, a managed page file of 14.5 GB) had 0.4-2.3 GB left to commit in play and 35-49 pipelines refused with0x8007000Ein a 10-minute run: the same put-offs.(The ~110 draws a frame "dropped without a host pipeline" are something else: the ray-tracing passes left out on purpose,
VICTORY_LEAVE_OUTand the water light.)Checks
cargo build --release --locked -p victorycargo test --release --locked -p victory-gpu --lib -- --test-threads=1: 929 passed, 1 failed:shader_cache::tests::every_switch_of_the_translator_is_in_the_key, which fails the same way on main (41adb551). TwotexbackGPU tests fail when run in parallel with the others and pass alone (-- texback:: --test-threads=1). They were not touched here.cargo clippy -p victory-gpu --all-targets: no warnings in the changed lines. Note:-D warningsstops earlier on main, invictory-shader(emit/lower/analysis.rs:6,:467,emit/lower.rs:594).residency::tests::{the_shared_guard_is_on_by_itself_on_a_small_host_and_one_means_85, the_shared_guard_holds_past_its_share_of_the_budget, shared_pressure_enters_at_the_share_and_leaves_five_points_under, windows_may_fill_the_card_but_its_margin_only_when_shared_memory_is_tight},resource::tests::{a_sweep_for_the_card_takes_mapped_copies_only_with_the_switch, the_card_sweeps_idle_time_is_15_s_unless_set, the_card_sweep_takes_mapped_copies_by_itself_on_a_small_host_only},shadow::land_tests::cpu_mirrors_go_to_process_memory_by_default_on_a_small_host_only.cargo test --release --locked -p victory: 82 passed, among themplay::tests::{memory_warned_under_52_gb, a_managed_page_file_is_judged_by_its_size_now_on_a_big_host_too, a_small_managed_page_file_is_warned_about_on_a_small_host}.cargo xtask policy --stagedon each commit.The sweep bug was found in a code read by Gemini and checked against the code and the logs.
🤖 Generated with Claude Code
@NAbobo101 on GitHub · 2026-11-29 17:04 UTC · original
Tested this branch (
3ebcfa5e) against its base (829188e9) on a second 16 GB machine.Setup: RTX 5060 8 GB, Ryzen 7 5700G, 16 GB RAM, Windows 11. Series S, DLSS off, release builds, shaders preloaded, the launcher's defaults (on this branch
VICTORY_CARD_CPU_HEAPandVICTORY_SHARED_GUARD=85came on by themselves, as the startup lines say). Open world, an automated 10-minute walking route from a save in the first house.829188e9(3 runs)0x8007000E, "a host command list did not close")no upload buffer/no shared buffer)So here the branch fixes the load crashes, and the non-local memory stays under the line. The device loss in the middle of the route is there with and without it, at about the same point, so I don't think this PR causes it. In the PR run it surfaced first as
could not snapshot 4 dirty bytes from a private CPU mirror; device removed(0x887A0005), butno upload buffercalls were already failing with the device suspended just before, so I read that as where the loss was noticed, not its cause. In every run the card's own memory went well past its budget (8.4-9.7 GB against ~6.9 GB), which may be what is left to look at on 8 GB cards.Three more runs on
829188e9withVICTORY_CARD_ROOM_FOR_TARGETS_MB=1536went the same way: two died loading with the same error, one lost the device ~3 min into the route.For reference, a build from an earlier main on the same route ran at ~6.6 fps with the card at ~5.3 GB and no allocation failures.
(Measured with an automated route; summary prepared with help from Claude Code.)
@dejvidkou on GitHub · 2026-11-29 20:14 UTC · original · reviewed
Thanks for testing on a second machine, this is very useful.
Good to see the load crashes gone and the non-local memory staying under the line on an 8 GB card too. I agree the device loss in the middle of the route is not from this PR. It happens on the base at about the same point.
The card's own memory going well past its budget matches what I see here: 7.2 GB in use of a 5.2 GB budget on a 6 GB card. The last commit (
68b43cba) is for that. Could you try two things?One run with
VICTORY_CARD_SWEEP_WINS=1on the head of this branch (68b43cba). Without it, under host pressure the card's sweep only takes copies whose title memory is wholly unmapped. On a 16 GB PC that is almost nothing, so a full card gets little back. With it on, mapped copies also go once idle 15 s (VICTORY_CARD_SWEEP_IDLE_MS). Here it gave 8 % fewer textures waiting for +13 % texture uploads and about 2 ms a frame. If you use the launcher, it clears typedVICTORY_*variables, so the line has to go in%LOCALAPPDATA%\victory\victory-settings.txt.memory now:andslot eviction since the last linelines would show it best.Which earlier main ran the route at ~6.6 fps with the card at ~5.3 GB? A commit or release name would let us find what made the card's memory grow past its budget since then. That looks like the next thing to fix for small cards.
Thanks again!
The memory warning before a start said nothing where Windows manages the page file's size ("it grows as needed"). On a 16 GB PC (RTX 3060 Laptop, 2026-11-29) it stayed at 8.5 GB, a commit limit of 24.7 GB with the title committing ~21 GB, and the driver compiles memguard keeps 4 GB of commit free for were put off all run (2,048 times): 149 pipelines were never made. With a custom page file of 36,864-49,152 MB none were, at the same frame rate (12.1 fps against 11.8). Under 24 GB of RAM a managed page file is now judged by the commit limit now (streamline::ram_and_page_files gives it), and on such a host the fix named is a custom size (initial 52 GB less the RAM, maximum 12 GB more), not the managed one. Bigger hosts are warned about as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>@NAbobo101 on GitHub · 2026-11-30 01:38 UTC · original
Thanks! Both done, and two corrections to my earlier comment first.
1.
VICTORY_CARD_SWEEP_WINS=1on68b43cba(same PC, route and launcher defaults as before, one run):3ebcfa5e, sweep fix off (2 runs)68b43cba,VICTORY_CARD_SWEEP_WINS=1(1 run)memory now:)So the card stayed near its budget and the route finished.
slot eviction since the last lineprinted only once during the route (nothing let go), so on this PC the sweep did the work. Textures picked by index ended at ~103,000 uploaded (30 GB) with ~14,900 waiting. One run only, so take the frame rate with some salt.2. The earlier build. I described it wrongly. It was not a plain main: it was v2026.11.27 (
959dcaf) plus 17 commits from another fork (CHECK6960/Victory-Nvidia-optimized, no longer on GitHub) plus a local copy change of mine. Also, "~5.3 GB" was its card memory right after the world loaded, not during play. During play it held ~6.6 GB, inside its budget, with new textures waiting at the 90 % line.So I ran plain
959dcafon the same route (this run withVICTORY_CARD_ROOM_FOR_TARGETS_MB=1536, as my earlier fork runs; the PR runs used the launcher's 3072):So on this PC the card going past its budget appeared between
959dcaf(v2026.11.27) and829188e9, while the frame rate on main went up in the same span (4.9 to 5.4-5.8 fps here). With your sweep fix the card is back near its budget at the better frame rate.(Measured with an automated route; summary prepared with help from Claude Code.)
@dejvidkou on GitHub · 2026-11-30 07:52 UTC · original
Thanks, this is exactly what I hoped for, and thanks for correcting the earlier build. That turns the question from "which main" into "what changed since v2026.11.27".
The sweep fix. On
68b43cbawithVICTORY_CARD_SWEEP_WINS=1the route finished, with no device loss and no allocation failures, and the card sat at 6.8 GB on average against a 6.9 GB budget. It is held on average, not at every moment: the peak of 7.9 GB is still about 1 GB past the budget, so that part is not solved. One run, so I agree the frame rate says little.Defaults. On the current head (
17e52561) the sweep is on by itself under 24 GiB of RAM, with the 15 s rule, so a 16 GB PC no longer needs the line invictory-settings.txt. If you have a run to spare, the plain launcher on the head would confirm it gives the same result as your opt-in run. Not needed otherwise.Where the card went past its budget.
959dcafto829188e9is 1,764 commits, about 11 builds to bisect. The base does the same on my 6 GB card (7.2 GB in use of a 5.2 GB budget). Could you bisect it and post what you find, I'll try the same on my end.Thanks again!
@iridiumLotus on GitHub · 2026-11-30 08:25 UTC · original
A data point from a host this PR leaves as before:
VICTORY_CARD_CPU_HEAP=1on a 32 GB PC. It is the existing switch on main, not this branch, so it says nothing about the guard or the sweep fix.Setup. RTX 5080 16 GB, Ryzen 7 5800X3D, 32 GB RAM, Windows 11 build 26300, driver 621.24. Main
41adb551with local commits that do not touchshadow.rsor the host's memory code. Series S, DLSS Balanced, no frame generation, release build, shaders preloaded. Not the launcher's defaults: my wrapper adds switches, of whichVICTORY_WINDOWS_BAR_MB=2048matters here (windows in mapped card memory, so the non-local figures below are lower than the defaults would give), and it leaves out the two particle light-atlas programs of #2348. Every run starts from the same copy of one save.Standing in the first house, three alternated pairs, 90 s measured each:
VICTORY_CARD_CPU_HEAP=1private_mib, mostA 10-minute scripted run on foot from that save (
VICTORY_INPUT_REPLAY), one run each: non-local 5.1 GB on average and 6.0 at most without the switch, 2.1 and 2.5 with it (private_mibup to 3,529). The two runs did not take the same way, 5,645 draws a frame against 7,575, so their frame rates (19.0 and 17.6) and copy-back times (16.2 and 19.4 ms) do not compare; the pairs above do.What it shows here. About 2 to 3 GB leave the non-local memory, as on the 16 GB PCs, and at equal draws neither the frame rate nor the copy-back time moves (#2415 asked whether the landing pays for the extra pages: not measurably on this PC). What it does not change is commit: the diagnostics build's memory line had 4,950 MB left to commit without the switch and 4,814 MB with it, and free RAM went from 4.6 to 5.7 GB. On this host the non-local budget was never the limit, so "bigger hosts are as before" costs nothing I can measure; the switch on would not have either.
Failures in these runs. No device was lost in any of the eight. Host pipelines did fail with
0x8007000E, with and without the switch: one compute pipeline in each of the six standing runs, and in the 10-minute runs 49 without it (41 mesh, 7 graphics, 1 compute) and 35 with it (34 mesh, 1 compute). That fits commit being what runs short on this PC (a page file of 14.5 GB that Windows manages; the game's panel showed 0.4 to 2.3 GB left to commit in play), which this switch does not change.Not tested: this branch, a card of 8 GB, frame generation, ray tracing.
@dejvidkou on GitHub · 2026-11-30 09:36 UTC · original
I bisected it on my side: it is #76 (
05a269d8, "gpu: size the render targets' room by the peak they have held, not a flat 3 GiB").How:
git bisect --first-parentfrom959dcaf(good) to829188e9(bad), release builds, unattended runs on my RTX 3060 Laptop 6 GB / 16 GB RAM (Series S profile, DLSS ultra performance, frame generation off, the character standing at the save, 5-10 min each). The measure is the card's memory in use from thethe texture queue's room:line (it is in every build of the range) after the first 3-4 minutes. The line between good and bad was 5,190 MB, halfway between the two ends; the budget is 5,226 MB.959dcaf(v2026.11.27)d583714d(#45)39c4b995(#61)2ce7a3c1(#74)14e5deda(#76)2414bfad(#92)829188e9Four builds in the range (
a9567c18,24848b85,8e9f11d6,5583a872) were skipped: the title crashed about 1.5 minutes in, all at the same address (0xc0000005, a write to 0). That is an old bug, fixed later, and not related to this.Why #76 does it. Before it,
targets_room_keptkept a flat 3,072 MB of the card for render targets. In a Series S world the targets peak at about 400 MB, so in practice about 2.7 GB stayed free. #76 sizes the reserve at 1.5x the targets' peak instead, about 200 MB here. That fixed a real bug, the black faces: textures that were never uploaded while the card was 41 % used. But those 2.7 GB were also the card's only margin for what is made without a room test: a texture a draw, copy or transition uses is made on first use (resource::host_resource), and so are render targets and card copies of title buffers. Now the texture queue fills the card to its line, and those go past the budget.So I don't think the answer is to undo #76, since the black faces would come back. It needs a real margin under the budget for what is made without a room test. The sweep fix in this PR (
VICTORY_CARD_SWEEP_WINS, now on by itself on small hosts) already brings the card back near its budget, which matches your 8 GB run, but it frees memory after the fact rather than keeping the margin.One thing I can't explain yet: your runs on
829188e9withVICTORY_CARD_ROOM_FOR_TARGETS_MB=1536(the flat reserve again, at half the size) still lost the device. If you have a run to spare, one on the current head withVICTORY_CARD_ROOM_FOR_TARGETS_MB=3072would show whether the flat reserve alone keeps an 8 GB card inside its budget there. I'll try the same on my card.(Bisected with unattended test runs; summary prepared with help from Claude Code.)
@dejvidkou on GitHub · 2026-11-30 09:47 UTC · original
Thanks, a 32 GB PC was the data point missing here. Good to see the 2-3 GB leave the non-local memory there too, at no cost at equal draws.
Your
0x8007000Epipeline failures are, I think, the same thing I found on the 16 GB laptop. They are not the driver running out: they arememguardputting compiles off (memguard::refusal()givesE_OUTOFMEMORYon purpose) while commit would fall underVICTORY_COMMIT_FLOOR_MB(4,096). A page file that Windows manages grows only as commit reaches the limit, and the guard keeps 4 GB under it, so in play it never grows. On my laptop (managed page file of 8.5 GB) 149 pipelines were put off and none of them was made later in the run. With a custom page file of 36,864-49,152 MB there were none, at the same frame rate. Your 0.4-2.3 GB left to commit and a managed 14.5 GB page file fit that.The launcher's memory warning used to say nothing for a managed page file ("it grows as needed"). This PR now judges it by its size now on every host (
d294b752;b574347bdid it under 24 GB only), so your PC would get the warning, with a custom size of 20,480-32,768 MB. If you try a custom page file of about that size, I'd expect the refused pipelines to go to 0.d294b7529etoaa4ba51d83View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.