fix: copies by address give their card room back when they go (+ VRAM census and churn tests) #549
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/549"
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 LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-27T21:00:46Z.
Change
shadow::by_addressputs the copies that ray-tracing shaders read by address (the arenas ofmemory.rs, 64 MiB each, its directory, and the pages around small title buffers) on the card, at mostVICTORY_MEMORY_CARD_MBof them (4,096 MB by default). The count it checked was astatic USEDinside the function that only ever grew:So the limit was on the bytes ever made, not on the bytes alive. Once 4,096 MB had been made in a process, every later arena went to the PC's memory, even with the card nearly empty, and every step of every ray then reads it over the bus. The counter the HUD shows (
BY_ADDRESS_CARD_BYTES) only grew too.Now
BY_ADDRESS_CARD_BYTESis the count:Shadow::by_address_card, read inDrop).The limit, the 97 % line and everything else stay as they were.
How much this matters in game today: little, and I say so plainly.
memory.rskeeps every arena for the whole run (pages are recycled inside them), so in one game session the bytes made and the bytes alive are the same, unless arenas are let go some day. This PR fixes the count so that what the limit says is true. I found it with the VRAM census below, which is the larger part of this PR.The census (
shadow::vram_census, two ignored device tests, plus the regression test). It makes each of the base's card-memory consumers through the base's own paths and readsQueryVideoMemoryInfo(local) around each one. The run below is on an RTX 4060 Laptop 8 GB (budget 7,188 MB) with theLowVramoverrides (CARD_WINDOWS_MB=512,CARD_BUFFERS_MB=512,CARD_BUFFERS_MIN_KB=64,CARD_RESERVE_BUDGETS=1,TEXTURE_ROOM_PERCENT=85,TEXTURE_MAX_SIZE=1024):card_ready; results are PC memory)register+find)CARD_BUFFERS_MB)findoutside buffers)CARD_WINDOWS_MB)by_address)pool::texture)HostHeap::new)The churn (
shadow::vram_census::churn): 24 cycles. Each cycle makes and lets go of 32 card copies, 32 windows, 4 arenas, 64 pool textures and 16 host lists of growing sizes.4 × 16, then 0 × 8; after,4 × 24.The census's other findings (the texture pool's made-ahead blocks, host lists that keep their largest indirect buffers, arenas that count against the window budget) are listed in the PR comment below. The pool one has its own PR (#550).
Linked issue: Refs VIctory #3505 (8 GB laptop VRAM creep on AnyXboxX main, 6,559 → 7,145 MiB in 6 min).
Verification
RTX 4060 Laptop 8 GB, Intel UHD (a78b);
third_party/victory,CARGO_TARGET_DIRoutside the tree.Oracle and test data
shadow::vram_census::arenas_give_their_card_room_backmakes and lets go of 72 arenas of 64 MiB, one after another (4,608 MB in all, past the 4,096 MB limit), and checks that each one lies where the first did. It fails without the fix (shown above).Checklist
E_NOTIMPL), never a fake success. (n/a)AI use: made with Claude Code (Claude Opus 5.5): code reading, the census and churn harness, the fix, the tests and this description. The device runs were made on my RTX 4060 Laptop.
🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-27T21:01:26Z.
VRAM census of the base under
LowVram: the full table. Code reading plus the harness in this PR. RTX 4060 Laptop 8 GB, budget 7,188 MB; "measured" meansQueryVideoMemoryInfolocal around the allocation.shadow::card_for)CARD_BUFFERS_MB), measured +512window_card_for)CARD_WINDOWS_MB), measured +512memory.rs+by_address)MEMORY_CARD_MB4,096 and 97 %; also counted in the window bytes (16 arenas → 1,536 MB counted against the 512 MB window cap)pool.rs)resource::room85 % of use less empty blocks, plus the reserves; floor min(2 GB, budget/4)vram_keep), 10 min belowHostHeap::new)indirect_scratchdoubles,batch_argsonly grows, both kept acrossreset(); idle pool up to 512 listsCARD_STEPS=2)WINDOWS_BAR_MB), tile heaps (LEVELS_ON_DEMAND)Churn, 24 cycles of card copies, windows, arenas, pool textures and host lists. What is in use, less empty texture blocks, was 12 → 12 MB: no creep in any of our own pools. The only thing that did not come back was the arena count (this PR).
So the creep YUYING234 saw on #3505 (6,559 → 7,145 MiB in 6 min) does not come from a leak in these paths. The consumers that grow with play are the title's own textures and targets (7, 13), and the arenas (5), if ray tracing is on. Two of the findings could be follow-ups if a timed 8 GB run points at them: