victory-gpu: a vram line every 5 s: how the card is shared and what letting copies go costs #216
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!216
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-216"
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?
@skalel on GitHub · 2026-12-02 19:07 UTC · original
skalel:feat/texture-low-vram→main· +410 −7 · 7 files · 1 commits · openA
stats: vramline every 5 s, after the frame line: how the card's memory is shared between title memory and host copies of textures, and what letting copies go costs. It changes nothing a run does; it is what a change to how they share the card can be measured by.This PR used to carry two switches as well. As suggested in review it is split in three: this line, then
VICTORY_RESERVE_RELEASE(#481), thenVICTORY_SMALL_FIRST, left out (below).The line
texture_side_mb) and the band it falls in; the room kept for render targets (kept_mb); title memory on the card, movable and fixed, and its room; host copies of textures and those idle; render targets; free room in texture blocks; the rest.remade_soon); slots the texture pass found waiting for a copy that was let go (slots_after_let_go, which read nothing until it is made again); textures let go at least once; streamed out; refused passes.The band comes from
host::keep_band, which holds the percentages and whichvram_keepnow goes by too, so the line cannot drift from it (it used to mapvram_keep's idle times back to bands).(Series X, 1080p, FSR 4 quality, in the world.)
Checked
vram_keepat every percentage; the texture side's value is whatvram_plancompares; a stale look is none; counts since the last line count once; a copy made again within 5 s counts as remade soon; a texture made again no longer counts as let go.Small-first, held back
VICTORY_SMALL_FIRSTis not in either PR. An earlier version of this body said it "did not help" fromslots_after_let_go, which cannot show it: that counter counts a let-go texture's slot when the pass makes its copy again, whole or small, the same event either way. A local build that also counted the slots the pass holds back black for lack of room (for up to some four seconds) found that none of them were of a let-go texture: a slot already made from its view is never held back (has_its_texture), so a let-go copy is made again at once, room or not. The long black waits are slots of textures not made yet, which small-first does not reach. In an off/on pair on Series S without the reserve given back, on was worse:So it stays out. The held-back slots are the next thing to look at (a counter for them, and why they wait out their four seconds once the card has room again).
@abomalocaris's device loss with both switches on (with #342, spin test, ray tracing off) did not reproduce here in a 3-minute spin with small-first on, 37,000 small copies, without #342.
🤖 Generated with Claude Code
@chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:07 UTC · original · edited 2026-12-02 19:13 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
ce2ad5dℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:13 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
ce2ad5de81ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@ -1676,0 +1775,4 @@let small = small_level(&r.desc);if small > base {base = small;made_small = true;@chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:13 UTC · original
When
VICTORY_SMALL_FIRST=1is enabled and the first post-eviction view starts at a mip later thansmall_level,base_levelis already at or beyondsmall, so this branch leavesmade_smallfalse even though the returned host copy is partial. If a later pass asks for an earlier mip,want_level_inseesSMALL_NOand takes the ordinary growth path without checking for room, so a full copy can be allocated while the card is full and the slot can go black until upload instead of keeping the blurred copy. Mark post-let-go copies that still lack earlier levels as small-first, not only cases where this branch changedbase.Useful? React with 👍 / 👎.
@ -1407,0 +1466,4 @@Growth::Park => {if park_once(&host.small_first) {crate::vram::SMALL_FIRST[3].fetch_add(1, Relaxed);let parked = (r.data() as u64, host.clone());@chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:13 UTC · original
When a copy is parked because
room_lately()is false, this clone leaves a second strongArcinGROW_PARKEDuntilgrow_parked()drains it on a room-positive texture pass.take_idle()only evicts a copy whenArc::strong_count(host) == 1, so after this texture stops being used and its slots and lists release it, the queue alone prevents eviction. Under sustained VRAM pressure the parked copy cannot help recover room, and if room never returns the allocation remains pinned; use a weak reference or remove the queue entry when the copy is no longer current.Useful? React with 👍 / 👎.
276f22c) into feat/texture-low-vram db9192a72f71317d7) into feat/texture-low-vram da14780396a7a417b) into feat/texture-low-vram bc332db5f1@abomalocaris on GitHub · 2026-12-04 04:14 UTC · original
Crashes with
VICTORY_SMALL_FIRST=1 VICTORY_RESERVE_RELEASE=1on currentmain+ #342, 16 GB cardSetup: RX 9070 XT 16 GB, Ryzen 7 9800X3D, 32 GB RAM, CachyOS (kernel 7.3.7),
proton-cachyos-slr, this repo's patched Mesa 26.3.1 and vkd3d-proton. Series X profile, 2560x1440 output with FSR 4 quality, ray tracing on,VICTORY_PAGES=0,VICTORY_PLACED_COPIED=1,VICTORY_VRAM_BUDGET_MB=17000,VICTORY_TEXTURE_ROOM_PERCENT=87,VICTORY_TEXTURE_ROOM_CAP_PERCENT=87.First the good part, on
mainat842767awith this PR and #262/#274 merged. A scripted 3.4 minute walk-and-pan on one save, summingslots_after_let_gofrom thestats: vramline:A 10 minute run with both on and the budget settings: 4,287 waited, 4,202 shown small first, no crash. So it does what it says on a 16 GB card too.
The problem, on
mainat00aa4d3with this PR, #342 and #344 merged, hardware ray tracing off: a scripted test that turns the camera in place for 3 minutes ended in a lost device (0x887A0005) in 3 of 5 runs with both switches on, between about 30 and 140 seconds into the scene. The kernel log shows a GPU page fault each time ([gfxhub] page fault,Faulty UTCL2 client ID: SQC (data)), then a ring timeout.VICTORY_HW_RT=1and its companions: 0 of 4 runs (3 spin, 1 walk).I did not test the two switches separately, so I can't say which one it is. The spin test streams very hard (about 200,000 new texture slots in 3 minutes), which may be what it takes to hit it. I can run either switch alone or a diagnostics build if that helps.
Written with AI assistance (Claude Code); the runs and observations are from my own machine.
@Widget9337 on GitHub · 2026-12-04 06:17 UTC · original
Results from a 16 GB card on the Series X profile with ray tracing on, which the PR lists as untested. RX 9070 XT, 7950X3D, 64 GB RAM, CachyOS (kernel 7.2), this repo's Mesa and vkd3d-proton, 1080p output with FSR 4 Balanced, 30 cap. The build is
8585cd4with this PR's own commits and #428 picked on top (not currentmain, and not #342 like @abomalocaris). Three runs of about 6 minutes each, walking, turning back and some driving, summed from thestats: vramline:"Budget 17000" is
VICTORY_VRAM_BUDGET_MB=17000withVICTORY_TEXTURE_ROOM_PERCENT=87andVICTORY_TEXTURE_ROOM_CAP_PERCENT=87, as in abomalocaris's runs.The reserve matters on Series X too. With the switches off, the render targets sat at 1.45 to 1.53 GB for the first 5 minutes, just under the 1.5 GiB that gives the room back, so
kept_mbstayed at 1.5 to 1.9 GB and the texture side sat in band 2 (copies idle 2 s let go) with 1.3 to 1.7 GB of the card free. Once the targets passed 1.5 GiB the room came back and letting go nearly stopped. WithVICTORY_RESERVE_RELEASE=1that happened about 90 s in.Without the raised budget, small first works against itself here. The keep line is 80 % of a 15.4 GB budget, so the card sat in band 2 and 3 with 1.6 to 3 GB free, small copies had no room by the budget's count to grow, and about 1,400 stayed small from 3 minutes on. That run was worse than the switches off on every count. With the budget raised, small copies at a time stayed flat around 40.
Frame rate: the three runs averaged 26.8, 26.0 and 26.2 fps, and that spread follows the scenes, so I can't claim a gain or a loss.
No crash in the two runs with both switches on (about 13 minutes), no lost device and no GPU page fault in the kernel log. I didn't run a spin test like abomalocaris's, and this build has no #342.
By eye: the flickering didn't improve at all. What I notice most is the one frame black flashes in #69, which this PR isn't meant to fix, so the drop in waiting slots didn't show as anything I could point to. I'm keeping both switches on with the raised budget.
@Luxuride on GitHub · 2026-12-04 12:02 UTC · original
The diagnostics half is good work and reviewable in five minutes; the memory-policy half is a state machine that decides what a frame sees, and it is in the same PR. Splitting would help more than anything else you could do here.
The one thing to check before anything else:
crates/victory-gpu/src/resource.rs:1727—hosted_fornow hands out a copy smaller than the level the view asked for underVICTORY_SMALL_FIRST, whilecrates/victory-gpu/src/descriptor/host.rs:5228still builds the slot from the title's fulldesc[..10], mip count included. So a shader can be told there are N levels over a host texture holding fewer. If the slot's mip count is clamped somewhere, say where; if not, that is an out-of-bounds read on the card.Smaller:
crates/victory-gpu/src/vram.rs:39mapshost::vram_keep's return through the literals600_000 / 4_000 / 2_000, mirroringKEPT_MS/GENTLE_MSinhost.rs:170-180with nothing tying them together; the test atvram.rs:300uses literals too, so a constant change silently mislabels the telemetry.docs/SETTINGS.md:65-66but not inrun.conf.default, so they get no# choices:line and never appear in the menu template.Suggested split: (1) the
vramline alone; (2) small-first; (3) reserve-release. And for 2 and 3, one before/after each — thevramline plus fps and copies let go on a 12 GB card, since the whole PR exists because of a trial on issue #119 that the diff does not reproduce.@skalel on GitHub · 2026-12-04 14:21 UTC · original
@abomalocaris thank you, the spin test is exactly what this needed. I can't tell yet which switch it is, or whether it takes #342 too. Reading the code, the growth of a small copy goes through the replacement path
mainalready has (the old copy is kept for at least a second, then dropped 128 submissions after the last that may use it), so I don't see a use-after-free there. Small-first just runs that path far more often, about 10,000 times in a round here.If you can spare the time, these three would split it, with the same spin test, ray tracing off, on the same build as your crashing one:
VICTORY_SMALL_FIRST=1aloneVICTORY_RESERVE_RELEASE=1alonemain+ this PR without #342For a crashing run, the last
stats: vramlines before the loss and thedmesgpage-fault lines (the faulting address andFaulty UTCL2 client ID) would help most. I'll try to reproduce it here on 12 GB with a scripted spin as well.@Widget9337 thank you too: the reserve sitting just under 1.5 GiB on Series X is a second case for
VICTORY_RESERVE_RELEASE. Small copies stuck small under the system budget are a real flaw: they grow only while the card has room by the budget's count, and in bands 2 and 3 that never comes. I'll fix that in the small-first part.As @Luxuride suggested, I'm splitting this into three: the
vramline alone (no change in behaviour), the reserve release, then small-first. This PR will keep thevramline, and I'll link the other two here.@skalel on GitHub · 2026-12-04 14:21 UTC · original
@Luxuride thanks. On the one to check first: a slot never claims more levels than the copy holds. When the slot is written from a host copy that starts at a later level,
descriptor/host.rs:4776callsfrom_base(desc, copy.base, own_mips)(:4971), which movesMostDetailedMipdown by the copy's base, clamps it andMipLevelsto the copy's own mip count, and lowersResourceMinLODClampby the base. The title'sdesc[..10]thatplaced()carries (:5265) is what that starts from, not what reachesCreateShaderResourceView.from_baseis onmainalready (:4748/:4943there), for copies that start at the first level views ask for; small-first just gives it a later base more often.The smaller two:
vram::bandwill takeKEPT_MS/GENTLE_MSfromhost.rsinstead of the literals, with the test going by the same constants, and both switches get their lines inrun.conf.defaultwith choices, so F1 lists them.Split as you suggest: (1) the
vramline, here; (2) reserve release; (3) small-first. Each one gets its own before/after on this 12 GB card,vramline and fps.@skalel on GitHub · 2026-12-04 14:22 UTC · original
On
crates/victory-gpu/src/resource.rsline 1778 (outdated):Fixed in
ffa02f7: a copy made after a let-go with the switch on is marked small first whenever it is made from the first page's level or a later one (base.max(small_level)inside thesmall_firstbranch setsmade_smalleither way), so its growth waits for the upload, the pass and room like any small copy.a_texture_back_at_its_first_page_level_is_small_firstcovers a first view at the first page's level.@skalel on GitHub · 2026-12-04 14:22 UTC · original
On
crates/victory-gpu/src/resource.rsline 1469 (outdated):Fixed in
ffa02f7:GROW_PARKEDholds aWeak<HostTexture>, so the queue keeps nothing alive andtake_idlecan let a parked copy go; when the queue is drained, a copy already gone is skipped.a_parked_copy_is_not_held_by_the_queuechecks the strong count is unchanged by parking.bc332db5f1to7d9e57e947textures on 12 GB cards: give the render targets' room back, and bring a let-go texture back blurred instead of black (both opt-in)to victory-gpu: a vram line every 5 s: how the card is shared and what letting copies go costs7d9e57e947to624d18ca10@skalel on GitHub · 2026-12-04 18:40 UTC · original
@Widget9337 a correction to what I said above: small-first is out, not fixed. Measured with a counter of the slots held back black for lack of room, none of those were of a let-go texture (a slot already made from its view is never held back, so a let-go copy is made again at once), and on was worse in an off/on pair; the body has the numbers. The reserve part, where your Series X case applies, is #481.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.