gpu: reclaim empty Paged pages (ring-heap malloc growth) (#639) #644
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!644
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-640"
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?
@jamal-fv on GitHub · 2026-11-28 21:05 UTC · original
jamal-fv:vibe/console-budget-footprint-639→main· +58583 −5923 · 342 files · 160 commits · draftSummary
Pagedpages (ring-heap MALLOC growth) — prior commit.Stitch(mach_vm_remapper 64 KiB piece → one untagged VM region each). Preferwrap_title_memorywhen the title VA is already mapped (pieces=0); keep Stitch for unmapped VAs and gaps.VICTORY_TRACE_MEMORYbuffer lines report stitch piece counts vs title wraps.reports/world-vm-growth.md.Test plan
cargo test -p victory-gpu --lib mapped_gaplesscargo test -p victory-gpu --lib mirror_tests(47 passed)cargo test -p victory-metal stitch_of_n_pages_makes_about_n_vm_regionsfootprintbefore/after — blocked: headless tip dies at0xc000001dimage+0x55ff714 (~75 s, frame 0), same RVA as pre-fix attempt; never reaches world /TRACE_MEMORYspan lines.How it was tested
run-native.sh --headless --seconds 420withVICTORY_METAL_TEXTURE_BUDGET_MB=4348VICTORY_TEXTURE_DROP_TOP_MIP=1VICTORY_TRACE_MEMORY=5undergame.lock— abort before world.d48bb1b): sound through CoreAudio, live keys, dropped-work warnings 5999490a503d4ca18): late-DLL static TLS, remirror window, Rosetta test pools 7da7f7f2df- Resource heaps reach HEAP_VIEWS entries (when the title's entries and the contract's fit) with null views at its last two, and carry a view-stride table (a dword per entry: element size, integer-format bits; 0 for no buffer view), kept by `mirror` and bound as root SRV VIEW_STRIDES. Shaders taking buffer views at computed heap indices read it; without it their commands were left out ("root parameter 255 was never set", 40 a run) and the title's watchdog ended it 30 s later. - Translator: the thread-group info SGPR (TG_SIZE: wave count, wave index over console waves), s_sext_i32_i8/i16. - VICTORY_DUMP_THREADS=0 also dumps every thread at a write to address 0 (the title's watchdog crashes that way). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mkbda640d): permlane16/x16 upstream, computed-buffer subword loads, texture formats, hot-texture probing bound 75a69eb411Surface::read_last read the presented texture with 4-byte rows whatever its format. Once the scene presents a half-float (RGBA16Float) texture, Metal wrote twice the buffer, over the host heap where the title's own objects live: their pointers became half-float texels (+-inf, the cleared HDR target), and the title crashed a second or two after the scene's start ("AGX: Texture read/write assertion failed: bytes_per_row >= used_bytes_per_row" just before; n12, n13, n20, likely n18). Only runs that read frames (VICTORY_SHOTS) were hit. Rows are now the texel's size, and wider texels are clamped to 8 bits for the caller; unknown formats none. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mkaf380ca): pool ranges across mappings, drop one command, fault dumps, stencil clears, BGRA sRGB da95423786af380ca) into the arm64 run 89495059f8escapeslists direct targets a linear sweep of each function finds outside every function 93dc8497c7Function discovery walks from each start and takes an in-range forward jmp as internal, stopping at `jmp reg`; so a thunk's target (a1: rva 0x9f6400) and a switch case that tail-calls (a2: rva 0x5b4c9f0, the case reached through a jump table in .rdata) were left out, and the lifted image aborted there ("rt: no fallback installed"). `discover::sweep` decodes each final extent linearly and keeps its direct call / jcc / jmp targets and executable `lea rip` targets; `escaping_targets` returns those that land in no function (to feed back as seeds) and those that land in the middle of one (reported only). `victory-recomp escapes <pe> [seeds]` prints the first to stdout, the second to stderr. On game_scarlett_master: 481 seeds, 61 targets into the middle of .pdata functions. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mk- ds_bpermute_b32 in a wave of 64 permutes lanes 0..31 and 32..63 apart (RDNA 2 ISA 10.4.4): the lane read is the address modulo 32 in the reading lane's own half. It was lowered as a read across the whole console wave plus a 64-lane ballot, both exchange sites on a 32-lane host, so in divergent code it was refused ("cross-lane operation between host waves in divergent code", 34 programs in n28 with the others of that reason), and where the address wrapped past 31 it read the other half. It is now the host wave's own read and ballot. After VIctory-macOS 0665a0e8 (QB) and ka1qux f9a5034 (its test checked all 64 lanes against RDNA 2 hardware). Tests: the permute lowers with no barrier and no exchange, also under an EXEC branch. - An immediate sampler used with a comparison sample clears the reduction bits (0x180) before setting the comparison one (0x80): a minimum sampler (0x100) became a maximum one (0x180). After ka1qux 93b9b2f, port of Marvisak/VIctory #2983 (RVZO6). - SDWA destination WORD_0 with dst_unused 1 (sext) copies bit 15 upward: a 16-bit -1 came out as 0x0000ffff. After fxceless 58de9bf (upstream VIctory #3124). - BC7: the 2-bit rotation field exists in modes 4 and 5 only; in the other modes those bits are other fields, and reading them swapped a channel with alpha (wrong colours, a shift past the width in modes 0, 1, 3). After ka1qux 765d9fa (upstream VIctory pull request #3111). Test. The shader translator changed: its cache keys move with the build. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mka3 trapped 25 s in ("jump table index out of range", f_53bf950): the table at rva 0x67694f4 has 8 cases, and the size came from `cmp r8d, 7` / `jae`, after which the index is `add r8d, 2` and a branch target joins. The size was taken from the last compare-and-ja within 40 instructions on any register a move connected to the index, whatever happened in between. Now `index_bound` reads forward to the table load with value numbers: a plain copy (`mov eax, r13d`, `movzx r10d, dl`, `movsxd rax, ecx`, `mov r8d, r8d`, `cdqe`) passes a value on, any other write (and a call, for the registers the Windows x64 convention gives the callee) makes a new one, a compare followed by ja/jae bounds the value it tests (the least of its checks), and a branch target forgets everything before it. The load's index is bounded by its value's check, or, for MSVC's two-level switch (`movzx eax, byte [base+idx+bytes]`, then `mov ecx, [base+4*rax+table]`), by the largest of the byte table's checked entries plus one. A table also ends where the function's next table starts (tables sit side by side in .rdata, MSVC's byte table right after its offsets); up to there an entry in other code is a tail-call case, as with a check. Over the exe's 3434 tables (`victory-recomp tablelist <pe> [seeds]` prints them, to compare builds): 208 change. 167 unchecked tables no longer run on into the next table's entries (21 -> 5 cases and the like); 10 MSVC switches go from 3-56 cases to their 2-47 real ones (the rest were bytes of the byte table read as offsets, one as rva 0x10100); 28 checks of another or a changed value no longer bound (2 of them had read one entry of the next table; f_53bf950's two tables go from 7 to 8 cases); 3 tables are newly bounded by the check of a copy made ahead of it (as at 0x22e39e3, where the looser outer check would give 41 cases running into other functions). Tests for each case. Functions entered in the middle: a direct jump, call or executable `lea rip` from one lifted function into the middle of another one (not its own chained parts) went to the dispatcher, which has no function there. Each such address that is an instruction of a function without landing pads is now an entry of its own, `f_<rva>`: the same body after the prologue, `goto` its label (`FuncIn::entries`, `inner_entries`); one that is no instruction start gets a function that traps, so the table always links. The exe has one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mkpauseis a compiler barrier 51035a88cca4 got past a3's trap, showed the intro (the first frame drawn by the arm64 build), presented black frames from then on and read nothing more from disk: title-main sat in 762 of 762 samples on one instruction of f_9dcac0, `b .`. The guest code there (rva 0x9dd0d7): lock inc dword ptr [rax] ; one more job handed out spin: mov eax, dword ptr [rsp + 0x48] ; the counter the workers raise cmp eax, 8 jne spin The counter lives on the waiter's stack and the workers write it through the address it handed them. Stack accesses are lifted as thread-local (plain), so clang took the read as loop-invariant, the loop as endless, and emitted a branch to itself. `spin_reads`: in a polling loop (a backward branch over at most 16 instructions that only load, compare, test and branch: no call, no store, no register arithmetic, so nothing of its own changes between turns) the reads of fixed stack slots are emitted as shared accesses (acquire under RT_TSO), which clang must repeat and which order what follows the exit. In the exe: 50 such reads in 27 units. And `pause`, a spin-wait hint, is lifted as ARM's `yield` with a memory clobber, so a waiting loop with it reads memory again on every turn whatever it reads (182 units have one). Tests: the spin above, a loop that writes its slot, one that calls, a search loop that counts, `pause`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mk3fd73fd) into the arm64 run: shader opcodes, SCC, sample/gather variants, root signatures, UCRT fixes 9fad133bd7jmp [r12 + 8*rbx]) 2b981d95c73fd73fd) by way of merge-main-1905: shader opcodes, SCC, sample/gather variants, root signatures, UCRT fixes 593bd829b2a6 trapped ("jump table index out of range", f_1ffa540): the function's switch is `movsxd rax, [r8 + 4*rax]` / `add rax, r8` / `jmp rax`, and one of its cases is a virtual call in tail position, `mov rax, [rcx]` / `mov rax, [rax + 0x78]` / `jmp rax`. The table finder took any `jmp reg` with a scaled load and an add of the base into the jump's register within 40 instructions before it for a switch, so the virtual call got the switch's five cases, and its real target trapped. `feeds_jump`: the load writes the offset, an `add off, base` (the jump takes off) or `add base, off` (the jump takes the base) follows, and on the way from the load to the jump nothing else writes the offset and the base (before the add) or the target (after it), no unconditional jump, indirect jump, return or interrupt breaks the flow, and no branch target (the jump included) joins another path. In the exe this takes the table from eight jumps, all virtual calls in tail position behind a switch (0x11e405d, 0x11e4096, 0x11e40ae, 0x11e40d4 behind the one at 0x11e4047, 0x1ffa572, 0x4c497d, 0x2e800c9, 0x43833c1), which now go to the dispatcher; no real switch loses its table. Test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mka7 aborted in bink2scarlett.dll: `rt: unresolved guest target ... rva 0x1751f`, a case of the switch at 0x1751d that the last change had taken the table from. Bink (MSVC) loads the offset over its base register and sets the base again in another one for the add: movzx ecx, byte ptr [rdx + rcx + 0x17a74] mov edx, dword ptr [rdx + 4*rcx + 0x17a5c] ; offset over the base lea rcx, [rip - 0x1751a] ; __ImageBase again add rdx, rcx jmp rdx `feeds_jump` now keeps the registers that hold the base: the load's base register (unless the load overwrites it) and any one an `lea` of the same address sets on the way; a write to one takes it out. The add must take one of them. Over the 17 images, against the table recovery before `feeds_jump`, only the eight virtual calls in tail position in the exe lose their tables; Bink's switch is back (6 cases). Test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BotUDcRjHo3zJ1HWdpX4mkc5fd140d+ lift). 397dca5a6cView 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.