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

Merged
Olima34 merged 1 commit from upstream-pr/513 into main 2026-11-28 00:22:12 +00:00
Olima34 commented 2026-11-27 23:18:02 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T23:18:02Z.


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 + #459:

  • 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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5534340648 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/513). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-27T23:18:02Z. --- 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 + #459: - **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 commented 2026-11-28 00:37:14 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:37:14Z.


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. #525 corrects the sentence in docs/native-host.md.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231056346 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/513#issuecomment-7231056346). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T00:37:14Z. --- 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. #525 corrects the sentence in `docs/native-host.md`.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS!513
No description provided.