Heap pass: every buffer slot looked at once in N passes, a share at a time, not all in every Nth pass (VICTORY_HEAP_RESCAN_SPREAD=1, off by default) #1138

Open
github-bot wants to merge 2 commits from github-bot/gh-1138 into main AGit
Owner

@⁠exotiquee on GitHub · 2026-11-25 21:23 UTC · original
exotiquee:pr/heap-rescan-spread → main · +160 −11 · 3 files · 2 commits · open

Branch pr/heap-rescan-spread on main c36971b, two commits:

  1. VICTORY_HEAP_RESCAN_FRAMES (N, default 16 as before). This is a minimal prerequisite, after VItoriaBr 5a84eb4 (uiliannn), which uses 64 there. With the switch unset nothing changes. The heap-pass line names the interval.
  2. VICTORY_HEAP_RESCAN_SPREAD=1.

What it does

The pass over the heap's buffer views (State::heap_buffers) looks at the slots written since the last pass. Every 16th pass it looks at every buffer slot, because a view of a released resource goes stale without a write. We measured that full pass at 96.7 ms of one recording thread, every 16th frame.

Spread, pass p looks at:

  • the buffer slots with slot % N == p % N;
  • plus the slots written since;
  • and forgets what it found of that share before.

Each slot is still looked at again as often as before (once in N passes). Entries of slots that left the set still go within N passes. No frame takes the whole look.

Not spread, the old branch is kept as it was (pass_slots).

Switch

VICTORY_HEAP_RESCAN_SPREAD=1, off by default. VICTORY_HEAP_RESCAN_FRAMES=N (default 16) sets N for both modes.

How it was tested

cargo +1.98.1 test --locked -j 4 -p victory-gpu (WARP and RTX 5080 tests run automatically): 185 passed, 0 failed, 5 ignored. With --features diagnostics: 202 passed, 0 failed, 6 ignored (three clean runs of each).

New test draw::rescan_tests::every_buffer_slot_is_looked_at_once_in_n_passes, for N = 1, 16 and 64:

  • Not spread: every buffer slot once in N passes with everything found forgotten, and the written slots in between (as before).
  • Spread:
    • every buffer slot is looked at exactly once in any N passes in a row, plus the written slots;
    • nothing found before the first N passes is left, including entries of slots no longer in the set.

Known flaky tests (also on plain main):

  • indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields (a WARP race);
  • frame::tests::waits_end_on_ticks_and_count_frames (timing).

The first run after the rebase onto c36971b, while the machine was busy, also failed watch::tests::a_view_mapped_beside_a_guarded_one_makes_it_check_again, the frame test and inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset. None of them is in code this PR touches. The next three runs of both suites were clean.

What we measured (RTX 5080, Ryzen 7 9800X3D)

  • Before: the full look took 96.7 ms of one recording thread every 16th frame. Spread, each pass does 1/N of that look, by construction.
  • No isolated fps measurement. The switch was on in one combined run with other switches of ours: ~14.3 fps (13.3-15.3), against ~12.2 (10.4-13.6) with all of them off. The other switches were heap-pass and descriptor-lock fixes, two-phase slots, one-call feed, and per-list tables at Close. This PR's share of that difference is not known.

Risks

  • Small. The same slots are looked at as often as before, only spread over the passes. With the switch off nothing changes.
  • With the spread, a stale view of a released resource is still found within N passes, as before. Which pass finds it depends on its slot number.

🤖 Generated with Claude Code

**@⁠exotiquee** on GitHub · 2026-11-25 21:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/1138) `exotiquee:pr/heap-rescan-spread` → `main` · +160 −11 · 3 files · 2 commits · open Branch `pr/heap-rescan-spread` on `main` c36971b, two commits: 1. **`VICTORY_HEAP_RESCAN_FRAMES` (N, default 16 as before).** This is a minimal prerequisite, after VItoriaBr 5a84eb4 (uiliannn), which uses 64 there. With the switch unset nothing changes. The heap-pass line names the interval. 2. **`VICTORY_HEAP_RESCAN_SPREAD=1`.** ## What it does The pass over the heap's buffer views (`State::heap_buffers`) looks at the slots written since the last pass. Every 16th pass it looks at **every** buffer slot, because a view of a released resource goes stale without a write. We measured that full pass at **96.7 ms of one recording thread, every 16th frame**. Spread, pass `p` looks at: - the buffer slots with `slot % N == p % N`; - plus the slots written since; - and forgets what it found of that share before. Each slot is still looked at again as often as before (once in N passes). Entries of slots that left the set still go within N passes. No frame takes the whole look. Not spread, the old branch is kept as it was (`pass_slots`). ## Switch `VICTORY_HEAP_RESCAN_SPREAD=1`, **off by default**. `VICTORY_HEAP_RESCAN_FRAMES=N` (default 16) sets N for both modes. ## How it was tested `cargo +1.98.1 test --locked -j 4 -p victory-gpu` (WARP and RTX 5080 tests run automatically): **185 passed, 0 failed, 5 ignored**. With `--features diagnostics`: **202 passed, 0 failed, 6 ignored** (three clean runs of each). New test `draw::rescan_tests::every_buffer_slot_is_looked_at_once_in_n_passes`, for N = 1, 16 and 64: - Not spread: every buffer slot once in N passes with everything found forgotten, and the written slots in between (as before). - Spread: - every buffer slot is looked at exactly once in any N passes in a row, plus the written slots; - nothing found before the first N passes is left, including entries of slots no longer in the set. Known flaky tests (also on plain `main`): - `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields` (a WARP race); - `frame::tests::waits_end_on_ticks_and_count_frames` (timing). The first run after the rebase onto c36971b, while the machine was busy, also failed `watch::tests::a_view_mapped_beside_a_guarded_one_makes_it_check_again`, the frame test and `inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset`. None of them is in code this PR touches. The next three runs of both suites were clean. ## What we measured (RTX 5080, Ryzen 7 9800X3D) - **Before:** the full look took 96.7 ms of one recording thread every 16th frame. Spread, each pass does 1/N of that look, by construction. - **No isolated fps measurement.** The switch was on in one combined run with other switches of ours: ~14.3 fps (13.3-15.3), against ~12.2 (10.4-13.6) with all of them off. The other switches were heap-pass and descriptor-lock fixes, two-phase slots, one-call feed, and per-list tables at Close. This PR's share of that difference is not known. ## Risks - Small. The same slots are looked at as often as before, only spread over the passes. With the switch off nothing changes. - With the spread, a stale view of a released resource is still found within N passes, as before. Which pass finds it depends on its slot number. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
After VItoriaBr 5a84eb4 (uiliannn), which takes 64 by default; here it
stays at 16, so nothing changes unless the switch is set: a longer
interval leaves a slot whose resource went without a write, or one written
before its memory had a host copy, stale for longer. The heap pass line
names the interval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The full look at every buffer slot took 96.7 ms of one recording thread
every 16th frame (RTX 5080). Spread, pass p looks at the buffer slots with
slot % N == p % N and the slots written since, and forgets what it found
of that share before; each slot is looked at again as often as before
(N = VICTORY_HEAP_RESCAN_FRAMES, 16), and entries of slots that left the
set go within N passes as they did. Not spread: as before (pass_slots
keeps the old branch; a test checks both).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:14 +00:00
Author
Owner

@⁠Proudnoob4 on GitHub · 2026-11-25 22:16 UTC · original

AI-assisted testing (Gemini in OpenCode); measured locally on my own machine.

RTX 4080 / Windows 10 bundled test report (d76af4b)

Setup: Windows 10 Pro 22H2 (Agility SDK 1.620.2), i5-13600K, 32 GB RAM, RTX 4080 16 GB (driver 621.01), Series X profile, diagnostics release build (9c184b3 + #1138 + bundled perf PRs), VICTORY_HEAP_RESCAN_SPREAD=1 (default VICTORY_HEAP_RESCAN_FRAMES=16).

  • Merged cleanly onto 9c184b3 with zero conflicts.
  • Confirmed active in logs across 4 full world runs (every buffer slot every 16 passes, VICTORY_HEAP_RESCAN_FRAMES, a share in each pass (VICTORY_HEAP_RESCAN_SPREAD=1)), scanning ~20.5k–22.4k buffer slots/frame cleanly with 0 crashes, 0 device removals, and crisp world frames (frame-4096.png).
  • Latest bundled run (fxnext_turbo, 330 s, 27 world lines): 8.50 fps median, 9.20 p90, 9.30 max, usual frame 113 ms, pass over textures 0.3 ms. (Isolated on/off A/B of #1138 alone is unmeasured in this run.)
**@⁠Proudnoob4** on GitHub · 2026-11-25 22:16 UTC · [original](https://github.com/fxceless/victory-fork/pull/1138#issuecomment-7176158988) *AI-assisted testing (Gemini in OpenCode); measured locally on my own machine.* ### RTX 4080 / Windows 10 bundled test report (`d76af4b`) **Setup:** Windows 10 Pro 22H2 (Agility SDK 1.620.2), i5-13600K, 32 GB RAM, RTX 4080 16 GB (driver 621.01), Series X profile, diagnostics release build (`9c184b3` + `#1138` + bundled perf PRs), `VICTORY_HEAP_RESCAN_SPREAD=1` (default `VICTORY_HEAP_RESCAN_FRAMES=16`). - Merged cleanly onto `9c184b3` with zero conflicts. - Confirmed active in logs across 4 full world runs (`every buffer slot every 16 passes, VICTORY_HEAP_RESCAN_FRAMES, a share in each pass (VICTORY_HEAP_RESCAN_SPREAD=1)`), scanning ~20.5k–22.4k buffer slots/frame cleanly with `0` crashes, `0` device removals, and crisp world frames (`frame-4096.png`). - Latest bundled run (`fxnext_turbo`, 330 s, 27 world lines): **8.50 fps median, 9.20 p90, 9.30 max**, `usual frame 113 ms`, `pass over textures 0.3 ms`. *(Isolated on/off A/B of `#1138` alone is unmeasured in this run.)*
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
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.
git fetch -u origin '+refs/pull/1138/head:github-bot/gh-1138'
git switch 'github-bot/gh-1138'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1138'
git switch 'github-bot/gh-1138'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1138'
git switch 'github-bot/gh-1138'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1138'
git switch 'main'
git merge --squash 'github-bot/gh-1138'
git switch 'main'
git merge --ff-only 'github-bot/gh-1138'
git switch 'main'
git merge 'github-bot/gh-1138'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.