native: release placed texture copies whose title memory another placement takes #400
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!400
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-396"
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?
@Ketan-Kapse on GitHub · 2026-11-27 16:27 UTC · original
Ketan-Kapse:pr/placed-overlap→main· +749 −10 · 7 files · 1 commits · closed without mergingRefs #383, #79
What this changes
Host copies of placed title textures were never released when the title reused their memory at another start address or size.
Title::texture_placedreleased the previous placement only at the SAME address ("guess: the title is done with it once it places another there"), andrelease_placedonly when the whole pool went. The old detiled copy stayed tracked, kept being hashed by the scanner, was uploaded again when its now foreign bytes changed, and stayed resident through the heap entries that still showed it.This PR, on the native host only:
VICTORY_PLACED_OVERLAP=0turns it off). On placement, every other placed texture whose title range intersects the new one is released the way the same-address case is. The object that owns the placement and aliases of that owner are kept. A sorted range index makes the lookup O(log n + hits).release_resource) keeps its meaning.VICTORY_TRACE_TEXTURE_MEMORY=1: every 64 presented frames onetexture memory:line with tracked copies by kind (placed / object / targets), placed bytes against the union of their title ranges, what the rule released, ping-pong count, pending.It is a guess about title behaviour (intersecting placements mean reused bytes) and is marked as one in the code and in
docs/native-host.md.Measured
Apple M4 Pro, 24 GB, macOS 27.0.1,
--console series-s, windowed,VICTORY_METAL_RESIDENCY_SETS=1. Counts only.Main
728845d1plus this branch, same binary, the rule off and on:VICTORY_PLACED_OVERLAP=0)On our fork (older base, more local changes), the same rule took the world from about 0.8 to 1.6 fps over a 10-minute run with no GPU errors: 75,334 textures (19.3 GB) released, kernel time of the command buffers per frame 1,908 ms to 720 ms.
Not verified, please read
kIOGPUCommandBufferCallbackErrorTimeout, and 30 s later the title took an unhandled access violation (0xc0000005, a null read) and the host aborted. The rule-off run did not time out, but it only lived 5 minutes before swap ran out, so it never reached that point. I cannot say whether the rule contributes to the timeout or whether it is the world-load timeout others report in #79. One run each.How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: passes exceptnative_list_imports::list_imports_binds_the_probe_and_does_not_run_it, which cannot build its Windows probe on this Mac (cross tools not installed). Not touched by this change.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: clean.list::tests::unordered_access_clears_have_the_same_slots_in_both_layouts, which fails the same way on main728845d1here. victory-metal: 37, 12 and 16 passed.native::host::tests::displaced_texture_records_retry_when_the_table_is_checked(entries cleared, the unchanged record retried, shown again once the key is registered again, final release unchanged).cargo xtask policypasses.Checklist
VICTORY_*variable and documented🤖 Generated with Claude Code
@Ketan-Kapse on GitHub · 2026-11-27 16:31 UTC · original
Closing: main already covers this. I cut the branch from
728845d1and missed that55219dfa("one host texture per range of title memory") and740bbb2d(the byte budget) had landed. They release a placed copy another placement covers, with a safer rule than this PR's (given up only once no heap entry, list or submission in flight uses it; this PR released at once).The numbers in the description may still be useful as data for #79 and #359: on
728845d1, 24 GB M4 Pro, Series S, placed copies were 11.12 GB over a 6.52 GB union of title ranges at frame 1920 (4.60 GB counted more than once), against 6.27 GB with overlap release. I will measure current main the same way and report on #383.Pull request closed