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

Open
HailLucifer666 wants to merge 2 commits from upstream-pr/943 into main
HailLucifer666 commented 2026-11-25 13:24:53 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HailLucifer666 on 2026-11-25T13:24:53Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6605507806 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/943). Originally posted by [HailLucifer666](https://github.com/HailLucifer666) on 2026-11-25T13:24:53Z. --- ### 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 commented 2026-11-26 15:04:07 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HailLucifer666 on 2026-11-26T14:10:01Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7194370102 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/943#issuecomment-7194370102). Originally posted by [HailLucifer666](https://github.com/HailLucifer666) on 2026-11-26T14:10:01Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/943:upstream-pr/943'
git switch 'upstream-pr/943'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/943'
git switch 'upstream-pr/943'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/943'
git switch 'upstream-pr/943'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/943'
git switch 'main'
git merge --squash 'upstream-pr/943'
git switch 'main'
git merge --ff-only 'upstream-pr/943'
git switch 'main'
git merge 'upstream-pr/943'
git push origin 'main'
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
fxceless/victory-fork!942
No description provided.