GPU: heap buffer pass looks only at marked slots; time split in the fps line #467
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!467
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-467"
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?
@LeonardoS11 on GitHub · 2026-11-25 01:17 UTC · original
LeonardoS11:perf/heap-pass→main· +534 −32 · 5 files · 2 commits · openDraft until the still-scene A/B and the whole test suite on a GPU are done (see Not tested).
Problem
The heap buffer pass (
heap_buffersindraw.rs, once a frame, inside a list call of a recording thread) serves shaders that pick a buffer by its index in the descriptor heap. Every 16 passes it looked at every view in the heap again (about 81,000 in the title's world, each with amirror, a lock and ashadow::find), and on every pass it rebuilt the spans of the roughly 4,100 host copies from all the views. Its time was reported as one number that also contains the textures picked by index, so it could not be told what the buffer part cost.What is in it
One commit on
main(c96b4f2), five files:crates/victory-gpu/src/heap_pass.rs(new, no D3D12, unit tested): which slots a pass has to look at. A slot is looked at again only whenchangedset, as before),descriptor::forgetnow notes the entries;take_forgotten),A copy's span is recomputed only when one of its slots leaves it.
draw.rs,descriptor.rs,host.rs,lib.rs: the pass uses it; the fps line splits the pass:heap buffers N passes X ms (marked|full: S slots looked at A ms, C copies refreshed B ms, textures T ms).VICTORY_HEAP_PASS_FULL=1keeps the old pass, for comparison.Tested
diagprofile withdiagnostics, rebased ontomainc96b4f2(head37272ae).cargo build --profile diag -p victory --features diagnostics: no warnings.cargo test -p victory-gpu heap_pass: 4 passed, 0 failed —only_slots_changed_since_the_last_pass_are_looked_at_again(an API write, a copy made outside the API and a freed entry are each looked at again; unchanged slots are not),a_slot_that_went_shrinks_its_copy_span,orphans_are_tried_again_every_16_passes_and_all_slots_now_and_then,the_old_pass_looks_at_all_every_16_passes.Result
No measurable change in frame time so far. In the same runs the pass took 105–456 ms a frame, of it 88–338 ms the textures picked by index (
heap_textures, 1,700–4,000 slots waiting each pass), which this PR does not touch, and 14–218 ms the slots. The runs before and after did not go through the same scene, so no frame-time number is claimed. What the PR gives today is the buffer part bounded by what changed, and the split that shows the texture part is the one to look at next.Not tested
VICTORY_HEAP_PASS_FULL=1on a still scene (a checkpoint for that exists now; to be added here).cargo test --workspace); before the rebase it passed with the stack named above.AI use
Claude Code: Claude Opus 5.5 wrote the change and its tests; Claude Fable 5.2 rebased it, ran the measurements and wrote this description. Run in the title by the author on the hardware above.
@ryotdev on GitHub · 2026-11-25 12:49 UTC · original
A dormant descriptor heap can accumulate freed indices indefinitely in
Picked::note_forgotten. The broadcast indraw.rsreaches every cached heap, but only the heap passed toplandrains its list. The global limit on a single broadcast leaves the per-heap total unbounded.I reproduced this on
37272aeawith two initialized heaps. I sent both heaps 2,048 batches of 1,024 indices and calledplanonly on the active one. The active heap ended with zero pending indices. The dormant heap retained 2,097,152 entries (8 MiB of elements), even though I used the same index throughout.A per-heap cap that switches to the existing full-rescan state on overflow fixed the regression locally. The next bind enumerated all slots, and the four existing tests still passed. This was an AI-assisted synthetic Rust test using the PR's heap_pass.rs; it needs no game files or GPU.
@LeonardoS11 on GitHub · 2026-11-25 13:59 UTC · original
@ryotdev thank you — that is a real leak, and it is fixed in
dfb8ee3, now on this branch:note_forgottenkeeps an entry only if some slot of that heap named it the last time the heap was looked at (by_entry); an entry nothing named changes nothing and is not kept. Your two-heap case (2,097,152 entries nothing named, sent to a heap that is never planned) now keeps 0.FORGOTTEN_MOST). Past that the list is dropped and that heap's next pass looks at all of its slots, which is always correct.a_dormant_heap_keeps_few_forgotten_entries_and_falls_back_to_all: the 2,097,152 case, one named entry (the pass looks at that slot only), and 65,537 repeats (list dropped, full pass).The branch is also rebased onto
0b0074e(two commits: the pass, then this fix); the only conflict was the counters of the frame line, where I keptmain's and this PR's.cargo test --workspace --no-fail-faston an RTX 3080 Ti: 570 passed, 12 ignored, 1 failed —warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which fails the same way on plain0b0074e(#847, #849).Where the PR stands on speed, so nobody takes it for more than it is yet: on our branches over current
main(f85101banda253706with other PRs) the buffer part of the heap pass is 38–75 ms a frame here in the first room (15,000 slots looked at), and withVICTORY_TABLED_SKIP_FRAMES=2(#827) it is 85–155 ms over 37,000–78,000 slots, marked or full alike — the marks are inflated by the per-draw tables being mirrored again every frame, so this pass alone does not pay there. I am measuring the fix for that part and will post numbers with it; until then this stays a draft in spirit.(Fix and rebase with Claude Code; tests run by me on the hardware above.)
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.