GPU tests: one page-table test lock for every test that binds a list #2886

Open
Jackster wants to merge 1 commit from upstream-pr/2888 into main
Jackster commented 2026-11-25 23:07:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-25T23:07:10Z.


memory::tests::bitmap_pool_reuses_and_zeroes_across_resets asserts that a list whose page tables were released gets its own 256 KiB dirty-page bitmap back when it is bound again. The pool those bitmaps come from (BITMAP_POOL) is shared by the whole process, hands them back last-in-first-out and is capped at 64, so the assertion only holds while no other test takes or returns a bitmap in between.

memory's tests already held gpu_test_lock for exactly that reason, but two other tests take a page table from the same pool without it:

  • descriptor::tests::a_released_view_heap_drops_its_page_table (through memory::bind);
  • draw::tests::compute_view_marks_rebind_after_depth_twin_conversion (through State::bind, which binds a heap's page table).

In a parallel suite run they do just that between the reset and the next bind, and the assertion fails:

test memory::tests::bitmap_pool_reuses_and_zeroes_across_resets ... FAILED
panicked at crates\victory-gpu\src\memory.rs:854:
assertion `left == right` failed: reset returns bitmap to pool for reuse

Fix

gpu_test_lock becomes a module-level #[cfg(test)] pub(crate) helper (it was private to memory::tests), documented with the pool's properties, and every test that binds a list holds it for its run. No production code changes: at runtime the pool is only reached from the submitting thread.

Verified

Windows 11, RX 7900 XTX, 223d010-equivalent tree, debug:

before after
victory-gpu test binary, --test-threads=256 1 failure in 7 runs 40 runs, 0 failures
cargo test -p victory-gpu (default threads) clean clean
cargo test --workspace --exclude victory-core — 856 passed, 0 failed, 9 ignored

victory.example.toml is absent from this checkout, which is the only reason victory-core is excluded; the change touches no config code.

Notes for review

  • Related to FIND-20 (parallel-suite flakiness in victory-gpu) but not the same test: this one is in memory, not watch, and 30 runs of the watch:: tests alone showed no failure here. FIND-20 should stay open.
  • The lock is only held by five tests, and none of them calls another, so it cannot deadlock.
  • Synthetic test data only, no game files.

Claimed in #1633: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7177154035

AI-assisted (drafted with an AI coding agent); the reproduction and the test runs above are my own.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6615595243 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2888). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-25T23:07:10Z. --- `memory::tests::bitmap_pool_reuses_and_zeroes_across_resets` asserts that a list whose page tables were released gets *its own* 256 KiB dirty-page bitmap back when it is bound again. The pool those bitmaps come from (`BITMAP_POOL`) is shared by the whole process, hands them back last-in-first-out and is capped at 64, so the assertion only holds while no other test takes or returns a bitmap in between. `memory`'s tests already held `gpu_test_lock` for exactly that reason, but two other tests take a page table from the same pool without it: * `descriptor::tests::a_released_view_heap_drops_its_page_table` (through `memory::bind`); * `draw::tests::compute_view_marks_rebind_after_depth_twin_conversion` (through `State::bind`, which binds a heap's page table). In a parallel suite run they do just that between the reset and the next bind, and the assertion fails: ``` test memory::tests::bitmap_pool_reuses_and_zeroes_across_resets ... FAILED panicked at crates\victory-gpu\src\memory.rs:854: assertion `left == right` failed: reset returns bitmap to pool for reuse ``` ### Fix `gpu_test_lock` becomes a module-level `#[cfg(test)] pub(crate)` helper (it was private to `memory::tests`), documented with the pool's properties, and every test that binds a list holds it for its run. No production code changes: at runtime the pool is only reached from the submitting thread. ### Verified Windows 11, RX 7900 XTX, `223d010`-equivalent tree, debug: | | before | after | |---|---|---| | `victory-gpu` test binary, `--test-threads=256` | 1 failure in 7 runs | 40 runs, 0 failures | | `cargo test -p victory-gpu` (default threads) | clean | clean | | `cargo test --workspace --exclude victory-core` | — | 856 passed, 0 failed, 9 ignored | `victory.example.toml` is absent from this checkout, which is the only reason `victory-core` is excluded; the change touches no config code. ### Notes for review * Related to `FIND-20` (parallel-suite flakiness in `victory-gpu`) but not the same test: this one is in `memory`, not `watch`, and 30 runs of the `watch::` tests alone showed no failure here. `FIND-20` should stay open. * The lock is only held by five tests, and none of them calls another, so it cannot deadlock. * Synthetic test data only, no game files. Claimed in #1633: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7177154035 AI-assisted (drafted with an AI coding agent); the reproduction and the test runs above are my own.
kotekompotek commented 2026-11-26 00:03:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:34:12Z.

Review: COMMENTED


Right scope extension: the bitmap pool is process-wide and LIFO, so any test binding a list (directly or through draw::State::bind) can interleave with another's acquire/return — same flake class as #2861. Promoting the lock to pub(crate) and holding it for the whole run is the correct fix. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066470388 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2888#pullrequestreview-6066470388). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:34:12Z. **Review:** COMMENTED --- Right scope extension: the bitmap pool is process-wide and LIFO, so any test binding a list (directly or through draw::State::bind) can interleave with another's acquire/return — same flake class as #2861. Promoting the lock to pub(crate) and holding it for the whole run is the correct fix. LGTM.
fuzeofficlal commented 2026-11-26 00:03:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:18:40Z.


Reviewed and verified 9c70f452 on Windows 11 (RTX 5090 + WARP) against main (842b0cb):

  • Audited all memory::bind / State::bind test call sites across victory-gpu: all 4 direct memory::bind tests and compute_view_marks_rebind_after_depth_twin_conversion now share memory::gpu_test_lock() at the outermost test scope with no nested re-entry (and placed_uav_dispatch_writes_its_texture uses stage.memory == None, so it does not touch page tables or BITMAP_POOL).
  • Local checks: WARP (--features diagnostics, full crate parallel run) 242 passed; 0 failed; 1 ignored with zero deadlocks; RTX 5090 226/227 (only the pre-existing 842b0cb NVIDIA 1M-heap lists_share_a_table_and_copies_keep_their_views baseline issue); cargo clippy --locked -p victory-gpu --all-targets -- -D warnings 0 warnings; cargo xtask policy (190 files ok).

Looks clean and ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177391831 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2888#issuecomment-7177391831). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:18:40Z. --- Reviewed and verified `9c70f452` on Windows 11 (RTX 5090 + WARP) against `main` (`842b0cb`): - Audited all `memory::bind` / `State::bind` test call sites across `victory-gpu`: all 4 direct `memory::bind` tests and `compute_view_marks_rebind_after_depth_twin_conversion` now share `memory::gpu_test_lock()` at the outermost test scope with no nested re-entry (and `placed_uav_dispatch_writes_its_texture` uses `stage.memory == None`, so it does not touch page tables or `BITMAP_POOL`). - Local checks: WARP (`--features diagnostics`, full crate parallel run) **242 passed; 0 failed; 1 ignored** with zero deadlocks; RTX 5090 `226/227` (only the pre-existing `842b0cb` NVIDIA 1M-heap `lists_share_a_table_and_copies_keep_their_views` baseline issue); `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` 0 warnings; `cargo xtask policy` (`190 files ok`). Looks clean and ready to merge.
Marvisak commented 2026-11-26 05:04:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:29:09Z.


Automated triage for the maintainers.

Merge candidate. Fixes a flaky test: bitmap_pool_reuses_and_zeroes_across_resets relies on the process-wide BITMAP_POOL, but two other tests took page tables from it without the lock. gpu_test_lock moves to module level in victory-gpu/src/memory.rs, and a_released_view_heap_drops_its_page_table and compute_view_marks_rebind_after_depth_twin_conversion now hold it. No production changes.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182636010 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2888#issuecomment-7182636010). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:29:09Z. --- <!-- victory-triage v1 head=9c70f45290b3e5ea20844675a5190374d29e051e verdict=merge-candidate at=2026-11-26T04:29:03Z --> Automated triage for the maintainers. **Merge candidate.** Fixes a flaky test: `bitmap_pool_reuses_and_zeroes_across_resets` relies on the process-wide `BITMAP_POOL`, but two other tests took page tables from it without the lock. `gpu_test_lock` moves to module level in `victory-gpu/src/memory.rs`, and `a_released_view_heap_drops_its_page_table` and `compute_view_marks_rebind_after_depth_twin_conversion` now hold it. No production changes. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 10:04:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:52:03Z.

Review: APPROVED


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

  • 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 unifies the page-table test lock across all GPU tests that bind a command list.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6071885569 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2888#pullrequestreview-6071885569). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T09:52:03Z. **Review:** APPROVED --- Verified on RTX 5090 against `origin/main` (`63bcca4`): - `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 unifies the page-table test lock across all GPU tests that bind a command list. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 12:05:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T11:04:59Z.

Review: APPROVED


Verified 9c70f452 locally on Windows 11 (RTX 5090 and WARP, with VICTORY_D3D12_DEBUG=1):

  • cargo xtask policy and cargo clippy -p victory-gpu --tests -- -D warnings (default and --all-features): clean.
  • memory:: (7/7, excluding the pre-existing lists_share_a_table_and_copies_keep_their_views baseline), descriptor::tests::a_released_view_heap_drops_its_page_table, and draw::tests::compute_view_marks_rebind_after_depth_twin_conversion: all passed.
  • Ran 10 consecutive default-parallel rounds of bitmap_pool_reuses_and_zeroes_across_resets, a_released_view_heap_drops_its_page_table, compute_view_marks_rebind_after_depth_twin_conversion, and a_submission_that_missed_leaves_the_copies_at_once: 10/10 passed on RTX 5090 and 10/10 passed on WARP + VICTORY_D3D12_DEBUG=1.

Audited all memory::bind and State::bind test paths across victory-gpu — every test that can touch BITMAP_POOL now serializes on memory::gpu_test_lock() with no nested acquisition. Looks good to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6073017224 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2888#pullrequestreview-6073017224). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T11:04:59Z. **Review:** APPROVED --- Verified `9c70f452` locally on Windows 11 (RTX 5090 and WARP, with `VICTORY_D3D12_DEBUG=1`): - `cargo xtask policy` and `cargo clippy -p victory-gpu --tests -- -D warnings` (default and `--all-features`): clean. - `memory::` (7/7, excluding the pre-existing `lists_share_a_table_and_copies_keep_their_views` baseline), `descriptor::tests::a_released_view_heap_drops_its_page_table`, and `draw::tests::compute_view_marks_rebind_after_depth_twin_conversion`: all passed. - Ran 10 consecutive default-parallel rounds of `bitmap_pool_reuses_and_zeroes_across_resets`, `a_released_view_heap_drops_its_page_table`, `compute_view_marks_rebind_after_depth_twin_conversion`, and `a_submission_that_missed_leaves_the_copies_at_once`: 10/10 passed on RTX 5090 and 10/10 passed on WARP + `VICTORY_D3D12_DEBUG=1`. Audited all `memory::bind` and `State::bind` test paths across `victory-gpu` — every test that can touch `BITMAP_POOL` now serializes on `memory::gpu_test_lock()` with no nested acquisition. Looks good to merge.
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/2888:upstream-pr/2888'
git switch 'upstream-pr/2888'

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/2888'
git switch 'upstream-pr/2888'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2888'
git switch 'upstream-pr/2888'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2888'
git switch 'main'
git merge --squash 'upstream-pr/2888'
git switch 'main'
git merge --ff-only 'upstream-pr/2888'
git switch 'main'
git merge 'upstream-pr/2888'
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
Marvisak/VIctory!2886
No description provided.