Title memory by address: give back the numbers of copies named longest ago (VICTORY_MEMORY_RECLAIM) #1082
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/fxceless--victory-fork!1082
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1082"
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?
@SpaghettiMaster545 on GitHub · 2026-11-25 18:45 UTC · original
SpaghettiMaster545:pr/memory-reclaim→main· +248 −26 · 1 files · 1 commits · openWhat was wrong
Title memory reached by raw address (
memory.rs) gives each copy a number in the directory, and a number is never given back. There are 1023 of them (COPIES). With the structure builder on (VICTORY_BVH_BUILDER=1) they run out within seconds of its start, mostly on 4 MiB windows of real card memory: in one of our runs, 1010 windows and 13 buffers, 4,300 MiB. From then on every page that has no number yet reads zeros and its stores are dropped, for the rest of the run ("no number left for another copy").More numbers only put it off. With finer windows and 8191 numbers the count kept growing the whole time: 4096 numbers 50 s after the builder started, all 8191 at three minutes (8146 windows, 2,671 MiB).
How it shows
With the builder on, the walks over the structures read zeros wherever their pages came after the last number. Builder off (the default), a run rarely gets near the limit.
What the change does
Numbers are given back.
VICTORY_MEMORY_RECLAIM=0keeps every number for the run, as before.Limitation: a copy reached only through pointers read out of memory looks old to the host while it is still read. It can lose its number, and its pages then read zeros for a frame until they are numbered again.
The pure parts, choosing the oldest copies and deciding when a number's quarantine is over, have a unit test:
numbers_named_longest_ago_go_back_and_wait_out_a_quarantine.How it was tested
maind510ee4):cargo test --locked -p victory-gpu --lib memorypasses (15, the new test among them).cargo clippy -p victory-gpu --all-targets -- -D warningsreports nothing inmemory.rs; it stops on lintsmainalready has elsewhere invictory-gpu.@drchef420 on GitHub · 2026-11-26 05:06 UTC · original
AI-assisted (Claude Code). Numbers and log lines only, no game data.
Two data points: without #994, 8191 numbers ran a 32 GB PC out of memory; with #994, main's 1023 held for six minutes.
RTX 5070 12 GB, 32 GB RAM (fixed 32 GB paging file), Windows 11 26300. Fork
maina183ea2,COPIESraised from 1023 to 8191, builder on with a quarantine (no copy-backs of builder copies), no reclaim.no shared buffer/no upload bufferwith0x8007000E, the title's own crash reporter recording 99% memory load and 442 MB of 69.5 GB commit free, then a crash.And with #994 the numbers hold without this. On the same machine,
main988aa41+ #994 (7af465b),COPIESat main's 1023, no reclaim, no quarantine: 6 min 17 s with the builder on andno number left for another copynever logged; shared video memory levelled at about 10.2 GB. So most of the exhaustion we and others saw came with the overrun #994 fixes (2.2 GiB of empty nodes past its levels). The reclaim may still matter for longer runs or other scenes; we did not run it.@drchef420 on GitHub · 2026-11-26 06:10 UTC · original
AI-assisted (Claude Code). Numbers and log lines only, no game data.
Correction: the "with #994" run in my comment above used #994's
COPIES = 2047, notmain's 1023.And 2047 isn't enough for a long session. Same build, 58 minutes from a save:
no number left for another copy ... COPIES=2047at 22 min 47 s after the builder came up. Shared memory had levelled at about 12 GB by then, so on a 32 GB PC numbers, not memory, are what run out first. That's the case for giving numbers back. Rendering went wrong for the player later in the run; we can't tie it to the zero pages from the log alone.@drchef420 on GitHub · 2026-11-26 07:56 UTC · original
AI-assisted (Claude Code). Numbers and log lines only, no game data.
Run with this PR on top of #994: copy numbers given back 20 times over 80 minutes with the builder on, live copies held at about 1,800 of 2047, shared memory flat, no crash.
Tree. Fork
main988aa41+ #994 (7af465b) + this PR (b26d793). The only conflict ismemory.rs. I kept #994's per-dispatch tracking:mapreturns the copy; only named copies and list upload memory are brought up to date;VICTORY_MEMORY_ALL. On top of that I kept this PR's numbering:Copy,number,reclaim,retire, andusedupdated on every directory hit. One point needed care. #994 brings new copies bynumbered..copies.len(), and with reuse that range misses numbers taken again. I used this PR'sm.freshinstead, and a fresh copy is brought whatever its per-list keys say, since its number may have held another copy earlier in the same list.COPIESstays at #994's 2047.cargo test -p victory-shader272 passed;cargo test -p victory-gpu -- --test-threads=1208 passed (this PR's test included).Run. Same machine as before (RTX 5070 12 GB, 32 GB RAM, Windows 11 26300).
VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1, no quarantine, a new game with no save. 87 min 31 s in all; the builder came up at 7 min 56 s.given=255 oldest=13500 newest=14039. Then 19 more, eachgiven=255, every 1 to 20 minutes depending on where the player went.made=4096 live=1801 of=2047at +51 min.no number left for another copylogged once, in the frame of the first give-back (the given-back numbers were still in their 8-frame quarantine). It is logged only the first time, so we can't tell how often a dispatch found none during later quarantines. A per-frame count would show it.0x8007000E, no device removal, noERRORlines. When the window was closed the title ended withtitle did not finish suspending in time; ending the title.no free dynamic descriptor slots: a table is not made n=27once, at +50 min (logged once).For comparison, without this PR (same tree minus
b26d793, from a save, 58 minutes): numbers ran out 22 min 47 s after the builder came up, and stayed out. Shared memory levelled at about 12 GB as well, so here giving numbers back costs no memory.Not fixed by this, as far as we can tell: a boat's engine is destroyed as soon as the player takes it, in both runs, and some character surfaces render black in later scenes. Both happen with and without this PR. We'll try the same place with the builder off to see whether the builder is involved at all.
View 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.