Skip to content

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

Open
HailLucifer666 wants to merge 2 commits into
fxceless:mainfrom
HailLucifer666:perf/inplace-fence-retirer
Open

HailLucifer666 wants to merge 2 commits into
fxceless:mainfrom
HailLucifer666:perf/inplace-fence-retirer

Conversation

@HailLucifer666

Copy link
Copy Markdown

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 Clippy: main is clean again with -D warnings, with and without --all-features (3 lints) #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.
  • inplace test: decommit the pages again for up to two seconds (the test failed about 8 runs in 100) #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 added a commit to HailLucifer666/victory-fork that referenced this pull request Nov 25, 2026
The in-place heap fix and the MSVC environment script no longer travel
together: fxceless#943 is the fix, fxceless#944 is the build script, each one commit, each
one reviewable on its own.
triippywhale pushed a commit to triippywhale/victory-fork that referenced this pull request Nov 25, 2026
…ntil the submissions that could read through it have finished

Hand port of PalmVIDev 64f709832 (in fxceless#239; fxceless#943): a
copy placed in a heap opened over title memory let the heap go the moment
the copy went, while a submission still running could read through it.
The heap now goes through the host's retirement queue (host::retire),
which holds it until the submissions running then have finished; the
buffer placed in it is a field and goes first.

Its retirement-queue test is not ported: it rewrites the process-wide
STARTED/FINISHED counters, which other host tests in the same process use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
notquiteog added a commit to notquiteog/VIctory that referenced this pull request Nov 26, 2026
… the submissions that could read through it have finished (by HailLucifer666)

Changed in porting: the one change to Shadow's drop is taken as it is (the
heap of a copy in place goes to host::retire). The PR's test is left out:
it expects a retirement with nothing running to drop at once, and here
VICTORY_BURY_LAG (64 submissions by default) keeps every retirement. Only
reached with VICTORY_INPLACE or VICTORY_STRETCH set; both are off by
default.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…through it have finished

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.
@HailLucifer666
HailLucifer666 force-pushed the perf/inplace-fence-retirer branch from f021e65 to de27629 Compare November 26, 2026 14:10
@HailLucifer666

HailLucifer666 commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant