GPU in place: the heap is held until the submissions that could read through it have finished #943

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

@⁠HailLucifer666 on GitHub · 2026-11-25 13:24 UTC · original
HailLucifer666:perf/inplace-fence-retirer → main · +64 −1 · 2 files · 2 commits · open

Problem

A heap opened from the title's own memory locks those pages. While it stands, the title's VirtualFree, VirtualProtect or release of them answers ERROR_INVALID_PARAMETER (87) — the module's own header says so, and the probe shows it.

When a placed buffer's shadow went, Shadow::drop let the heap go in the same breath as the buffer, without asking whether a queue had run the work that used it. A title that decommitted those pages in the next moment failed a call that should have worked.

This is not hypothetical: inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset asserts that decommit and passes and fails on the same commit (3 of 6 full runs on f85101b6).

What actually fixes it

host::retire already exists (host.rs:209) — "Drops object once every submission running now has finished: at once if none is." No new retirement queue is needed; this branch adds none.

Shadow::placed keeps only the heap (place = Some((heap, bias))); the buffer that stands in it is a field of the shadow, so Rust's drop glue runs the buffer after Drop::drop returns. Retiring the heap inside that body therefore yields buffer-then-heap for free, which is the COM ordering rule: a placed resource must not outlive the heap it stands in.

Four lines in Shadow::drop.

Tests

  • host::tests::a_retirement_waits_for_the_submission_that_was_running — the queue the fix depends on. Probe: make the queue never wait → red naming held while a submission runs → restored byte-identical (sha256 a8f68df6…).
  • cargo test -p victory-gpu --lib inplace:: -- --test-threads=1 → 6 passed.
  • cargo clippy -p victory-gpu --lib -- -D warnings → only the two pre-existing (placed_filler_twins, sort_unstable_by_key), both owned by #841.

What this does not cover

  • The four-line wiring itself has no test. A test for it needs a shadow, which needs a whole host. The title is the only end-to-end check.
  • #878 must stay open. It retries the decommit in the test's own drop(placed) path, which never goes through Shadow::drop — so this does not make it redundant, and closing it on the strength of this would leave that path flaky.
  • Opening INPLACE heaps on the ≥ 1 TiB persistent alias for buffers only is not in this PR; that was the other half of the planned phase and is untouched.

Measured, not asserted

cargo test -p victory-gpu --lib -- --test-threads=1 on this head: 159 passed, 1 failed, 4 ignored — the failure being indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which fails on f85101b6 too and is fixed by #849/#847.

**@⁠HailLucifer666** on GitHub · 2026-11-25 13:24 UTC · [original](https://github.com/fxceless/victory-fork/pull/943) `HailLucifer666:perf/inplace-fence-retirer` → `main` · +64 −1 · 2 files · 2 commits · open ### Problem A heap opened from the title's own memory locks those pages. While it stands, the title's `VirtualFree`, `VirtualProtect` or release of them answers `ERROR_INVALID_PARAMETER` (87) — the module's own header says so, and the probe shows it. When a placed buffer's shadow went, `Shadow::drop` let the heap go in the same breath as the buffer, without asking whether a queue had run the work that used it. A title that decommitted those pages in the next moment failed a call that should have worked. This is not hypothetical: `inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset` asserts that decommit and **passes and fails on the same commit** (3 of 6 full runs on `f85101b6`). ### What actually fixes it `host::retire` already exists (`host.rs:209`) — "Drops `object` once every submission running now has finished: at once if none is." No new retirement queue is needed; this branch adds none. `Shadow::placed` keeps only the **heap** (`place = Some((heap, bias))`); the buffer that stands in it is a field of the shadow, so Rust's drop glue runs the buffer *after* `Drop::drop` returns. Retiring the heap inside that body therefore yields buffer-then-heap for free, which is the COM ordering rule: a placed resource must not outlive the heap it stands in. Four lines in `Shadow::drop`. ### Tests - `host::tests::a_retirement_waits_for_the_submission_that_was_running` — the queue the fix depends on. **Probe:** make the queue never wait → red naming `held while a submission runs` → restored byte-identical (`sha256 a8f68df6…`). - `cargo test -p victory-gpu --lib inplace:: -- --test-threads=1` → 6 passed. - `cargo clippy -p victory-gpu --lib -- -D warnings` → only the two pre-existing (`placed_filler_twins`, `sort_unstable_by_key`), both owned by #841. ### What this does not cover - **The four-line wiring itself has no test.** A test for it needs a shadow, which needs a whole host. The title is the only end-to-end check. - **#878 must stay open.** It retries the decommit in the *test's own* `drop(placed)` path, which never goes through `Shadow::drop` — so this does not make it redundant, and closing it on the strength of this would leave that path flaky. - Opening `INPLACE` heaps on the ≥ 1 TiB persistent alias for buffers only is **not** in this PR; that was the other half of the planned phase and is untouched. ### Measured, not asserted `cargo test -p victory-gpu --lib -- --test-threads=1` on this head: 159 passed, 1 failed, 4 ignored — the failure being `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, which fails on `f85101b6` too and is fixed by #849/#847.
A heap opened from the title's address locks those pages. While it stands,
the title's own `VirtualFree` of them answers `ERROR_INVALID_PARAMETER`
(87). When a placed buffer's shadow went, the heap was let go in the same
breath, so a title that decommitted those pages in the next moment failed a
call that should have worked.

The heap now goes through the host's existing retirement queue, which holds
it while a submission is running and drops it once that submission has
finished. The buffer that stands in the heap is a field of the shadow, so
the drop glue runs it after this call returns: buffer first, as it must be.

Tested: `a_retirement_waits_for_the_submission_that_was_running` covers the
queue this depends on, red when the queue is made to never wait. It does NOT
cover this one-line wiring: that needs a shadow, which needs a whole host,
and the title itself is the only end-to-end check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:20 +00:00
github-bot force-pushed github-bot/gh-943 from 2185fe57b1 to de276299c3 2026-11-26 14:11:56 +00:00 Compare
Author
Owner

@⁠HailLucifer666 on GitHub · 2026-11-26 14:10 UTC · original

Rebased onto main a20809de; head is now de276299 (the two commits replayed). Two conflicts: a both-added tests block (main's card-sync test kept alongside the retirement test), and retire/bury, where main has since added the retire_lean/reaper_on fast paths inline while this PR extracted retire_into/bury_from for the test. Resolution keeps main's retire verbatim (the lean path needs ownership of the object), keeps bury's lean path followed by bury_from, and marks retire_into #[cfg(test)] since only the test drives it. Verified: cargo check and clippy -D warnings clean; a_retirement_waits_for_the_submission_that_was_running passed.

**@⁠HailLucifer666** on GitHub · 2026-11-26 14:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/943#issuecomment-7194370102) Rebased onto `main` `a20809de`; head is now `de276299` (the two commits replayed). Two conflicts: a both-added tests block (main's card-sync test kept alongside the retirement test), and `retire`/`bury`, where main has since added the `retire_lean`/`reaper_on` fast paths inline while this PR extracted `retire_into`/`bury_from` for the test. Resolution keeps main's `retire` verbatim (the lean path needs ownership of the object), keeps `bury`'s lean path followed by `bury_from`, and marks `retire_into` `#[cfg(test)]` since only the test drives it. Verified: `cargo check` and `clippy -D warnings` clean; `a_retirement_waits_for_the_submission_that_was_running` passed.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/943/head:github-bot/gh-943'
git switch 'github-bot/gh-943'

Merge

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