GPU: release replaced title memory layouts off the submitting thread #3144

Open
github-bot wants to merge 1 commit from github-bot/gh-3144 into main AGit
Owner

@⁠Ingenioeren on GitHub · 2026-11-26 10:10 UTC · original
Ingenioeren:fix/3137-layout-drop-off-thread → main · +79 −13 · 3 files · 1 commits · open

What

Queue the replaced title-memory layout on the existing release thread. The rewrite runs between submissions and updates the page table and its descriptors before handing off the old layout. Copies still used by the new table or by recorded work retain their own references. No extra GPU fence is needed. If the release worker is unavailable, the existing queue helper drops the value inline.

Keep upgraded shadow owners alive until the marks lock is released, including owners of withheld pages and owners rejected by the page bounds check.

Why

Replacing a layout can drop thousands of shadow references on the submitting thread while the heap locks are held. The diagnosis in #3137 also identified that dropping the last shadow reference during marks lookup can re-enter the marks lock and deadlock. The two changes address those paths together.

How tested

  • cargo test --locked --offline -p victory-gpu mark_lookup_releases_its_last_reference_outside_the_lock on origin/main (63bcca4) with only the regression test and its test-only hook applied. It failed with a five-second timeout after the weak upgrade became the last strong reference.
  • cargo test --locked --offline -p victory-gpu mark_lookup_releases_its_last_reference_outside_the_lock with the fix. One passed, covering both the withheld-page and out-of-range mark paths.
  • cargo test --locked --offline -p victory-gpu passed with 232 passed, 0 failed, and 1 ignored (the existing synthetic benchmark object::tests::benchmark_private_data_release). There were no doctests.
  • cargo clippy --locked --offline -p victory-gpu --all-targets passed with no warnings.
  • cargo run --locked --offline -p xtask -- policy --staged passed for all 3 staged files.

Test limits

No game run, independent performance measurement, or direct test of the layout destructor's thread.

Fixes #3137

AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.

**@⁠Ingenioeren** on GitHub · 2026-11-26 10:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/3144) `Ingenioeren:fix/3137-layout-drop-off-thread` → `main` · +79 −13 · 3 files · 1 commits · open ## What Queue the replaced title-memory layout on the existing release thread. The rewrite runs between submissions and updates the page table and its descriptors before handing off the old layout. Copies still used by the new table or by recorded work retain their own references. No extra GPU fence is needed. If the release worker is unavailable, the existing queue helper drops the value inline. Keep upgraded shadow owners alive until the marks lock is released, including owners of withheld pages and owners rejected by the page bounds check. ## Why Replacing a layout can drop thousands of shadow references on the submitting thread while the heap locks are held. The diagnosis in #3137 also identified that dropping the last shadow reference during marks lookup can re-enter the marks lock and deadlock. The two changes address those paths together. ## How tested - `cargo test --locked --offline -p victory-gpu mark_lookup_releases_its_last_reference_outside_the_lock` on `origin/main` (`63bcca4`) with only the regression test and its test-only hook applied. It failed with a five-second timeout after the weak upgrade became the last strong reference. - `cargo test --locked --offline -p victory-gpu mark_lookup_releases_its_last_reference_outside_the_lock` with the fix. One passed, covering both the withheld-page and out-of-range mark paths. - `cargo test --locked --offline -p victory-gpu` passed with 232 passed, 0 failed, and 1 ignored (the existing synthetic benchmark `object::tests::benchmark_private_data_release`). There were no doctests. - `cargo clippy --locked --offline -p victory-gpu --all-targets` passed with no warnings. - `cargo run --locked --offline -p xtask -- policy --staged` passed for all 3 staged files. ## Test limits No game run, independent performance measurement, or direct test of the layout destructor's thread. Fixes #3137 AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.
Rewriting the page table can give up the last references to old host copies while the heap locks are held. Queue the replaced layout for the release thread once the table names its new copies.

Keep each upgraded marks owner alive past the marks lock so that a last reference can return its mark run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:08:29 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 10:29 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: passed.
  • cargo test -p victory-gpu --lib memory:: -- --test-threads=1 --skip lists_share_a_table_and_copies_keep_their_views: 7/7 passed.
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly defers dropping replaced title memory layouts off the submitting thread.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 10:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3144#pullrequestreview-6072445034) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1`: passed. - `cargo test -p victory-gpu --lib memory:: -- --test-threads=1 --skip lists_share_a_table_and_copies_keep_their_views`: 7/7 passed. - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20/20 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly defers dropping replaced title memory layouts off the submitting thread. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 10:39 UTC · original

@⁠Ingenioeren I checked the destructor thread you listed as untested on exact head 35b9c70608 and parent main 63bcca43c6.

I ran the same fixture on Windows with WARP verified by the DXGI software adapter flag. It rewrote a real D3D12 page table twice, put a thread marker at the end of the old Layout, and waited for its last Arc to drop. The second rewrite published generation 2 on both builds, and the old Arc count reached zero on both.

Build Thread that dropped the old layout
main 63bcca4 The thread calling Shared::rewrite
this head 35b9c70 victory-release

The assertion for off-thread disposal failed on main and passed here. This establishes the handoff for one synthetic table rewrite. The reporter's timing measurements still need a title run.

My narrower #3145 covers the same mark-owner lifetime change. This PR also carries the layout handoff, so the two patches should be considered together. If you adopt our test approach or carry code from #3145, please retain the Git author when cherry-picking. If it is folded into another commit, please use the trailer below.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 10:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/3144#issuecomment-7189659779) @⁠Ingenioeren I checked the destructor thread you listed as untested on exact head 35b9c706083a75e765ee8bd84c22a0d4ac34ebfa and parent main 63bcca43c6a00a758510398fa43096ce7e4f7df0. I ran the same fixture on Windows with WARP verified by the DXGI software adapter flag. It rewrote a real D3D12 page table twice, put a thread marker at the end of the old Layout, and waited for its last Arc to drop. The second rewrite published generation 2 on both builds, and the old Arc count reached zero on both. | Build | Thread that dropped the old layout | | --- | --- | | main 63bcca4 | The thread calling Shared::rewrite | | this head 35b9c70 | victory-release | The assertion for off-thread disposal failed on main and passed here. This establishes the handoff for one synthetic table rewrite. The reporter's timing measurements still need a title run. My narrower #3145 covers the same mark-owner lifetime change. This PR also carries the layout handoff, so the two patches should be considered together. If you adopt our test approach or carry code from #3145, please retain the Git author when cherry-picking. If it is folded into another commit, please use the trailer below. Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
This pull request can be merged automatically.
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/3144/head:github-bot/gh-3144'
git switch 'github-bot/gh-3144'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3144'
git switch 'github-bot/gh-3144'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3144'
git switch 'github-bot/gh-3144'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3144'
git switch 'main'
git merge --squash 'github-bot/gh-3144'
git switch 'main'
git merge --ff-only 'github-bot/gh-3144'
git switch 'main'
git merge 'github-bot/gh-3144'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3144
No description provided.