GPU tests: each test's prepare hook runs on its own thread #2583
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2585"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-25T16:16:16Z.
Two
victory-gputests added in42ea09ffail intermittently when the suite runs in parallel (the default forcargo test):descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record: "the slot views the record written last"descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait: "both made"Each passes when run alone.
Cause
Both tests install work in
WHILE_PREPARING, whichprepareruns once. It was one global for the whole test process. Every test that binds a view callsprepare, so with tests running in parallel:preparecan take the hook first, so the work runs inside that test instead, orprepareruns, so this test runs the other one's work.Either way, the concurrent write (or bind) the test checks for never happens, and its assertion fails.
Change
WHILE_PREPARINGis now thread-local.prepareruns on the thread that binds the view (HostHeap::mirror), so each test's hook runs in its ownprepareand nowhere else. The two tests set and check it viaset/with_borrow. This is test code only; nothing outside#[cfg(test)]changes.WHILE_MAKINGis left alone, because it already only runs for its own slot.Testing
Windows 10 Pro 22H2 (19045), RTX 3080 (driver 617.42), Rust 1.98.1 MSVC, base
67e8ae1. The fullvictory-gpulib test binary was run 200 times in a row with default parallelism:main67e8ae1a_slot_rewritten_…13,views_bound_…11)The other failures on this machine are unchanged in both builds and unrelated. They happen in every run:
dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views(NVIDIA's view heap cap,FIND-9), plusa_texture_written_in_one_format_reads_in_another_through_a_placed_view(Windows 10 has noID3D12Device10, #1999).cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean, also with--all-featurescargo xtask policy:184 files okClaim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7167717052
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T16:33:48Z.
oni-swr verification — head
19016aaf6f13fdc7d338ad15fb825453e8717739,origin/main67e8ae1401df112248aed36d0024483181b718b7Environment: Windows 11 Pro (26200), rustc 1.98.1, WARP only (
VICTORY_D3D12_WARP=1with--features diagnostics, which is what makes the host device the software adapter; Windows SDK 10.0.26100.0dxil.dllon PATH). No hardware GPU use in the reported runs, no game files, no retail data. Merge check:git merge-tree --write-tree origin/main <head>is clean.Commands / results
cargo test --locked -p victory-gpu --features diagnostics --lib -- descriptor::host::tests: 13 passed, 0 failed, 0 ignoredcargo test --locked -p victory-gpu --features diagnostics: 198 passed, 0 failed, 1 ignored (lib; 0 doctests)descriptor:: --test-threads=16:origin/main7/150 runs fail (views_bound_while_another_slot_gets_its_texture_do_not_wait4,a_slot_rewritten_while_its_view_is_prepared_views_the_new_record4); this PR 0/150.memory::tests::a_submission_that_missed_leaves_the_copies_at_onceon WARP: main 9/60, PR 14/60 (also seen once failing onbindless::tests::heap_views_are_currenton main). It is not touched by this diff, passes alone and with--test-threads=1; noting it so it is not blamed on this PR.Review: test-only change.
WHILE_PREPARINGbecomes athread_local!RefCell;prepareruns on the thread callingHostHeap::mirror, so the hook set by a test is consumed on that same thread, and the helper threads the tests spawn only perform the concurrent write/bind (they never need the hook).WHILE_MAKINGcorrectly left alone. I found no defects.Overlap: no open PR changes the same hunks. #2547, #2558, #2543, #2542, #2541, #2483 also touch
descriptor/host.rsand all merge with this branch cleanly (merge-tree); #2475 conflicts with it indescriptor/host.rs/draw.rs(an ordering matter for whichever lands second, not this PR's fault).AI disclosure: this review and verification were done by Claude Code (Claude Sonnet 5.5), not a human reviewer. Comment-only; no code changed.
Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-25T17:07:05Z.
Thanks, @oni-swr. Your 7/150 → 0/150 on WARP matches what I saw on hardware.
On
memory::tests::a_submission_that_missed_leaves_the_copies_at_once: it never failed in any of my full-suite runs on an RTX 3080 (Windows 10, default parallelism). That's 0 of 550: 200 onmain67e8ae1, 200 with this PR and 150 more on other builds. So it looks specific to WARP (or to its timing), which fits your reading that it's unrelated here.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:19:41Z.
Automated triage for the maintainers.
Merge candidate. This is a test-only fix for two flaky
descriptor::hosttests.WHILE_PREPARINGwas one process-wide hook, andprepareruns it for every view any parallel test binds, so another test could take or replace it first. It is now athread_local!RefCell.prepare(descriptor/host.rs) callstests::while_preparing()on the thread that callsHostHeap::mirror, which is the test's own thread, so each hook runs in its own test. The helper threads the tests spawn never need it. Nothing outside#[cfg(test)]changes.CI:
checkpassing. Merges cleanly into currentmain. A recommendation to look at it, not an approval.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:10:36Z.
Review: APPROVED
Verified locally merged onto
origin/main(63bcca43) at PR head19016aaf(Windows 11 x64, NVIDIA RTX 5090 + Microsoft WARP,VICTORY_D3D12_DEBUG=1):crates/victory-gpu/src/descriptor/host.rs(#[cfg(test)]only): movesWHILE_PREPARINGto athread_local!RefCell<Option<Work>>, eliminating cross-test hook races under parallelcargo test.while_preparing()takes the closure viawith_borrow_mut(Option::take)before callingwork(), avoiding re-entrant borrow panics or leaked hooks if a callback panics. Confirmed no otherWHILE_PREPARINGcallers exist in the workspace (WHILE_MAKINGis already slot-keyed).cargo xtask policy: 191 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features): 0 warnings.--features diagnostics,VICTORY_D3D12_DEBUG=1,descriptor::host::tests::at--test-threads=16):--test-threads=1pass;dynamic_slots_are_held_until_releasedhits the unrelated NVIDIA view-heap cap onmain).Synthetic tests only; looks ready to merge.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:10:48Z.
Review: APPROVED
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).descriptor::host::tests.cargo test -p victory-gpu --lib descriptor::host::tests:: -- --skip dynamic_slots_are_held_until_released --test-threads=1: 14 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T07:23:07Z.
Two recent Windows CI runs on separate PR heads still fail at the assertion this test-only patch addresses:
Both logs report the sole failing test as descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait, with “both made” at host.rs:2011. The timeout assertion has a different message. I checked that
19016aafstill scopes the prepare hook to the test thread and that its own Windows check is green. These are two recent examples for the merge decision. Once this fix is on main, updating the two PR branches will let their checks run with it.AI-assisted log and diff review.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T19:28:57Z.
NVIDIA row for this PR: on an RTX 3070 the two
descriptor::hosttests failed in 2 of 20 full-suite runs on main and 0 of 20 with the PR. Run as a pair, they failed in 7 of 10 runs on main and 0 of 10 with the PR.RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, Rust 1.98.1, debug. The PR head is
19016aa, on base67e8ae1, which is 78 commits behind main63bcca4. Main has changeddescriptor/host.rssince then (351 insertions, 27 deletions), so I merged the head onto63bcca4locally with--no-ff. The merge is clean, and its diff against63bcca4changes the same lines as the PR (1 file, 15 insertions, 9 deletions). "Main" below is63bcca4and "PR" is that merge. Each tree had its ownCARGO_TARGET_DIR. Runs alternated between the two trees.Full suite, default parallelism, 20 runs per tree:
cargo test --locked -p victory-gpu --lib63bcca463bcca4descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_recorddescriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_waitboth made, host.rs:2011)watch::tests::a_retake_marks_the_copies_and_keeps_the_guardleft: 4,right: 2)Totals: main had 229 passed, 2 failed, 1 ignored in 18 runs and 228 passed, 3 failed, 1 ignored in 2 runs. The PR had 229 passed, 2 failed, 1 ignored in 19 runs and 228 passed, 3 failed, 1 ignored in 1 run.
That is a lower rate on main than in my earlier runs during #3780, where one of the two failed in 5 of 6 full runs on the same commit and card.
The two tests together, 10 runs per tree:
cargo test --locked -p victory-gpu --lib -- descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait63bcca463bcca4a_slot_rewritten_while_its_view_is_prepared_views_the_new_recordthe slot views the record written last, host.rs:1967)views_bound_while_another_slot_gets_its_texture_do_not_waitboth made)On main, 7 of 10 runs had a failure, with one test failing in each. With only these two tests running, each one's hook can still be taken by the other, which fits the cause in the description.
Known failures, in all 40 full runs on both trees and not counted above:
descriptor::host::tests::dynamic_slots_are_held_until_released;memory::tests::lists_share_a_table_and_copies_keep_their_views.They are NVIDIA's view-heap cap, the same two as in the description.
The single
watch::tests::a_retake_marks_the_copies_and_keeps_the_guardfailure was in a file the PR does not touch. The page protection read back wasPAGE_READWRITE(4) wherePAGE_READONLY(2) was expected. Run alone with-- watch::tests::a_retake_marks_the_copies_and_keeps_the_guard --exact, it passed in 10 of 10 runs on each tree. I read it as a separate parallel-run flake and not as an effect of the PR. One failure in 20 runs is too few to say more.Not tested:
--features diagnostics, WARP and the debug layer;--test-threadsother than the default;67e8ae1;cargo xtask policy, release and a title run.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.