gpu: a heap buffer view one pool run holds follows the title's pages too (stale entries, #79) #517

Manually merged
github merged 1 commit from github-bot/gh-513 into main 2026-11-28 00:23:22 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-27 23:18 UTC · original
Olima34:fix/pool-views-follow-pages → main · +113 −12 · 4 files · 1 commits · merged 2026-11-28 00:22 UTC

Refs #79, #258. Follow-up to #267 and #319.

Bug. A heap entry for a buffer view that one pool run holds points at the pool pages the title had there when the entry was written.

  • The title frees memory, takes it again at the same addresses with other pool pages, and writes the same record (a placed view is its address and description).
  • remirror_tables skipped the entry, because its record bytes hadn't changed, and mirror had dropped it from title_views.
  • So shaders read whatever the old pages held, and wrote into them: pages that belong to something else by then.

Fix. Such a view stays in title_views with the signature of the mappings under it, and follow_title_pages mirrors it again when they change. That's the same path as the wrapped views of #267.

Measured in 300 s world runs, Series S, on preview + #463:

  • Moved views: 2,048 such views moved in one run.

  • Stale bound entries: a check at each draw and dispatch found a bound entry pointing away from its view's memory more than 1,000 times without the fix, and 3 and 0 times with it.

  • Garbage indirect records past the gates' limits:

    Runs Records past the limits, per run
    3 runs with the fix 0, 0, 0
    7 runs without 0, 1, 9, 33, 26, 3, 43

    The [3, 864026624, …] draw records weren't seen in the three runs with the fix (they appeared in 4 of 8 before), but that cause isn't proven.

Cost: 572,863 views followed after 300 s, an average of 4.7 ms per look over 1,000 looks, so 1.6% of the run. Frames in 300 s: 2,331 and 2,441 with the fix, against 2,304–2,368 without. This is marked shortcut:, with the upgrade: walk only the views over ranges the pool table changed.

Test. a_view_one_pool_run_holds_follows_title_pages_remapped_under_it reads through the moved view, then stores through it. Before the fix the store went to the old pool page, and the test fails without the change. copies_of_a_wrapped_view_are_followed_with_one_walk now expects 2 walks rather than 1, on purpose: the output view is followed too, and it's still one walk per range.

Checks: victory-hle, victory, victory-gpu (413) and xtask tests pass (arm64). Windows clippy is clean with -D warnings, cargo xtask policy passes, and docs/native-host.md is updated.

Not covered:

  • an unordered view of 793,296 bytes whose own address changed under the same record (3 times in one run);
  • why the 16-bit typed stores of compute 238b1c799e1ee23c sometimes take the float path (0x33800000 is the half float of 1).

@⁠LakshanSivakumar, this is ours, so it needs your approval.

**@⁠Olima34** on GitHub · 2026-11-27 23:18 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/513) `Olima34:fix/pool-views-follow-pages` → `main` · +113 −12 · 4 files · 1 commits · merged 2026-11-28 00:22 UTC Refs #79, #258. Follow-up to #267 and #319. **Bug.** A heap entry for a buffer view that one pool run holds points at the pool pages the title had there when the entry was written. - The title frees memory, takes it again at the same addresses with other pool pages, and writes the same record (a placed view is its address and description). - `remirror_tables` skipped the entry, because its record bytes hadn't changed, and `mirror` had dropped it from `title_views`. - So shaders read whatever the old pages held, and wrote into them: pages that belong to something else by then. **Fix.** Such a view stays in `title_views` with the signature of the mappings under it, and `follow_title_pages` mirrors it again when they change. That's the same path as the wrapped views of #267. **Measured** in 300 s world runs, Series S, on preview + #463: - **Moved views:** 2,048 such views moved in one run. - **Stale bound entries:** a check at each draw and dispatch found a bound entry pointing away from its view's memory more than 1,000 times without the fix, and 3 and 0 times with it. - **Garbage indirect records past the gates' limits:** | Runs | Records past the limits, per run | |---|---| | 3 runs with the fix | 0, 0, 0 | | 7 runs without | 0, 1, 9, 33, 26, 3, 43 | The [3, 864026624, …] draw records weren't seen in the three runs with the fix (they appeared in 4 of 8 before), but that cause isn't proven. **Cost:** 572,863 views followed after 300 s, an average of 4.7 ms per look over 1,000 looks, so 1.6% of the run. Frames in 300 s: 2,331 and 2,441 with the fix, against 2,304–2,368 without. This is marked `shortcut:`, with the upgrade: walk only the views over ranges the pool table changed. **Test.** `a_view_one_pool_run_holds_follows_title_pages_remapped_under_it` reads through the moved view, then stores through it. Before the fix the store went to the old pool page, and the test fails without the change. `copies_of_a_wrapped_view_are_followed_with_one_walk` now expects 2 walks rather than 1, on purpose: the output view is followed too, and it's still one walk per range. **Checks:** victory-hle, victory, victory-gpu (413) and xtask tests pass (arm64). Windows clippy is clean with `-D warnings`, `cargo xtask policy` passes, and `docs/native-host.md` is updated. **Not covered:** - an unordered view of 793,296 bytes whose own address changed under the same record (3 times in one run); - why the 16-bit typed stores of compute `238b1c799e1ee23c` sometimes take the float path (0x33800000 is the half float of 1). @⁠LakshanSivakumar, this is ours, so it needs your approval.
Its heap entry points into the pool's buffer at the pages the title had under
the view when the entry was written. The title frees memory and takes it again
at the same addresses with other pool pages, and writes the same record for its
view, so remirror_tables left the entry alone and mirror had dropped it from
title_views: shaders read whatever the old pages held by then and wrote into
it. Such a view is now followed as a wrapped one is (follow_title_pages).

Measured in 300 s world runs (Series S profile): 2,048 such views moved in one
run; indirect records past the limits 0 in three runs with the fix, 0 to 43 a
run in seven without. Cost: 4.7 ms a look on average, 1.6 % of the run.

Test: a_view_one_pool_run_holds_follows_title_pages_remapped_under_it, which
fails without the change. copies_of_a_wrapped_view_are_followed_with_one_walk
now counts the output view's walk too (one a range, as before).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 23:19:08 +00:00
github manually merged commit 6c24066f6f into main 2026-11-28 00:23:22 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-28 00:22 UTC · original · approved these changes

**@⁠LakshanSivakumar** on GitHub · 2026-11-28 00:22 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/513#pullrequestreview-6094575693) · **approved these changes**
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 00:37 UTC · original

A correction to this PR's description and docs: the "no record past the limits in three runs with the fix" result held for headless runs only. A windowed run of the same build still had 15 records past the limits, so following the pool-held views does not stop the garbage indirect records. Their source is still open. The stale-entry fix itself and its test stand. #529 corrects the sentence in docs/native-host.md.

**@⁠Olima34** on GitHub · 2026-11-28 00:37 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/513#issuecomment-7231056346) A correction to this PR's description and docs: the "no record past the limits in three runs with the fix" result held for headless runs only. A windowed run of the same build still had 15 records past the limits, so following the pool-held views does not stop the garbage indirect records. Their source is still open. The stale-entry fix itself and its test stand. #529 corrects the sentence in `docs/native-host.md`.
This discussion has been locked. Commenting is limited to contributors.
No description provided.